diff --git a/pages/_app.tsx b/pages/_app.tsx index c7bbb1f..8d054bf 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -6,6 +6,7 @@ import 'assets/global.scss' import 'assets/variables.scss' import axios from 'axios' import {authConfig} from 'components/with.auth' +import 'i18n' import {AppProps} from 'next/app' import getConfig from 'next/config' import Head from 'next/head' @@ -34,11 +35,4 @@ const App: React.FC = ({ Component, pageProps }) => { ) } -const WrappedApp = wrapper.withRedux(App) - -WrappedApp.getInitialProps = async (): Promise => { - // important for now to pass public runtime config to clients! - return {} -} - -export default WrappedApp +export default wrapper.withRedux(App) diff --git a/pages/index.tsx b/pages/index.tsx index 9240497..95905b3 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,9 +1,38 @@ import {Layout} from 'antd' import {AuthFooter} from 'components/auth/footer' import {NextPage} from 'next' -import React from 'react' +import {useRouter} from 'next/router' +import React, {useEffect} from 'react' +import {LoadingPage} from '../components/loading.page' const Index: NextPage = () => { + const router = useRouter() + + useEffect(() => { + if (router.pathname !== window.location.pathname) { + let href = router.asPath + let as = router.asPath; + + [ + /(\/form\/)[^\/]+/i, + /(\/admin\/forms\/)[^\/]+/i, + /(\/admin\/users\/)[^\/]+/i, + ].forEach(r => { + if (r.test(as)) { + href = href.replace(r, '$1[id]') + } + }) + + router.replace(href, as) + } + }) + + if (process.browser && router.pathname !== window.location.pathname) { + return ( + + ) + } + return (