"use client"; import { useOrderDetail } from "@/lib/providers/order-detail-provider"; import OrderStepperStatus from "./order-stepper-status"; import OrderTimeAddressInfoAlert from "./order-time-address-info-alert"; import OrderItems from "./order-items"; import OrderPaymentSticky from "./order-payment-sticky"; const STATUS_LABELS: Record = { placed: "ثبت شد", preparing: "در حال آماده‌سازی", ready_to_ship: "آماده ارسال", handed_to_courier: "ارسال شد", delivered: "تحویل داده شد", cancelled: "لغو شد", }; export default function OrderDetailContent() { const { data: orderGroup, error, isLoading } = useOrderDetail(); if (isLoading) { return
در حال بارگذاری...
; } if (error || !orderGroup) { return (
{error ?? "سفارش یافت نشد"}
); } // وضعیت اصلی رو از اولین سفارش می‌گیریم (یا می‌تونی منطق پیچیده‌تری بذاری) const mainStatus = orderGroup.orders[0]?.status ?? "placed"; const statusToStep: Record = { placed: 0, preparing: 2, ready_to_ship: 3, handed_to_courier: 3, delivered: 4, cancelled: -1, }; const currentStep = statusToStep[mainStatus] ?? 0; const statusLabel = STATUS_LABELS[mainStatus] ?? mainStatus; return (

{statusLabel}

{mainStatus !== "cancelled" && ( )}
); }