"use client"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { Label } from "@/components/ui/label"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Textarea } from "@/components/ui/textarea"; import { Separator } from "@/components/ui/separator"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Input } from "@/components/ui/input"; import DeliveryTypeSelector from "./DeliveryTypeSelector"; import { useTranslations } from "next-intl"; import type { DeliveryType, PaymentType, Province } from "@/lib/types/api"; interface OrderBillingItem { title: string; value: string; } interface OrderBilling { body: OrderBillingItem[]; footer: { title: string; value: string; }; } interface OrderSummaryProps { order: { id: number; billing: OrderBilling; }; paymentType: PaymentType | null; deliveryType: DeliveryType; selectedRegion: string; selectedProvince: number | null; note: string; regionGroups: Record; availableRegions: string[]; paymentTypes: PaymentType[]; phone: string; name: string; lastName: string; onPhoneChange: (phone: string) => void; onNameChange: (name: string) => void; onLastNameChange: (lastName: string) => void; onPaymentTypeChange: (type: PaymentType) => void; onDeliveryTypeChange: (type: DeliveryType) => void; onRegionChange: (regionCode: string) => void; onProvinceChange: (provinceId: number) => void; onNoteChange: (note: string) => void; onCompleteOrder: () => void; isLoading: boolean; } export default function OrderSummary({ order, paymentType, deliveryType, selectedRegion, selectedProvince, note, regionGroups, availableRegions, paymentTypes, phone, name, lastName, onPhoneChange, onNameChange, onLastNameChange, onPaymentTypeChange, onDeliveryTypeChange, onRegionChange, onProvinceChange, onNoteChange, onCompleteOrder, isLoading, }: OrderSummaryProps) { const t = useTranslations(); const provincesForSelectedRegion = selectedRegion ? regionGroups[selectedRegion] || [] : []; const isFormValid = selectedRegion && selectedProvince && paymentType && phone && name; return ( {/* Customer Information */}

{t("customer_information")}

onNameChange(e.target.value)} placeholder={t("name")} className="rounded-lg" />
onLastNameChange(e.target.value)} placeholder={t("last_name")} className="rounded-lg" />
onPhoneChange(e.target.value)} placeholder={t("phone")} className="rounded-lg" />
{/* Payment Type */}

{t("payment_type")}

{paymentTypes.map((type) => ( onPaymentTypeChange(type)} >
{type.name}
))}
{/* Delivery Type */} {/* */} {/* Region Selection */}
{ onRegionChange(value); onProvinceChange(null as any); }} className="flex flex-wrap gap-4" > {availableRegions.map((regionCode) => (
))}
{/* Province Selection */} {selectedRegion && provincesForSelectedRegion.length > 0 && (
)} {/* Note */}