2020-12-12 17:54:13 +01:00
|
|
|
import React, { ElementType, useContext, useState } from 'react';
|
2020-08-20 18:14:28 +02:00
|
|
|
import Topbar from './Topbar';
|
2020-08-18 18:32:26 +02:00
|
|
|
import { Transfer } from './Transfer';
|
2020-11-29 23:42:36 +01:00
|
|
|
import { Admin } from './Admin';
|
2020-08-17 22:05:13 +02:00
|
|
|
import { Scheduler } from './Scheduler';
|
2020-08-17 23:56:34 +02:00
|
|
|
import { Rightbar } from './Rightbar';
|
2020-08-17 22:05:13 +02:00
|
|
|
import styled from 'styled-components';
|
2020-12-12 17:54:13 +01:00
|
|
|
import { coursesContext } from '../contexts/CoursesProvider';
|
|
|
|
import LoadingOverlay from 'react-loading-overlay';
|
|
|
|
import { SyncLoader } from 'react-spinners';
|
2020-08-17 22:05:13 +02:00
|
|
|
const Wrapper = styled.div`
|
|
|
|
display: flex;
|
2020-08-29 18:52:03 +02:00
|
|
|
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;
|
2020-08-17 22:05:13 +02:00
|
|
|
`;
|
|
|
|
|
|
|
|
export const App = () => {
|
2020-12-12 17:54:13 +01:00
|
|
|
const { isDataLoading } = useContext(coursesContext)!;
|
2020-08-17 22:05:13 +02:00
|
|
|
const [isOpenTransfer, setOpenTransfer] = useState(false);
|
|
|
|
|
|
|
|
const handleTransfer = () => {
|
|
|
|
setOpenTransfer(!isOpenTransfer);
|
|
|
|
};
|
|
|
|
|
2020-12-12 17:54:13 +01:00
|
|
|
const userPrivilige = localStorage.getItem('userPrivilige');
|
|
|
|
|
2020-08-17 22:05:13 +02:00
|
|
|
return (
|
|
|
|
<>
|
2020-12-12 17:54:13 +01:00
|
|
|
<LoadingOverlay active={isDataLoading} spinner={<SyncLoader />}>
|
|
|
|
<Topbar handleTransfer={handleTransfer} />
|
|
|
|
<Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} />
|
|
|
|
<Wrapper>
|
|
|
|
{userPrivilige === 'STUDENT' ? (
|
|
|
|
<>
|
|
|
|
<Scheduler />
|
|
|
|
<Rightbar />
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<Admin />
|
|
|
|
)}
|
|
|
|
</Wrapper>
|
|
|
|
</LoadingOverlay>
|
2020-08-17 22:05:13 +02:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|