frontend/src/components/App.tsx

47 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-01-05 23:46:51 +01:00
import React, { useContext, useState } from 'react';
2020-08-20 18:14:28 +02:00
import Topbar from './Topbar';
import { Transfer } from './Transfer';
2020-11-29 23:42:36 +01:00
import { Admin } from './Admin';
import { Scheduler } from './Scheduler';
2020-08-17 23:56:34 +02:00
import { Rightbar } from './Rightbar';
import styled from 'styled-components';
2020-12-12 17:54:13 +01:00
import LoadingOverlay from 'react-loading-overlay';
import { SyncLoader } from 'react-spinners';
2021-01-05 21:05:16 +01:00
import { CASContext } from '../contexts/CASProvider';
const Wrapper = styled.div`
display: flex;
height: calc(100vh - 80px);
2020-11-22 18:22:07 +01:00
background-color: #eceef4;
padding-top: 20px;
padding-bottom: 20px;
2020-11-24 19:01:20 +01:00
padding-right: 20px;
`;
export const App = () => {
2021-01-05 23:46:51 +01:00
const { role } = useContext(CASContext)!;
const [isOpenTransfer, setOpenTransfer] = useState(false);
2021-01-05 21:05:16 +01:00
const handleTransfer = () => {
setOpenTransfer(!isOpenTransfer);
};
2020-12-12 17:54:13 +01:00
const userPrivilige = localStorage.getItem('userPrivilige');
return (
<>
2021-01-05 21:05:16 +01:00
<LoadingOverlay active={role === undefined} spinner={<SyncLoader />}>
2020-12-12 17:54:13 +01:00
<Topbar handleTransfer={handleTransfer} />
<Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} />
<Wrapper>
{userPrivilige === 'STUDENT' && (
2020-12-12 17:54:13 +01:00
<>
<Scheduler />
<Rightbar />
</>
2021-01-05 23:46:51 +01:00
)}
2021-01-05 21:05:16 +01:00
{userPrivilige === 'DEANERY' && <Admin />}
2020-12-12 17:54:13 +01:00
</Wrapper>
</LoadingOverlay>
</>
);
};