'use client'; import type { ShippingRate } from 'brainerce'; import { formatPrice } from 'brainerce'; import { useTranslations } from '@/core/lib/translations'; import { useCurrency } from '@/core/lib/use-currency'; import { cn } from '@/core/lib/utils'; interface ShippingStepProps { rates: ShippingRate[]; selectedRateId: string | null; onSelect: (rateId: string) => void; loading?: boolean; className?: string; } /** * Live carrier rates arrive labelled with the carrier's own service identifier * — `USPS PriorityMailInternational`, `USAExportPBA USAExportStandard` — which * answers a question no shopper asked. They are choosing between how fast and * how much, so we render `speedTier` in the store's own language instead. * * Manual zone rates carry no `speedTier`: the merchant named those deliberately, * so those keep `rate.name` exactly as written. */ const TIER_KEYS = { cheapest: 'shippingTierCheapest', balanced: 'shippingTierBalanced', fastest: 'shippingTierFastest', } as const; export function ShippingStep({ rates, selectedRateId, onSelect, loading = false, className, }: ShippingStepProps) { const t = useTranslations('checkout'); const tc = useTranslations('common'); const currency = useCurrency(); if (rates.length === 0) { return (
{t('noShippingOptions')}
{t('noShippingOptionsHint')}