Skip to content

Commit 95cea9a

Browse files
committed
fix: fix shopping priority
1 parent 68515c1 commit 95cea9a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/components/shopping/ShoppingComponent.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ function ShoppingComponent({ hideButtons }) {
3939
}
4040

4141
const data = await response.json();
42-
setItems(data.cart.cart_items || []);
42+
const sortedItems = (data.cart.cart_items || []).sort(
43+
(a, b) => a.priority - b.priority
44+
);
45+
setItems(sortedItems);
4346
setBudget(data.cart.budget);
4447
setPresent(data.cart.total_price);
4548
console.log(data);

src/components/shopping/ShoppingList.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function ShoppingList({ items, setItems, isLoading, hideButtons }) {
4444
body: JSON.stringify({
4545
items: items.map((item, index) => ({
4646
...item,
47-
priority: index,
47+
priority: index + 1,
4848
})),
4949
}),
5050
}

0 commit comments

Comments
 (0)