mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-06-05 18:03:14 +00:00
Fix some errors after cart refactor
This commit is contained in:
parent
7066cc492b
commit
7f7fa3b3ab
2 changed files with 10 additions and 1 deletions
|
@ -42,6 +42,13 @@ function createCartStore() {
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cart.update((cart: Record<string, CartItem>) => {
|
||||||
|
if (cart[uuid].amount <= 0) {
|
||||||
|
delete cart[uuid];
|
||||||
|
}
|
||||||
|
return cart;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEntries(): [string, CartItem][] {
|
function getEntries(): [string, CartItem][] {
|
||||||
|
|
|
@ -12,15 +12,17 @@
|
||||||
|
|
||||||
let items: [string, CartItem][];
|
let items: [string, CartItem][];
|
||||||
let totalPrice: number;
|
let totalPrice: number;
|
||||||
|
let totalItems: number;
|
||||||
|
|
||||||
Cart.subscribe(() => {
|
Cart.subscribe(() => {
|
||||||
items = Cart.getEntries();
|
items = Cart.getEntries();
|
||||||
totalPrice = Cart.getTotalPrice();
|
totalPrice = Cart.getTotalPrice();
|
||||||
|
totalItems = Cart.getUniqueLength();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{#if items.entries}
|
{#if totalItems}
|
||||||
<h1>Cart</h1>
|
<h1>Cart</h1>
|
||||||
|
|
||||||
<button id="checkout-button">Checkout</button>
|
<button id="checkout-button">Checkout</button>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue