Advertisement
ahmadandika

Untitled

Oct 9th, 2020
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* eslint-disable react/react-in-jsx-scope */
  2. import '../src/assets/styles/fontawesome.min.css';
  3. import '../src/assets/styles/main.scss';
  4. import '../src/assets/styles/animate.min.css';
  5. import '../src/assets/styles/nprogress.css';
  6. import '../src/assets/styles/demo/demo.css';
  7. import '../src/assets/styles/demo/nucleo-icons-page-styles.css';
  8. import 'react-toastify/dist/ReactToastify.css';
  9. import '../src/assets/styles/pages/home.scss';
  10.  
  11. import { Provider } from 'react-redux';
  12. import App from 'next/app';
  13. import withRedux from 'next-redux-wrapper';
  14. import { DefaultSeo } from 'next-seo';
  15. import Router from 'next/router';
  16. import NProgress from 'nprogress';
  17. import { initStore } from '@reducers/store';
  18. import { appWithTranslation } from '@helpers/i18n';
  19. import { initGA, logPageView } from '@helpers/analytics';
  20.  
  21. NProgress.configure({ showSpinner: true });
  22.  
  23. Router.onRouteChangeStart = () => {
  24.   NProgress.start();
  25. };
  26.  
  27. Router.onRouteChangeComplete = () => {
  28.   if (process.browser) {
  29.     logPageView();
  30.   }
  31.   NProgress.done();
  32. };
  33.  
  34. Router.onRouteChangeError = () => {
  35.   NProgress.done();
  36. };
  37.  
  38. class MyApp extends App {
  39.   static async getInitialProps({ Component, ctx }) {
  40.     const { originalUrl } = ctx.req || {};
  41.     return {
  42.       pageProps: Component.getInitialProps
  43.         ? await Component.getInitialProps(ctx)
  44.         : {},
  45.       originalUrl
  46.     };
  47.   }
  48.  
  49.   constructor(props) {
  50.     super(props);
  51.     if (process.browser) {
  52.       if (!process.env.NODE_ENV || process.env.NODE_ENV === 'development') {
  53.         // for dev
  54.         // without google analytic
  55.       } else {
  56.         // for prod
  57.         // with google analytic
  58.         if (!window.GA_INITIALIZED) {
  59.           initGA();
  60.           window.GA_INITIALIZED = true;
  61.         }
  62.         logPageView();
  63.       }
  64.     }
  65.   }
  66.  
  67.   render() {
  68.     const { Component, pageProps, store } = this.props;
  69.     return (
  70.       <>
  71.         <DefaultSeo
  72.           title="Kaptiva"
  73.           description="kaptiva"
  74.           openGraph={{
  75.             type: 'website',
  76.             locale: 'en_IE',
  77.             url: '',
  78.             site_name: ''
  79.           }}
  80.         />
  81.         <Provider store={store}>
  82.           <Component {...pageProps} />
  83.         </Provider>
  84.       </>
  85.     );
  86.   }
  87. }
  88.  
  89. export default withRedux(initStore)(appWithTranslation(MyApp));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement