MainContainer.tsx
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { useState, useEffect } from 'react';
import { RouteComponentProps} from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import * as recoilUtil from '../../util/recoilUtil';
import Header from '../../components/Header';
import Footer from '../../components/Footer';
import DoctorMenuContainer from './doctor';
import ManagerMenuContainer from './manager';
type MainProps = RouteComponentProps
const MainContainer = (props : MainProps) => {
const token = useRecoilValue(recoilUtil.token);
const userTypeCd = useRecoilValue(recoilUtil.userTypeCd);
useEffect(() => {
if(!token || !token.length) {
props.history.push('/login');
}
}, []);
return (
<>
<Header {...props}/>
{
userTypeCd === 'DOCTOR' ?
<DoctorMenuContainer {...props}/> :
userTypeCd === 'MANAGER' ?
<ManagerMenuContainer {...props}/> : null
}
<Footer/>
</>
);
};
export default MainContainer;