'use client'; import type { Order } from 'brainerce'; import { useTranslations } from '@/core/lib/translations'; import { cn } from '@/core/lib/utils'; import { OrderShipmentTracking, shipmentsOf } from './order-shipment-tracking'; interface OrderShippingBlockProps { order: Order; className?: string; } export function OrderShippingBlock({ order, className }: OrderShippingBlockProps) { const t = useTranslations('account'); const addr = order.shippingAddress; const hasAddress = !!addr?.line1; // The parcels, when the backend sends them: a progress bar and the latest updates per parcel. An older // backend or SDK has none, and the single tracking line below is shown exactly as before. const shipments = shipmentsOf(order); const hasTracking = !!(order.trackingNumber || order.trackingUrl || order.carrier); if (!hasAddress && !hasTracking && shipments.length === 0) return null; const fullName = [addr?.firstName, addr?.lastName].filter(Boolean).join(' '); const cityLine = [addr?.city, addr?.state || addr?.region, addr?.postalCode] .filter(Boolean) .join(', '); return (
{t('shippingAddress')}
{fullName &&{t('tracking')}