@kiwicom/smart-faq
Version:
Smart FAQ
100 lines (95 loc) • 3.21 kB
JavaScript
// @flow
import * as React from 'react';
import { ThemeProvider } from 'styled-components';
import { Provider as ModalProvider } from '@kiwicom/nitro/lib/services/modal/context';
import ModalValue from '@kiwicom/nitro/lib/components/Value';
import InitCurrency from '@kiwicom/nitro/lib/components/InitCurrency';
import { Provider as CurrencyProvider } from '@kiwicom/nitro/lib/services/currency/context';
import { Provider as FetchedProvider } from '@kiwicom/nitro/lib/services/fetched/context';
import InitIntl from '@kiwicom/nitro/lib/components/InitIntl';
import { Provider as IntlProvider } from '@kiwicom/nitro/lib/services/intl/context';
import { Provider as BrandProvider } from '@kiwicom/nitro/lib/services/brand/context';
import PageVariantContext from '../../SmartFAQ/context/PageVariant';
import IsomorphicRouter from './IsomorphicRouter';
import { UserContext } from '../../SmartFAQ/context/User';
type Props = {
children: React.Node,
location: string,
lng: string,
userContext: Object,
theme: Object,
currencyId: string,
language: Object,
countries: Object,
brand: Object,
fetched: Object,
intl: Object,
screenWidth: number,
};
const Contexts = ({
children,
lng,
location,
userContext,
theme,
currencyId,
language,
countries,
brand,
fetched,
intl,
screenWidth,
}: Props) => (
<BrandProvider value={brand}>
<InitIntl raw={intl}>
{intl => (
<IntlProvider value={intl}>
<FetchedProvider value={fetched}>
<InitCurrency
brand={brand}
countries={countries}
affiliate=""
ip="1.3.3.7"
initialCurrency="EUR"
langCurrency={language.currency}
onChange={() => undefined}
>
{currency => (
<CurrencyProvider
value={{
...currency,
currency:
currency.available[currencyId] || currency.currency,
}}
>
<ModalValue>
{modal => (
<ModalProvider value={modal}>
<ThemeProvider theme={theme}>
<UserContext.Provider value={userContext}>
<IsomorphicRouter
basename={`/${lng}`}
location={location}
context={{}}
>
<PageVariantContext.Provider
value={{ variant: 'fullPage', screenWidth }}
>
{children}
</PageVariantContext.Provider>
</IsomorphicRouter>
</UserContext.Provider>
</ThemeProvider>
</ModalProvider>
)}
</ModalValue>
</CurrencyProvider>
)}
</InitCurrency>
</FetchedProvider>
</IntlProvider>
)}
</InitIntl>
</BrandProvider>
);
export default Contexts;