forked from dalyathan/vendure-nextjs-storefront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_app.page.tsx
70 lines (65 loc) · 3.36 KB
/
_app.page.tsx
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import '../styles/global.css';
import 'keen-slider/keen-slider.min.css';
import { AppProps } from 'next/app';
import { appWithTranslation } from 'next-i18next';
import { Nunito_Sans } from 'next/font/google';
import { Global, ThemeProvider } from '@emotion/react';
import { LightTheme } from '@/src/theme';
import { CartProvider } from '@/src/state/cart';
import { CheckoutProvider } from '@/src/state/checkout';
import { ProductProvider } from '@/src/state/product';
import { CollectionProvider } from '@/src/state/collection';
import { ChannelsProvider } from '../state/channels';
import { PrivyProvider } from '@privy-io/react-auth';
const nunito = Nunito_Sans({ subsets: ['latin'], variable: '--nunito-font' });
const App = ({ Component, pageProps }: AppProps) => {
return (
<ThemeProvider theme={LightTheme}>
<PrivyProvider
appId="cm3rjo8me045jsl0sl1wc3gjx"
config={{
appearance: {
theme: 'light',
accentColor: '#676FFF',
},
embeddedWallets: {
createOnLogin: 'users-without-wallets',
},
}}
>
<ChannelsProvider initialState={{ channel: pageProps.channel, locale: pageProps.locale }}>
<Global styles={`body { font-family:${nunito.style.fontFamily}; }`} />
{/* `checkout` prop should exist only on routes with checkout functionally */}
{'checkout' in pageProps ? (
<CheckoutProvider initialState={{ checkout: pageProps.checkout }}>
<Component {...pageProps} />
</CheckoutProvider>
) : (
<CartProvider>
<ProductProvider
initialState={{
product: 'product' in pageProps ? pageProps.product : undefined,
}}>
<CollectionProvider
initialState={{
collection: 'collection' in pageProps ? pageProps.collection : undefined,
products: 'products' in pageProps ? pageProps.products : undefined,
facets: 'facets' in pageProps ? pageProps.facets : undefined,
totalProducts: 'totalProducts' in pageProps ? pageProps.totalProducts : undefined,
filters: 'filters' in pageProps ? pageProps.filters : undefined,
searchQuery: 'searchQuery' in pageProps ? pageProps.searchQuery : undefined,
page: 'page' in pageProps ? pageProps.page : undefined,
sort: 'sort' in pageProps ? pageProps.sort : undefined,
}}>
<Component {...pageProps} />
</CollectionProvider>
</ProductProvider>
</CartProvider>
)}
</ChannelsProvider>
</PrivyProvider>
</ThemeProvider>
);
};
export default appWithTranslation(App);