Skip to content

Commit

Permalink
Merge pull request #54 from JacobDChamberlain/keepShirtSizesSameOrder…
Browse files Browse the repository at this point in the history
…AfterPurchase

sort sized items by size for dropdown (fix issue: on purchase of size…
  • Loading branch information
JacobDChamberlain authored Jan 11, 2025
2 parents 3b9c7c3 + 3393632 commit 3fb38f8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/components/Pages/Merch/StoreItem/StoreItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ export default function StoreItem({ item, inventory }) {
}
};


// initially, on purchase, the purchased size would be set to the bottom of the dropdown.
// this fixes that.
const predefinedOrder = ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL']; // Define the desired order
const sortedSizes = Object.keys(availableSizes).sort(
(a, b) => predefinedOrder.indexOf(a) - predefinedOrder.indexOf(b)
);


return (
<div className="store-item-wrapper">
<img className="store-item-image" src={item.images[0]} alt={`${item.description}`} />
Expand All @@ -86,7 +95,7 @@ export default function StoreItem({ item, inventory }) {
className="size-select"
>
<option value="">🤘Select Size🤘</option>
{Object.keys(availableSizes).map((size) => (
{sortedSizes.map((size) => (
<option key={size} value={size} disabled={availableSizes[size] === 0}>
{size.toUpperCase()}
</option>
Expand Down

0 comments on commit 3fb38f8

Please sign in to comment.