From 2048e99bf219c2682185204759a67c4970701871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Afra=20=E2=80=8C?= Date: Wed, 2 Sep 2026 15:14:43 +0330 Subject: [PATCH] feat: C08 page implemented --- .../(shop)/checkout/[store]/confirm/page.tsx | 14 ++++- src/components/customer/checkout-address.tsx | 54 +++++++++++++++++++ .../customer/checkout-fulfillment.tsx | 9 ++-- src/components/customer/checkout-payment.tsx | 14 +++-- src/lib/api/gooyal-accounts.ts | 8 +-- 5 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 src/components/customer/checkout-address.tsx diff --git a/src/app/(customer)/(shop)/checkout/[store]/confirm/page.tsx b/src/app/(customer)/(shop)/checkout/[store]/confirm/page.tsx index 9411ca7..9a6b8d2 100644 --- a/src/app/(customer)/(shop)/checkout/[store]/confirm/page.tsx +++ b/src/app/(customer)/(shop)/checkout/[store]/confirm/page.tsx @@ -4,10 +4,16 @@ import { ArrowRight } from "lucide-react"; import { getCart } from "@/lib/api/cart"; import { getAddresses } from "@/lib/api/addresses"; import { requireSession } from "@/lib/auth/session"; +import { CheckoutAddress } from "@/components/customer/checkout-address"; import { CheckoutPayment } from "@/components/customer/checkout-payment"; -export default async function ConfirmPaymentPage({ params }: PageProps<"/checkout/[store]/confirm">) { +export default async function ConfirmPaymentPage({ + params, + searchParams, +}: PageProps<"/checkout/[store]/confirm">) { const { store } = await params; + const { fulfillment } = await searchParams; + const isDelivery = fulfillment === "delivery"; await requireSession(`/checkout/${store}/confirm`); const [cart, addresses] = await Promise.all([ @@ -19,6 +25,8 @@ export default async function ConfirmPaymentPage({ params }: PageProps<"/checkou const group = cart.groups.find((g) => g.store.uuid === store); if (!group) notFound(); + const address = addresses.find((a) => a.is_default) ?? addresses[0] ?? null; + return (
{/* Same header pattern as /cart and /checkout/[store]. */} @@ -29,7 +37,9 @@ export default async function ConfirmPaymentPage({ params }: PageProps<"/checkou

تأیید و پرداخت

- + {isDelivery && } + +
); } diff --git a/src/components/customer/checkout-address.tsx b/src/components/customer/checkout-address.tsx new file mode 100644 index 0000000..5210fc9 --- /dev/null +++ b/src/components/customer/checkout-address.tsx @@ -0,0 +1,54 @@ +import Link from "next/link"; +import { MapPin } from "lucide-react"; +import type { Address, AddressLabel } from "@/types/api"; + +const ADDRESS_LABEL_FA: Record = { + home: "خانه", + work: "محل کار", + other: "سایر", +}; + +/** + * "افزودن آدرس" / "تغییر آدرس" both just go to /addresses for now — the picker step + * in between (per the design) is a later task. + */ +export function CheckoutAddress({ address }: { address: Address | null }) { + return ( +
+

آدرس تحویل

+ + {address ? ( +
+ {/* DOM order intentionally mirrors the screenshot's left→right layout — see the + inherited dir="rtl" note on the /cart page. */} +
+ + تغییر آدرس + +
+ + {address.title || ADDRESS_LABEL_FA[address.label]} + + +
+
+

{address.full_address}

+
+ ) : ( +
+ + + +

+ هنوز آدرسی ثبت نکرده‌اید. برای ادامه سفارش، لطفاً یک آدرس اضافه کنید. +

+ + + +
+ )} +
+ ); +} diff --git a/src/components/customer/checkout-fulfillment.tsx b/src/components/customer/checkout-fulfillment.tsx index a3e638a..202b38e 100644 --- a/src/components/customer/checkout-fulfillment.tsx +++ b/src/components/customer/checkout-fulfillment.tsx @@ -94,9 +94,12 @@ export function CheckoutFulfillment({ group }: { group: CartGroup }) {
- {/* Pickup has its own confirm+pay screen (no address needed); delivery still - goes to the general /checkout form until that flow's design is provided. */} - + {/* Same confirm+pay screen either way — it shows the address section only for + delivery, and folds the delivery fee into the total only for delivery. */} +