import { Layout } from 'antd'; import SideNav from 'components/SideNav'; import ROUTES from 'constants/routes'; import history from 'lib/history'; import React, { ReactNode, useEffect } from 'react'; import { useSelector } from 'react-redux'; import { useLocation } from 'react-router-dom'; import { AppState } from 'store/reducers'; import AppReducer from 'types/reducer/app'; import TopNav from './Nav/TopNav'; import { useRoute } from './RouteProvider'; const { Content, Footer } = Layout; interface BaseLayoutProps { children: ReactNode; } const BaseLayout: React.FC = ({ children }) => { const location = useLocation(); const { dispatch } = useRoute(); const currentYear = new Date().getFullYear(); const { isLoggedIn } = useSelector((state) => state.app); useEffect(() => { dispatch({ type: 'ROUTE_IS_LOADED', payload: location.pathname }); }, [location, dispatch]); useEffect(() => { if (isLoggedIn) { history.push(ROUTES.APPLICATION); } else { history.push(ROUTES.SIGN_UP); } }, [isLoggedIn]); return ( {children} ); }; export default BaseLayout;