source: sources/client/src/components/admin/ParkingZoneInfoEdit/ZoneSectorEdit/index.js

Last change on this file was bc20307, checked in by Tasevski2 <39170279+Tasevski2@…>, 2 years ago

Push before video

  • Property mode set to 100644
File size: 6.8 KB
Line 
1import MenuItem from '@mui/material/MenuItem';
2import { ColorPicker } from 'material-ui-color';
3import {
4 Wrapper,
5 Title,
6 DividerUnderTitle,
7 Characteristics,
8 KeyValueWrapper,
9 Key,
10 Value,
11 ColorCircleWrapper,
12 ZoneCenterLocation,
13 SmallTitle,
14 LatLngCenter,
15 LabelAndLatLngWrapper,
16 LatLngLabel,
17 LatLngValue,
18 ZoneCornersLocation,
19 TableWrapper,
20 EditedInputAdornment,
21 TimeSelectInputsWrapper,
22 TimeSelectInput,
23 TImeSelectInputsDivider,
24 AddIcon,
25 TableDataInput,
26 DeleteIcon,
27} from './styles';
28import { IconButton } from '@mui/material';
29
30const selectInputValues = Array(24)
31 .fill()
32 .map((_, index) => (
33 <MenuItem value={index + 1} key={index + 1}>
34 {index + 1 < 10 ? `0${index + 1}` : index + 1}
35 </MenuItem>
36 ));
37
38const MenuProps = {
39 PaperProps: {
40 style: {
41 height: 150,
42 width: '35px',
43 },
44 },
45};
46
47const ZoneSector = ({
48 zoneName,
49 hourlyRate,
50 from,
51 to,
52 zoneColor,
53 setZoneColor,
54 lat,
55 lng,
56 setZoneSectorData,
57 newCoord,
58 setNewCoord,
59 coords,
60 handleCoordsChange,
61}) => {
62 return (
63 <Wrapper>
64 <Title>Паркинг Зона</Title>
65 <DividerUnderTitle />
66 <Characteristics>
67 <KeyValueWrapper>
68 <Key>Назив:</Key>
69 <Value
70 name='zoneName'
71 onChange={setZoneSectorData}
72 value={zoneName}
73 />
74 </KeyValueWrapper>
75 <KeyValueWrapper>
76 <Key>Цена од Час:</Key>
77 <Value
78 name='hourlyRate'
79 onChange={setZoneSectorData}
80 value={hourlyRate}
81 InputProps={{
82 endAdornment: (
83 <EditedInputAdornment style={{}} position='end'>
84 ден.
85 </EditedInputAdornment>
86 ),
87 }}
88 />
89 </KeyValueWrapper>
90 <KeyValueWrapper>
91 <Key>Работни часови:</Key>
92 <TimeSelectInputsWrapper>
93 <TimeSelectInput
94 MenuProps={MenuProps}
95 name='from'
96 onChange={setZoneSectorData}
97 value={from}
98 >
99 <MenuItem value={0} key={0}>
100 <em>NONE</em>
101 </MenuItem>
102 {selectInputValues}
103 </TimeSelectInput>
104 <TImeSelectInputsDivider />
105 <TimeSelectInput
106 MenuProps={MenuProps}
107 name='to'
108 onChange={setZoneSectorData}
109 value={to}
110 >
111 <MenuItem value={0} key={0}>
112 <em>NONE</em>
113 </MenuItem>
114 {selectInputValues}
115 </TimeSelectInput>
116 </TimeSelectInputsWrapper>
117 </KeyValueWrapper>
118 <KeyValueWrapper>
119 <Key>Боја на зона:</Key>
120 <ColorCircleWrapper>
121 <ColorPicker
122 value={zoneColor}
123 onChange={(e) => setZoneColor(`#${e.hex}`)}
124 hideTextfield
125 />
126 </ColorCircleWrapper>
127 </KeyValueWrapper>
128 </Characteristics>
129
130 <ZoneCenterLocation>
131 <SmallTitle>Центар на Зона</SmallTitle>
132 <LatLngCenter>
133 <LabelAndLatLngWrapper>
134 <LatLngLabel htmlFor='lat-value'>Латитуда:</LatLngLabel>
135 <LatLngValue
136 id='lat-value'
137 name='lat'
138 onChange={setZoneSectorData}
139 value={lat}
140 />
141 </LabelAndLatLngWrapper>
142 <LabelAndLatLngWrapper>
143 <LatLngLabel htmlFor='lng-value'>Лонгитуда:</LatLngLabel>
144 <LatLngValue
145 id='lng-value'
146 name='lng'
147 onChange={setZoneSectorData}
148 value={lng}
149 />
150 </LabelAndLatLngWrapper>
151 </LatLngCenter>
152 </ZoneCenterLocation>
153
154 <ZoneCornersLocation>
155 <SmallTitle>Темиња на Зона</SmallTitle>
156 <TableWrapper>
157 <table>
158 <thead>
159 <tr>
160 <th></th>
161 <th>Латитуда</th>
162 <th>Лонгитуда</th>
163 <th></th>
164 </tr>
165 </thead>
166 <tbody>
167 <tr className='add-row'>
168 <td></td>
169 <td className='add-td'>
170 <TableDataInput
171 name='newLat'
172 onChange={(e) =>
173 setNewCoord({ ...newCoord, newLat: e.target.value })
174 }
175 value={newCoord.newLat}
176 />
177 </td>
178 <td className='add-td'>
179 <TableDataInput
180 name='newLng'
181 onChange={(e) =>
182 setNewCoord({ ...newCoord, newLng: e.target.value })
183 }
184 value={newCoord.newLng}
185 />
186 </td>
187 <td>
188 <IconButton
189 style={{ padding: 3.5 }}
190 onClick={() => handleCoordsChange({ type: 'add' })}
191 >
192 <AddIcon />
193 </IconButton>
194 </td>
195 </tr>
196 {coords.map(({ lat, lng }, index) => (
197 <tr key={index}>
198 <td>
199 <IconButton
200 style={{ padding: 3.5 }}
201 onClick={() =>
202 handleCoordsChange({
203 type: 'delete',
204 payload: { index },
205 })
206 }
207 >
208 <DeleteIcon />
209 </IconButton>
210 </td>
211 <td>
212 <TableDataInput
213 value={lat}
214 onChange={(e) =>
215 handleCoordsChange({
216 type: 'update',
217 payload: {
218 index,
219 column: 'lat',
220 value: e.target.value,
221 },
222 })
223 }
224 />
225 </td>
226 <td>
227 <TableDataInput
228 value={lng}
229 onChange={(e) =>
230 handleCoordsChange({
231 type: 'update',
232 payload: {
233 index,
234 column: 'lng',
235 value: e.target.value,
236 },
237 })
238 }
239 />
240 </td>
241 <td></td>
242 </tr>
243 ))}
244 </tbody>
245 </table>
246 </TableWrapper>
247 </ZoneCornersLocation>
248 </Wrapper>
249 );
250};
251
252export default ZoneSector;
Note: See TracBrowser for help on using the repository browser.