Skip to content

Commit

Permalink
Added Reschedule missing or cancelled pickup (#238)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
WishingWell13 authored Apr 27, 2024
1 parent f1c9107 commit d26e370
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
7 changes: 5 additions & 2 deletions src/components/store/OrderCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const OrderCard = ({ order, futurePickupEvents }: OrderCardProps) => {
const [pickupEvent, setPickupEvent] = useState<PublicOrderPickupEvent>(order.pickupEvent);
const [orderStatus, setOrderStatus] = useState<OrderStatus>(order.status);
const orderOpen = open && orderData !== null;
const [statusName, setStatusName] = useState<string>(orderStatusName[orderStatus]);

useEffect(() => {
if (open && orderData === null) {
Expand All @@ -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);
Expand All @@ -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 (
<div className={styles.card}>
Expand Down
6 changes: 5 additions & 1 deletion src/components/store/OrderSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/components/store/PickupEventDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const PickupEventDetail = ({ pickupEvent }: PickupEventDetailProps) => {
{title}
</Typography>
<Typography variant="h2/regular" className={styles.title} suppressHydrationWarning>
{formatEventDate(start, end)}
{formatEventDate(start, end, true)}
</Typography>
{hasLinkedEvent ? (
<Typography variant="h3/regular">{linkedEvent?.location}</Typography>
Expand Down
20 changes: 11 additions & 9 deletions src/components/store/PickupEventPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 => (
<EventCard
key={event.uuid}
event={event}
attended={false}
borderless
showYear={false}
/>
))}
{events
.sort((a, b) => new Date(a.start).getTime() - new Date(b.start).getTime())
.map(event => (
<EventCard
key={event.uuid}
event={event}
attended={false}
borderless
showYear={false}
/>
))}
</div>
) : (
<div className={styles.noEvents}>
Expand Down

0 comments on commit d26e370

Please sign in to comment.