2021-08-26 11:50:47 +05:30
|
|
|
import { Layout } from 'antd';
|
2021-10-20 09:24:55 +05:30
|
|
|
import get from 'api/browser/localstorage/get';
|
2021-10-11 16:21:15 +05:30
|
|
|
import ROUTES from 'constants/routes';
|
2021-10-20 09:24:55 +05:30
|
|
|
import TopNav from 'container/Header';
|
|
|
|
|
import SideNav from 'container/SideNav';
|
2021-10-11 16:21:15 +05:30
|
|
|
import history from 'lib/history';
|
2021-08-26 11:50:47 +05:30
|
|
|
import React, { ReactNode, useEffect } from 'react';
|
2021-10-11 16:21:15 +05:30
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
import { AppState } from 'store/reducers';
|
|
|
|
|
import AppReducer from 'types/reducer/app';
|
2021-05-16 18:35:50 +05:30
|
|
|
|
|
|
|
|
const { Content, Footer } = Layout;
|
|
|
|
|
interface BaseLayoutProps {
|
|
|
|
|
children: ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const BaseLayout: React.FC<BaseLayoutProps> = ({ children }) => {
|
2021-10-11 16:21:15 +05:30
|
|
|
const { isLoggedIn } = useSelector<AppState, AppReducer>((state) => state.app);
|
2021-10-20 09:24:55 +05:30
|
|
|
const isLoggedInLocalStorage = get('isLoggedIn');
|
2021-05-23 14:15:13 +05:30
|
|
|
|
|
|
|
|
useEffect(() => {
|
2021-10-20 09:24:55 +05:30
|
|
|
if (isLoggedIn && history.location.pathname === '/') {
|
|
|
|
|
history.push(ROUTES.APPLICATION);
|
|
|
|
|
}
|
2021-05-23 14:15:13 +05:30
|
|
|
|
2021-10-20 09:24:55 +05:30
|
|
|
if (!isLoggedIn && isLoggedInLocalStorage !== null) {
|
2021-10-11 16:21:15 +05:30
|
|
|
history.push(ROUTES.APPLICATION);
|
|
|
|
|
} else {
|
2021-10-20 09:24:55 +05:30
|
|
|
if (isLoggedInLocalStorage === null) {
|
|
|
|
|
history.push(ROUTES.SIGN_UP);
|
|
|
|
|
}
|
2021-10-11 16:21:15 +05:30
|
|
|
}
|
2021-10-20 09:24:55 +05:30
|
|
|
}, [isLoggedIn, isLoggedInLocalStorage]);
|
|
|
|
|
|
|
|
|
|
const currentYear = new Date().getFullYear();
|
2021-10-11 16:21:15 +05:30
|
|
|
|
2021-05-16 18:35:50 +05:30
|
|
|
return (
|
2021-08-26 11:50:47 +05:30
|
|
|
<Layout style={{ minHeight: '100vh' }}>
|
2021-05-16 18:35:50 +05:30
|
|
|
<SideNav />
|
|
|
|
|
<Layout className="site-layout">
|
2021-08-26 11:50:47 +05:30
|
|
|
<Content style={{ margin: '0 16px' }}>
|
2021-05-16 18:35:50 +05:30
|
|
|
<TopNav />
|
|
|
|
|
{children}
|
|
|
|
|
</Content>
|
2021-08-26 11:50:47 +05:30
|
|
|
<Footer style={{ textAlign: 'center', fontSize: 10 }}>
|
2021-09-06 22:04:43 +05:30
|
|
|
SigNoz Inc. ©{currentYear}
|
2021-05-16 18:35:50 +05:30
|
|
|
</Footer>
|
|
|
|
|
</Layout>
|
|
|
|
|
</Layout>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default BaseLayout;
|