From 6d4224abea1a6b627c532c9b11d8f338df076842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Wed, 22 Jun 2022 23:20:52 +0200 Subject: [PATCH] Use global value to check for current Shop product Also add other stores types to hint on expected values --- .../molecules/ShopLocationSwitcher.svelte | 4 ++-- src/components/organisms/ShopHeader.svelte | 2 +- src/routes/shop/index.svelte | 4 ++++ src/utils/stores/shop.ts | 21 ++++++++++++------- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/components/molecules/ShopLocationSwitcher.svelte b/src/components/molecules/ShopLocationSwitcher.svelte index ee27cdf..e56acbd 100644 --- a/src/components/molecules/ShopLocationSwitcher.svelte +++ b/src/components/molecules/ShopLocationSwitcher.svelte @@ -1,9 +1,9 @@ = writable(null) /** * Cart */ /** Cart open state */ -export const cartOpen = writable(false) +export const cartOpen: Writable = writable(false) /** Cart open state */ -export const cartId = writable(null) +export const cartId: Writable = writable(null) // Write to localStorage when changing cartId if (typeof localStorage !== 'undefined') { @@ -20,17 +26,18 @@ if (typeof localStorage !== 'undefined') { } /** Raw Cart data */ -export const cartData = writable(null) +export const cartData: Writable = writable(null) /** Cart data is being updated */ -export const cartIsUpdating = writable(false) +export const cartIsUpdating: Writable = writable(false) /** Amount of products present in cart */ -export const cartAmount = derived(cartData, ($cart) => { +export const cartAmount: Readable = derived(cartData, ($cart) => { return $cart && $cart.item_quantity > 0 ? $cart.item_quantity : 0 }) + /** * Notifications */ -export const cartNotifications = writable([]) \ No newline at end of file +export const cartNotifications: Writable = writable([]) \ No newline at end of file