@kiwicom/smart-faq
Version:
121 lines (114 loc) • 4.26 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 { getTokens } from '@kiwicom/orbit-design-tokens';
import { LanguageContext } from '../../SmartFAQ/context/Language';
import SearchStateProvider from '../../SmartFAQ/context/SearchState';
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,
screenWidthFallback: number,
};
const doNothing = () => {};
const Contexts = ({
children,
lng,
location,
userContext,
theme,
currencyId,
language,
countries,
brand,
fetched,
intl,
screenWidthFallback,
}: Props) => (
<BrandProvider value={brand}>
<InitIntl raw={intl}>
{intl => (
<IntlProvider value={intl}>
<LanguageContext.Provider value={language.id}>
<FetchedProvider value={fetched}>
<InitCurrency
brand={brand}
countries={countries}
affiliate=""
ip="1.3.3.7"
initialCurrency={currencyId}
langCurrency={language.currency}
onChange={doNothing}
>
{currency => (
<CurrencyProvider
value={{
...currency,
currency: currency.currency,
}}
>
<ModalValue>
{modal => (
<ModalProvider value={modal}>
<ThemeProvider
theme={{
...theme,
orbit: {
...getTokens(),
fontFamily:
"'Circular Pro', -apple-system, '.SFNSText-Regular', 'San Francisco', 'Segoe UI', 'Helvetica Neue', 'Lucida Grande', sans-serif",
},
}}
>
<UserContext.Provider value={userContext}>
<IsomorphicRouter
basename={`/${lng}`}
location={location}
context={{}}
>
<PageVariantContext.Provider
value={{
variant: 'fullPage',
screenWidthFallback,
}}
>
<SearchStateProvider>
{children}
</SearchStateProvider>
</PageVariantContext.Provider>
</IsomorphicRouter>
</UserContext.Provider>
</ThemeProvider>
</ModalProvider>
)}
</ModalValue>
</CurrencyProvider>
)}
</InitCurrency>
</FetchedProvider>
</LanguageContext.Provider>
</IntlProvider>
)}
</InitIntl>
</BrandProvider>
);
export default Contexts;