'use client'; import { useLocale, useTranslations } from 'next-intl'; import { CreditCard, Pencil } from 'lucide-react'; import { Link } from '@/i18n/navigation'; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Callout } from '@/components/ui/callout'; import { BookingStatusBadge } from './BookingStatusBadge'; /** * Detail d'une reservation. * * Extrait de la page de liste, ou il etait ecrit en ligne avec une superposition * maison sans focus trap ni fermeture au clavier. */ interface BookingDetailDialogProps { booking: any | null; onOpenChange: (open: boolean) => void; buildEditUrl: (booking: any) => string; /** Namespace de la vue appelante, pour que le titre suive l'onglet. */ namespace?: string; } export function BookingDetailDialog({ booking, onOpenChange, buildEditUrl, namespace = 'dashboard.bookingsList', }: BookingDetailDialogProps) { const t = useTranslations(namespace as any); const locale = useLocale(); const dateLocale = locale === 'fr' ? 'fr-FR' : 'en-US'; if (!booking) return null; const longDate = (value?: string) => value ? new Date(value).toLocaleDateString(dateLocale, { day: '2-digit', month: 'long', year: 'numeric', }) : 'N/A'; const reference = booking.bookingId ? `#${booking.bookingId}` : `#${booking.id?.slice(0, 8).toUpperCase()}`; return ( {t('detail.title')} {reference}
{booking.carrierName && ( {booking.carrierName} )}
{booking.origin || booking.originCity || 'N/A'} {' → '} {booking.destination || booking.destinationCity || 'N/A'} {longDate(booking.createdAt || booking.requestedAt)} {booking.palletCount ? t('units.palletsCount', { count: booking.palletCount }) : '—'} {booking.weightKG ? t('units.kg', { value: booking.weightKG }) : 'N/A'} {booking.volumeCBM ? ` / ${t('units.cbm', { value: booking.volumeCBM })}` : ''} {booking.requestedPickupDate && ( {longDate(booking.requestedPickupDate)} )} {(booking.priceEUR || booking.priceUSD) && ( {booking.priceEUR ? `${booking.priceEUR} €` : `${booking.priceUSD} $`} )}
{booking.status === 'QUOTE' && ( {t('detail.quoteNotice')} )}
{booking.status === 'QUOTE' && ( <> )}
); } function Field({ label, children, emphasis = false, }: { label: string; children: React.ReactNode; emphasis?: boolean; }) { return (
{label}
{children}
); }