From d26e37019d0d8102770449e55a168682f6b07c6d Mon Sep 17 00:00:00 2001 From: Andrew Smithwick Date: Fri, 26 Apr 2024 23:48:31 -0700 Subject: [PATCH] Added Reschedule missing or cancelled pickup (#238) * Added Reschedule missing or cancelled pickup Sorted events by status Allow you to reschedule pickup events (and tag properly updates without refresh) Difference between Pickup Cancelled and Cancelled * Removed unused console.log statement --- src/components/store/OrderCard/index.tsx | 7 +++++-- src/components/store/OrderSummary/index.tsx | 6 +++++- .../store/PickupEventDetail/index.tsx | 2 +- .../store/PickupEventPicker/index.tsx | 20 ++++++++++--------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/components/store/OrderCard/index.tsx b/src/components/store/OrderCard/index.tsx index 18d5013c..12807be6 100644 --- a/src/components/store/OrderCard/index.tsx +++ b/src/components/store/OrderCard/index.tsx @@ -46,6 +46,7 @@ const OrderCard = ({ order, futurePickupEvents }: OrderCardProps) => { const [pickupEvent, setPickupEvent] = useState(order.pickupEvent); const [orderStatus, setOrderStatus] = useState(order.status); const orderOpen = open && orderData !== null; + const [statusName, setStatusName] = useState(orderStatusName[orderStatus]); useEffect(() => { if (open && orderData === null) { @@ -57,8 +58,10 @@ const OrderCard = ({ order, futurePickupEvents }: OrderCardProps) => { reportError('Error loading order!', e); setOrderData(null); }); + } else if (open) { + setStatusName(orderStatusName[orderStatus]); } - }, [open, order.uuid, orderData]); + }, [open, order.uuid, orderData, pickupEvent, orderStatus]); const cancelOrder = async () => { await StoreManager.cancelMerchOrder(order.uuid); @@ -68,10 +71,10 @@ const OrderCard = ({ order, futurePickupEvents }: OrderCardProps) => { const rescheduleOrderPickup = async (pickup: PublicOrderPickupEvent) => { await StoreManager.rescheduleOrderPickup(order.uuid, pickup.uuid); setPickupEvent(pickup); + setOrderStatus(OrderStatus.PLACED); }; const statusColor = orderStatusColor[orderStatus]; - const statusName = orderStatusName[orderStatus]; return (
diff --git a/src/components/store/OrderSummary/index.tsx b/src/components/store/OrderSummary/index.tsx index d0db8e75..f8d9810c 100644 --- a/src/components/store/OrderSummary/index.tsx +++ b/src/components/store/OrderSummary/index.tsx @@ -30,7 +30,11 @@ const isOrderActionable = (status: OrderStatus, pickupEvent: PublicOrderPickupEv const now = new Date(); const eventStart = new Date(pickupEvent.start); eventStart.setDate(eventStart.getDate() - 2); - if (now > eventStart) { + if ( + now > eventStart && + status !== OrderStatus.PICKUP_MISSED && + status !== OrderStatus.PICKUP_CANCELLED + ) { return false; } return true; diff --git a/src/components/store/PickupEventDetail/index.tsx b/src/components/store/PickupEventDetail/index.tsx index 6881fc20..75202243 100644 --- a/src/components/store/PickupEventDetail/index.tsx +++ b/src/components/store/PickupEventDetail/index.tsx @@ -29,7 +29,7 @@ const PickupEventDetail = ({ pickupEvent }: PickupEventDetailProps) => { {title} - {formatEventDate(start, end)} + {formatEventDate(start, end, true)} {hasLinkedEvent ? ( {linkedEvent?.location} diff --git a/src/components/store/PickupEventPicker/index.tsx b/src/components/store/PickupEventPicker/index.tsx index 461d4a64..1fd8bc12 100644 --- a/src/components/store/PickupEventPicker/index.tsx +++ b/src/components/store/PickupEventPicker/index.tsx @@ -23,15 +23,17 @@ const PickupEventPicker = ({ events, eventIndex, setEventIndex, active }: EventP className={styles.slider} style={{ transform: `translateX(calc(-1 * var(--width) * ${eventIndex}))` }} > - {events.map(event => ( - - ))} + {events + .sort((a, b) => new Date(a.start).getTime() - new Date(b.start).getTime()) + .map(event => ( + + ))}
) : (