2021-08-26 11:50:47 +05:30
|
|
|
import { Layout } from 'antd';
|
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-10-22 17:05:10 +05:30
|
|
|
import React, { ReactNode, useEffect, useState } 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;
|
|
|
|
|
|
2021-10-22 17:05:10 +05:30
|
|
|
const AppLayout: React.FC<AppLayoutProps> = ({ children }) => {
|
2021-10-11 16:21:15 +05:30
|
|
|
const { isLoggedIn } = useSelector<AppState, AppReducer>((state) => state.app);
|
2021-05-23 14:15:13 +05:30
|
|
|
|
2021-10-22 17:05:10 +05:30
|
|
|
const [isSignUpPage, setIsSignUpPage] = useState(
|
|
|
|
|
ROUTES.SIGN_UP === location.pathname,
|
|
|
|
|
);
|
2021-05-23 14:15:13 +05:30
|
|
|
|
2021-10-22 17:05:10 +05:30
|
|
|
useEffect(() => {
|
|
|
|
|
if (!isLoggedIn) {
|
|
|
|
|
setIsSignUpPage(true);
|
|
|
|
|
history.push(ROUTES.SIGN_UP);
|
2021-10-11 16:21:15 +05:30
|
|
|
} else {
|
2021-10-22 17:05:10 +05:30
|
|
|
if (isSignUpPage) {
|
|
|
|
|
setIsSignUpPage(false);
|
2021-10-20 09:24:55 +05:30
|
|
|
}
|
2021-10-11 16:21:15 +05:30
|
|
|
}
|
2021-10-22 17:05:10 +05:30
|
|
|
}, [isLoggedIn, isSignUpPage]);
|
2021-10-20 09:24:55 +05:30
|
|
|
|
|
|
|
|
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-10-22 17:05:10 +05:30
|
|
|
{!isSignUpPage && <SideNav />}
|
2021-05-16 18:35:50 +05:30
|
|
|
<Layout className="site-layout">
|
2021-08-26 11:50:47 +05:30
|
|
|
<Content style={{ margin: '0 16px' }}>
|
2021-10-22 17:05:10 +05:30
|
|
|
{!isSignUpPage && <TopNav />}
|
2021-05-16 18:35:50 +05:30
|
|
|
{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>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-22 17:05:10 +05:30
|
|
|
interface AppLayoutProps {
|
|
|
|
|
children: ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AppLayout;
|