Ignore:
Timestamp:
02/14/22 01:41:41 (2 years ago)
Author:
Tasevski2 <39170279+Tasevski2@…>
Branches:
master
Children:
747e0ab
Parents:
e8b1076
Message:

Push before video

Location:
sources/client/src/screens
Files:
2 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • sources/client/src/screens/AdminHomeScreen/index.js

    re8b1076 rbc20307  
     1import { useContext, useState } from 'react';
    12import { Route, Switch, Redirect } from 'react-router-dom';
    23import { useHistory } from 'react-router-dom';
     
    1920  DividerUnderHeader,
    2021  UserIcon,
     22  MenuBurgerIcon,
    2123} from './styles';
    2224
    2325import IconButton from '@mui/material/IconButton';
    2426
    25 import logo from '../../resources/logo_2_transparent_bg.jpg';
     27import logo from '../../resources/logo_2_transparent_bg.png';
    2628import { roles } from '../../config/enums';
    2729import DestinationComponent from '../../utils/DestinationComponent';
    2830import onClickRouting from '../../utils/onClickRouting';
     31import AbsoluteLoader from '../../components/Loaders/AbsoluteLoader';
    2932
    3033import ParkingZones from '../../components/admin/ParkingZones';
     
    3336import EmployeeCreate from '../../components/admin/EmployeeCreate';
    3437import ParkingZone from '../../components/admin/ParkingZone';
     38
     39import { UserContext } from '../../context/UserContext';
     40import { AccessoriesContext } from '../../context/AccessoriesContext';
     41import useLogoutUser from '../../hooks/useLogoutUser';
    3542
    3643const ToParkingZones = new DestinationComponent('/', ParkingZones, true);
     
    6774
    6875const AdminHomeScreen = (props) => {
     76  const { user, isLoadingUser } = useContext(UserContext);
     77  const { isMobile, setIsOpenDrawer } = useContext(AccessoriesContext);
    6978  let history = useHistory();
    70   const user = {
    71     role: 'ROLE_ADMIN',
    72   };
    73 
     79  const { logoutUser } = useLogoutUser();
    7480  let routes = user.role === roles.admin ? adminRoutes : employeeRoutes;
    7581
    7682  return (
    7783    <Container>
    78       <SideMenu>
    79         <IconButton onClick={() => onClickRouting('/', history)}>
    80           <DashboardIcon />
    81         </IconButton>
    82         {user.role === roles.admin ? (
    83           <IconButton onClick={() => onClickRouting('/employees', history)}>
    84             <SupervisorAccountIcon />
    85           </IconButton>
    86         ) : null}
    87       </SideMenu>
     84      {isLoadingUser ? (
     85        <AbsoluteLoader
     86          containerStyle={{
     87            width: isMobile ? '150px' : '300px',
     88            height: isMobile ? '150px' : '300px',
     89            margin: 'auto',
     90          }}
     91        />
     92      ) : (
     93        <>
     94          {!isMobile ? (
     95            <SideMenu>
     96              <IconButton onClick={() => onClickRouting('/', history)}>
     97                <DashboardIcon />
     98              </IconButton>
     99              {user.role === roles.admin ? (
     100                <IconButton
     101                  onClick={() => onClickRouting('/employees', history)}
     102                >
     103                  <SupervisorAccountIcon />
     104                </IconButton>
     105              ) : null}
     106            </SideMenu>
     107          ) : null}
    88108
    89       <HeaderAndMainSectionWrapper>
    90         <Header>
    91           <TitleAndLogoWrapper>
    92             <LogoWrapper>
    93               <Logo src={logo} />
    94             </LogoWrapper>
    95             <HeaderTitle>Park Up</HeaderTitle>
    96           </TitleAndLogoWrapper>
     109          <HeaderAndMainSectionWrapper>
     110            <Header>
     111              {isMobile ? (
     112                <IconButton
     113                  onClick={() => setIsOpenDrawer(true)}
     114                  style={{ padding: 0 }}
     115                >
     116                  <MenuBurgerIcon />
     117                </IconButton>
     118              ) : null}
     119              <TitleAndLogoWrapper>
     120                <LogoWrapper>
     121                  <Logo src={logo} />
     122                </LogoWrapper>
     123                <HeaderTitle>Park Up</HeaderTitle>
     124              </TitleAndLogoWrapper>
    97125
    98           <UserNameAndLogoutWrapper>
    99             <UserIcon />
    100             <UserName>Viktor Tasevski</UserName>
    101             <IconButton>
    102               <LogoutIcon />
    103             </IconButton>
    104           </UserNameAndLogoutWrapper>
    105         </Header>
    106         <DividerUnderHeader />
    107         <MainSection>
    108           <Switch>
    109             {routes?.map((route, index) => (
    110               <Route
    111                 key={index}
    112                 path={route.path}
    113                 component={route.component}
    114                 exact={route.exact}
    115               />
    116             ))}
    117             <Redirect to='/' />
    118           </Switch>
    119         </MainSection>
    120       </HeaderAndMainSectionWrapper>
     126              {isMobile ? null : (
     127                <UserNameAndLogoutWrapper>
     128                  <UserIcon />
     129                  <UserName>
     130                    {user.firstName} {user.lastName}
     131                  </UserName>
     132                  <IconButton onClick={logoutUser}>
     133                    <LogoutIcon />
     134                  </IconButton>
     135                </UserNameAndLogoutWrapper>
     136              )}
     137            </Header>
     138            <DividerUnderHeader />
     139            <MainSection>
     140              <Switch>
     141                {routes?.map((route, index) => (
     142                  <Route
     143                    key={index}
     144                    path={route.path}
     145                    component={route.component}
     146                    exact={route.exact}
     147                  />
     148                ))}
     149                <Redirect to='/' />
     150              </Switch>
     151            </MainSection>
     152          </HeaderAndMainSectionWrapper>
     153        </>
     154      )}
    121155    </Container>
    122156  );
  • sources/client/src/screens/AdminHomeScreen/styles.js

    re8b1076 rbc20307  
    77import SupervisorAccount from '@mui/icons-material/SupervisorAccount';
    88import AccountCircleIcon from '@mui/icons-material/AccountCircle';
     9import Box from '@mui/material/Box';
     10import MenuIcon from '@mui/icons-material/Menu';
     11import CloseI from '@mui/icons-material/Close';
     12import { mobile_max_width } from '../../config/utilities';
     13import backgroundImage from '../../resources/login_background.jpg';
    914
    1015export const Container = styled.div`
    1116  display: flex;
    1217  flex-direction: row;
    13   height: 100%;
     18  min-height: 100vh;
    1419  flex: 1;
    1520`;
     
    2025  flex-direction: row;
    2126  justify-content: space-between;
    22   padding: 10px 30px;
     27  padding: 10px 7%;
     28  position: fixed;
     29  z-index: 100;
     30  background-color: ${(props) => props.theme.palette.background.whiteSmoke};
     31  @media (max-width: ${mobile_max_width}px) {
     32    padding-left: 15px;
     33  }
    2334`;
    2435
     
    2637  variant: 'middle',
    2738  sx: {
    28     margin: '0 25px',
     39    margin: '0 5%',
     40    marginTop: '75px',
    2941    borderWidth: '2px',
    3042    borderBottomWidth: 'thin',
     
    7587  sx: {
    7688    fontSize: 30,
    77     color: `${props.theme.palette.error.light}`,
     89    color: `${props.theme.palette.error.main}`,
    7890  },
    7991}))``;
     
    8294  display: flex;
    8395  flex-direction: column;
    84   height: 100%;
    8596  width: 100%;
     97  padding-left: 70px;
    8698  background-color: ${(props) => props.theme.palette.background.whiteSmoke};
     99
     100  @media (max-width: ${mobile_max_width}px) {
     101    padding-left: 0;
     102  }
    87103`;
    88104
    89105export const SideMenu = styled.div`
    90106  flex-direction: column;
    91   height: 100%;
    92107  width: 70px;
    93108  padding: 20px 10px 0 10px;
    94109  border-right: 1px solid grey;
     110  position: fixed;
     111  height: 100%;
    95112  background-color: ${(props) => props.theme.palette.primary.main};
    96113`;
     
    124141  width: 100%;
    125142  height: 100%;
    126   padding: 20px 0px;
     143  padding-top: 20px;
    127144  display: flex;
    128145  flex-direction: column;
    129146`;
     147
     148export const MenuBurgerIcon = styled(MenuIcon).attrs((props) => ({
     149  sx: {
     150    fontSize: 50,
     151    color: `${props.theme.palette.primary.main}`,
     152  },
     153}))``;
Note: See TracChangeset for help on using the changeset viewer.