2018-10-23 14:18:46 +01:00
|
|
|
import React from 'react';
|
2018-08-23 16:29:26 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
|
|
|
import { createStore } from './src/redux/createStore';
|
2018-08-30 15:27:53 +01:00
|
|
|
import AppMountNotifier from './src/components/AppMountNotifier';
|
2019-02-20 15:41:33 +03:00
|
|
|
|
2019-02-22 20:36:47 +05:30
|
|
|
import {
|
|
|
|
CertificationLayout,
|
|
|
|
DefaultLayout,
|
|
|
|
GuideLayout
|
|
|
|
} from './src/components/layouts';
|
2018-08-23 16:29:26 +01:00
|
|
|
|
|
|
|
const store = createStore();
|
|
|
|
|
|
|
|
export const wrapRootElement = ({ element }) => {
|
2018-08-30 15:27:53 +01:00
|
|
|
return (
|
|
|
|
<Provider store={store}>
|
2019-02-20 15:41:33 +03:00
|
|
|
<AppMountNotifier render={() => element} />
|
2018-08-30 15:27:53 +01:00
|
|
|
</Provider>
|
|
|
|
);
|
2018-08-23 16:29:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
wrapRootElement.propTypes = {
|
|
|
|
element: PropTypes.any
|
|
|
|
};
|
2019-01-23 00:53:35 +03:00
|
|
|
|
|
|
|
export const wrapPageElement = ({ element, props }) => {
|
|
|
|
const {
|
|
|
|
location: { pathname }
|
|
|
|
} = props;
|
|
|
|
if (pathname === '/') {
|
|
|
|
return (
|
2019-02-17 14:47:20 +03:00
|
|
|
<DefaultLayout disableSettings={true} landingPage={true}>
|
2019-01-23 00:53:35 +03:00
|
|
|
{element}
|
|
|
|
</DefaultLayout>
|
|
|
|
);
|
|
|
|
}
|
2019-02-22 20:36:47 +05:30
|
|
|
if (/^\/certification(\/.*)*/.test(pathname)) {
|
|
|
|
return <CertificationLayout>{element}</CertificationLayout>;
|
|
|
|
}
|
2019-02-19 01:59:12 +03:00
|
|
|
if (/^\/guide(\/.*)*/.test(pathname)) {
|
2019-01-23 02:02:31 +03:00
|
|
|
return (
|
2019-02-21 14:07:01 +03:00
|
|
|
<DefaultLayout onGuide={true}>
|
2019-01-23 02:02:31 +03:00
|
|
|
<GuideLayout>{element}</GuideLayout>
|
|
|
|
</DefaultLayout>
|
|
|
|
);
|
|
|
|
}
|
2019-02-19 01:59:12 +03:00
|
|
|
if (/^\/learn(\/.*)*/.test(pathname)) {
|
2019-02-17 14:47:20 +03:00
|
|
|
return <DefaultLayout showFooter={false}>{element}</DefaultLayout>;
|
2019-02-17 16:26:10 +05:30
|
|
|
}
|
2019-01-23 00:53:35 +03:00
|
|
|
return <DefaultLayout>{element}</DefaultLayout>;
|
|
|
|
};
|
|
|
|
|
|
|
|
wrapPageElement.propTypes = {
|
|
|
|
element: PropTypes.any,
|
|
|
|
location: PropTypes.objectOf({ pathname: PropTypes.string }),
|
|
|
|
props: PropTypes.any
|
|
|
|
};
|