4
0
forked from crowetic/commerce

UI Provider

This commit is contained in:
Belen Curcio 2020-10-15 18:05:13 -03:00
parent 5e4d2c2f8f
commit d3d45e1b2a
2 changed files with 8 additions and 10 deletions

View File

@ -18,7 +18,7 @@ export default function useCart<T>(
fetcherFn: HookFetcher<T | null, CartInput>, fetcherFn: HookFetcher<T | null, CartInput>,
swrOptions?: ConfigInterface<T | null> swrOptions?: ConfigInterface<T | null>
) { ) {
const { cartCookie = '' } = useCommerce() | {} const { cartCookie } = useCommerce()
const fetcher: typeof fetcherFn = (options, input, fetch) => { const fetcher: typeof fetcherFn = (options, input, fetch) => {
input.cartId = Cookies.get(cartCookie) input.cartId = Cookies.get(cartCookie)
return fetcherFn(options, input, fetch) return fetcherFn(options, input, fetch)

View File

@ -14,15 +14,13 @@ export default function MyApp({ Component, pageProps }: AppProps) {
const Layout = (Component as any).Layout || Noop const Layout = (Component as any).Layout || Noop
return ( return (
<> <CommerceProvider locale="en-us">
<Head /> <Head />
<CommerceProvider locale="en-us"> <ManagedUIContext>
<ManagedUIContext> <Layout>
<Layout> <Component {...pageProps} />
<Component {...pageProps} /> </Layout>
</Layout> </ManagedUIContext>
</ManagedUIContext> </CommerceProvider>
</CommerceProvider>
</>
) )
} }