frontend/src/components/App.tsx
2021-01-05 23:46:51 +01:00

47 lines
1.3 KiB
TypeScript

import React, { useContext, useState } from 'react';
import Topbar from './Topbar';
import { Transfer } from './Transfer';
import { Admin } from './Admin';
import { Scheduler } from './Scheduler';
import { Rightbar } from './Rightbar';
import styled from 'styled-components';
import LoadingOverlay from 'react-loading-overlay';
import { SyncLoader } from 'react-spinners';
import { CASContext } from '../contexts/CASProvider';
const Wrapper = styled.div`
display: flex;
height: calc(100vh - 80px);
background-color: #eceef4;
padding-top: 20px;
padding-bottom: 20px;
padding-right: 20px;
`;
export const App = () => {
const { role } = useContext(CASContext)!;
const [isOpenTransfer, setOpenTransfer] = useState(false);
const handleTransfer = () => {
setOpenTransfer(!isOpenTransfer);
};
const userPrivilige = localStorage.getItem('userPrivilige');
return (
<>
<LoadingOverlay active={role === undefined} spinner={<SyncLoader />}>
<Topbar handleTransfer={handleTransfer} />
<Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} />
<Wrapper>
{userPrivilige === 'STUDENT' && (
<>
<Scheduler />
<Rightbar />
</>
)}
{userPrivilige === 'DEANERY' && <Admin />}
</Wrapper>
</LoadingOverlay>
</>
);
};