diff --git a/packages/docs/.storybook/preview.tsx b/packages/docs/.storybook/preview.tsx index 2b524f5c..b3cd2f12 100644 --- a/packages/docs/.storybook/preview.tsx +++ b/packages/docs/.storybook/preview.tsx @@ -23,7 +23,16 @@ const parameters: Parameters = { }, options: { storySort: { - order: ['Getting Started', 'Components', ['Prices', ['PricesContainer']]] + order: [ + 'Getting Started', + 'Components', + [ + 'Prices', + ['PricesContainer', '*'], + 'Skus', + ['AvailabilityContainer', '*'] + ] + ] } }, docs: { diff --git a/packages/docs/stories/_internals/useGetToken.ts b/packages/docs/stories/_internals/useGetToken.ts index 0e7fc9bd..4eb2c4b5 100644 --- a/packages/docs/stories/_internals/useGetToken.ts +++ b/packages/docs/stories/_internals/useGetToken.ts @@ -9,10 +9,10 @@ interface UseGetTokenOptions { } const salesChannel = { - clientId: '48ee4802f8227b04951645a9b7c8af1e3943efec7edd1dcfd04b5661bf1da5db', - slug: 'the-blue-brand-3', - scope: 'market:58', - domain: 'commercelayer.co' + clientId: 'Z5ypiDlsqgV8twWRz0GabrJvTKXad4U-PMoVAU-XvV0', + slug: 'react-components-store', + scope: 'market:15283', + domain: 'commercelayer.io' } const customer = { @@ -37,7 +37,7 @@ export function useGetToken( const scope = salesChannel.scope const domain = salesChannel.domain const user = - options?.userMode != null + options?.userMode === true ? { username: customer.username, password: customer.password @@ -65,6 +65,7 @@ export function useGetToken( accessToken === '' || isTokenExpired({ accessToken, compareTo: new Date() }) ) { + console.log('initToken') void initToken() } }, [accessToken]) @@ -115,12 +116,16 @@ function isTokenExpired({ return true } - const { exp } = jwtDecode<{ exp: number }>(accessToken) + try { + const { exp } = jwtDecode<{ exp: number }>(accessToken) - if (exp == null) { + if (exp == null) { + return true + } + + const nowTime = Math.trunc(compareTo.getTime() / 1000) + return nowTime > exp + } catch { return true } - - const nowTime = Math.trunc(compareTo.getTime() / 1000) - return nowTime > exp } diff --git a/packages/docs/stories/examples/cart/ShoppingCart.stories.tsx b/packages/docs/stories/examples/cart/ShoppingCart.stories.tsx index f3c4d97c..599df97f 100644 --- a/packages/docs/stories/examples/cart/ShoppingCart.stories.tsx +++ b/packages/docs/stories/examples/cart/ShoppingCart.stories.tsx @@ -36,19 +36,24 @@ export const Default: StoryFn = (args) => { > -
+
Line items -

+

Items count:

-
+
- - - +
+ + +
+
diff --git a/packages/docs/stories/examples/cart/components.tsx b/packages/docs/stories/examples/cart/components.tsx index 330fe688..f4572ff4 100644 --- a/packages/docs/stories/examples/cart/components.tsx +++ b/packages/docs/stories/examples/cart/components.tsx @@ -51,11 +51,11 @@ export const AddSampleItems = (): JSX.Element => {