All files / src/components App.tsx

90% Statements 9/10
62.5% Branches 5/8
50% Functions 1/2
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59                        1x                 1x 2x 2x   2x 2x   2x       2x 2x                                                  
import React, { useContext, useState } from 'react';
import Topbar from './Topbar';
import { Transfer } from './Transfer';
import { DeaneryPanel } from './DeaneryPanel';
import { Scheduler } from './Scheduler';
import { Rightbar } from './Rightbar';
import { Administrator } from './Administrator';
import styled from 'styled-components';
import LoadingOverlay from 'react-loading-overlay';
import { SyncLoader } from 'react-spinners';
import { CASContext } from '../contexts/CASProvider';
import { coursesContext } from '../contexts/CoursesProvider';
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 { selectSchedulerEvents } = useContext(coursesContext)!;
  const schedulerEvents = selectSchedulerEvents();
 
  const handleTransfer = () => {
    setOpenTransfer(!isOpenTransfer);
  };
 
  const userPrivilige = localStorage.getItem('userPrivilige');
  return (
    <>
      <LoadingOverlay active={role === undefined} spinner={<SyncLoader />}>
        {userPrivilige !== 'ADMIN' && (
            <>
              <Topbar handleTransfer={handleTransfer} />
              <Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} />
              <Wrapper>
                {userPrivilige === 'STUDENT' && (
                  <>
                    <Scheduler schedulerEvents={schedulerEvents} />
                    <Rightbar />
                  </>
                )}
                {userPrivilige === 'DEANERY' && <DeaneryPanel schedulerEvents={schedulerEvents} />}
              </Wrapper>
            </>
          )}
        {userPrivilige === 'ADMIN' && (
            <Administrator></Administrator>
        )}
      </LoadingOverlay>
    </>
  );
};