mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-01-29 17:48:28 +00:00
Fix some errors after cart refactor
This commit is contained in:
parent
7066cc492b
commit
7f7fa3b3ab
|
@ -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][] {
|
||||
|
|
|
@ -12,15 +12,17 @@
|
|||
|
||||
let items: [string, CartItem][];
|
||||
let totalPrice: number;
|
||||
let totalItems: number;
|
||||
|
||||
Cart.subscribe(() => {
|
||||
items = Cart.getEntries();
|
||||
totalPrice = Cart.getTotalPrice();
|
||||
totalItems = Cart.getUniqueLength();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{#if items.entries}
|
||||
{#if totalItems}
|
||||
<h1>Cart</h1>
|
||||
|
||||
<button id="checkout-button">Checkout</button>
|
||||
|
|
Loading…
Reference in a new issue