source: sources/client/src/components/admin/ParkingZone/index.js@ e8b1076

Last change on this file since e8b1076 was 3a58bd6, checked in by Viktor <39170279+Tasevski2@…>, 3 years ago

Added Frontend

  • Property mode set to 100644
File size: 2.0 KB
Line 
1import { useState } from 'react';
2import { useParams } from 'react-router-dom';
3
4import { IconButton } from '@mui/material';
5
6import ParkingZoneInfo from '../ParkingZoneInfo';
7import ParkingZoneSessions from '../ParkingZoneSessions';
8import GoogleMaps from '../../GoogleMaps';
9
10import {
11 NamesWrapper,
12 ParkingAndZoneName,
13 DividerUnderNames,
14 NavigationIconsWrapper,
15 MainSection,
16 MapsIcon,
17 ComponentIcon,
18} from './styles';
19
20import { roles } from '../../../config/enums';
21
22import { parkingZones } from '../ParkingZones/mockData';
23
24const activeComponentEnum = {
25 MAPS: 'maps',
26 INFO: 'info',
27};
28
29const ParkingZone = () => {
30 const { zone_id } = useParams();
31 const [activeComponent, setActiveComponent] = useState(
32 activeComponentEnum.MAPS
33 );
34
35 const user = {
36 role: 'ROLE_ADMIN',
37 };
38
39 const zone = parkingZones.find((z) => z.id === parseInt(zone_id));
40 const Info =
41 user.role !== roles.admin ? ParkingZoneInfo : ParkingZoneSessions;
42 return (
43 <>
44 <NamesWrapper>
45 <ParkingAndZoneName>Паркинг - Дебар Маало</ParkingAndZoneName>
46 <ParkingAndZoneName>{zone?.zoneName}</ParkingAndZoneName>
47 </NamesWrapper>
48
49 <DividerUnderNames />
50
51 <NavigationIconsWrapper>
52 <IconButton
53 onClick={() => setActiveComponent(activeComponentEnum.MAPS)}
54 >
55 <MapsIcon $isactive={activeComponent === activeComponentEnum.MAPS} />
56 </IconButton>
57 <IconButton
58 onClick={() => setActiveComponent(activeComponentEnum.INFO)}
59 >
60 <ComponentIcon
61 $isactive={activeComponent === activeComponentEnum.INFO}
62 />
63 </IconButton>
64 </NavigationIconsWrapper>
65
66 <MainSection>
67 {activeComponent === activeComponentEnum.MAPS ? (
68 <GoogleMaps
69 location={zone.location}
70 parkingSpacesLocation={zone.parkingSpacesLocation}
71 zoneAreaColor={zone.areaColor}
72 />
73 ) : (
74 <Info zone={zone} />
75 )}
76 </MainSection>
77 </>
78 );
79};
80
81export default ParkingZone;
Note: See TracBrowser for help on using the repository browser.