Skip to content

Commit

Permalink
Labels back to emoji, have checkbox select all of an entire variant a…
Browse files Browse the repository at this point in the history
…t a time

If we want granularity in the future then that can be added later
  • Loading branch information
SheepTester committed Aug 19, 2024
1 parent 3f71919 commit a664aea
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 26 deletions.
55 changes: 31 additions & 24 deletions src/components/admin/store/PickupOrder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,41 @@ const PickupOrder = ({ token, canFulfill, order, onOrderUpdate }: PickupOrderPro
order.status === OrderStatus.PARTIALLY_FULFILLED
) {
if (!item.fulfilled) {
badge = <span className={styles.notFulfilled}>Not fulfilled</span>;
badge = (
<span className={styles.notFulfilled} title="Not fulfilled">
</span>
);
}
} else if (item.fulfilled) {
badge = <span className={styles.fulfilled}>Fulfilled</span>;
badge = (
<span className={styles.fulfilled} title="Fulfilled">
</span>
);
}
return (
<li key={item.uuids[0]}>
<Typography variant="h5/regular">
{`${item.quantity} x ${itemToString(item)}`} {badge}
</Typography>
{canFulfill && !item.fulfilled
? item.uuids.map(uuid => (
<input
key={uuid}
type="checkbox"
checked={selected.has(uuid)}
onChange={e => {
const copy = new Set(selected);
if (e.currentTarget.checked) {
copy.add(uuid);
} else {
copy.delete(uuid);
}
setSelected(copy);
}}
/>
))
: null}
<label>
{canFulfill && !item.fulfilled ? (
<input
type="checkbox"
defaultChecked={false}
onChange={e => {
setSelected(
new Set(
e.currentTarget.checked
? [...Array.from(selected), ...item.uuids]
: Array.from(selected).filter(uuid => !item.uuids.includes(uuid))
)
);
}}
/>
) : null}
<Typography variant="h5/regular" component="span">
{`${item.quantity} x ${itemToString(item)}`} {badge}
</Typography>
</label>
</li>
);
})}
Expand All @@ -85,7 +92,7 @@ const PickupOrder = ({ token, canFulfill, order, onOrderUpdate }: PickupOrderPro
}
}}
>
Fulfill Selected
Fulfill {selected.size} item{selected.size === 1 ? '' : 's'}
</Button>
) : null}
</td>
Expand Down
1 change: 1 addition & 0 deletions src/components/admin/store/PickupOrder/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
[type='checkbox'] {
cursor: pointer;
height: 1rem;
margin-right: 5px;
width: 1rem;
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/components/store/OrderSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ const OrderItemPreview = ({ item, showFulfilled, showNotFulfilled }: OrderItemPr
fill
/>
{showFulfilled && item.fulfilled ? (
// "Already picked up" means that the item could only have been picked
// up from a previous partially fulfilled order that was rescheduled.
// For example, if an item is fulfilled but the order is missed or
// cancelled
<div className={styles.badge}>{showNotFulfilled ? 'Picked up' : 'Already picked up'}</div>
) : null}
{showNotFulfilled && !item.fulfilled ? (
<div className={`${styles.badge} ${styles.notAvailable}`}>Not available</div>
// Only shows for partially fulfilled orders when the item wasn't
// available at the pickup event (e.g. hoodies haven't arrived yet)
<div className={`${styles.badge} ${styles.notAvailable}`}>Not picked up</div>
) : null}
</div>
<div className={styles.itemSummary}>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export const getOrderItemQuantities = (items: PublicOrderItem[]): OrderItemQuant
return Array.from(itemMap.values()).sort(
(a, b) =>
// Group unfulfilled items first
+b.fulfilled - +a.fulfilled ||
+a.fulfilled - +b.fulfilled ||
// Alphabetize by item name
a.option.item.itemName.localeCompare(b.option.item.itemName) ||
// then by option name
Expand Down

0 comments on commit a664aea

Please sign in to comment.