generated from vtex-sites/base.store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-ssr.js
33 lines (30 loc) · 1.12 KB
/
gatsby-ssr.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* eslint-disable react/jsx-filename-extension */
import { CartProvider, SessionProvider, UIProvider } from '@faststore/sdk'
import React from 'react'
import Layout from './src/Layout'
import AnalyticsHandler from './src/sdk/analytics'
import { validateCart } from './src/sdk/cart/validate'
import ErrorBoundary from './src/sdk/error/ErrorBoundary'
import TestProvider from './src/sdk/tests'
import { uiActions, uiEffects, uiInitialState } from './src/sdk/ui'
import storeConfig from './store.config'
export const wrapRootElement = ({ element }) => (
<ErrorBoundary>
<AnalyticsHandler>
<TestProvider>
<UIProvider
initialState={uiInitialState}
actions={uiActions}
effects={uiEffects}
>
<SessionProvider initialState={{ channel: storeConfig.channel }}>
<CartProvider mode="optimistic" onValidateCart={validateCart}>
{element}
</CartProvider>
</SessionProvider>
</UIProvider>
</TestProvider>
</AnalyticsHandler>
</ErrorBoundary>
)
export const wrapPageElement = ({ element }) => <Layout>{element}</Layout>