diff --git a/components/ordercontainer/OrderSteps.tsx b/components/ordercontainer/OrderSteps.tsx index afc15d1..32c76fd 100644 --- a/components/ordercontainer/OrderSteps.tsx +++ b/components/ordercontainer/OrderSteps.tsx @@ -440,20 +440,34 @@ export default function OrderSteps({ // ── Pickup step ──────────────────────────────────────────────── if (step === OrderStep.PICKUP) { + const hasExistingTimeslot = !!orderDetails?.pickupTimeslot; + return ( - 📍 Select Pickup Time + {hasExistingTimeslot + ? "📍 Change Pickup Time" + : "📍 Select Pickup Time"} - Order {orderNumber} has been paid. Choose when - you'd like to collect it. + {hasExistingTimeslot ? ( + <> + Order {orderNumber} already has a pickup time. + Select a new timeslot below. + + ) : ( + <> + Order {orderNumber} has been paid. Choose when + you'd like to collect it. + + )} onPickupConfirmed()} onCancel={() => router.push("/my-orders")} /> diff --git a/components/pickup/TimeslotSelector.tsx b/components/pickup/TimeslotSelector.tsx index 58da5e9..05b6c05 100644 --- a/components/pickup/TimeslotSelector.tsx +++ b/components/pickup/TimeslotSelector.tsx @@ -44,8 +44,21 @@ interface TimeslotResponse { hasMore: boolean; } +interface CurrentTimeslot { + date: string; + startTime: string; + endTime: string; + label?: string; + pickupInstructionProfile?: + | { id: string; name: string; shortSummary?: string } + | string + | null; +} + interface TimeslotSelectorProps { orderId: string; + /** If provided, indicates the user is changing an existing timeslot. */ + currentTimeslot?: CurrentTimeslot | null; onTimeslotSelected: ( timeslotId: string, pickupInstructions?: unknown[], @@ -106,9 +119,11 @@ async function fetchTimeslots(page: number): Promise { */ export function TimeslotSelector({ orderId, + currentTimeslot, onTimeslotSelected, onCancel, }: TimeslotSelectorProps) { + const isChanging = !!currentTimeslot; const [selectedId, setSelectedId] = useState(null); const [submitting, setSubmitting] = useState(false); const [submitError, setSubmitError] = useState(null); @@ -204,9 +219,41 @@ export function TimeslotSelector({ transition="opacity 0.15s ease" > - Select a Pickup Timeslot + {isChanging ? "Change Pickup Timeslot" : "Select a Pickup Timeslot"} + {/* Show current timeslot when changing */} + {isChanging && currentTimeslot && ( + + + CURRENT TIMESLOT + + + {currentTimeslot.startTime} – {currentTimeslot.endTime} + {currentTimeslot.label ? ` · ${currentTimeslot.label}` : ""} + + {typeof currentTimeslot.pickupInstructionProfile === "object" && + currentTimeslot.pickupInstructionProfile && ( + + 📍 {currentTimeslot.pickupInstructionProfile.name} + {currentTimeslot.pickupInstructionProfile.shortSummary && ( + + {" "} + — {currentTimeslot.pickupInstructionProfile.shortSummary} + + )} + + )} + + )} + {submitError && ( @@ -328,9 +375,9 @@ export function TimeslotSelector({ onClick={handleSubmit} isDisabled={!selectedId || submitting} isLoading={submitting} - loadingText="Confirming..." + loadingText={isChanging ? "Updating..." : "Confirming..."} > - Confirm Timeslot + {isChanging ? "Update Timeslot" : "Confirm Timeslot"}