|
1 | 1 | import { useEffect } from 'react'; |
2 | 2 | import { MultiSelect } from 'react-multi-select-component'; |
3 | | -import { Button, Label, Row, Col, FormGroup } from 'reactstrap'; |
| 3 | +import { Button, Row, Col, FormGroup } from 'reactstrap'; |
4 | 4 | import mainStyles from './WeeklySummariesReport.module.css'; |
5 | | -import { setField, toggleField, removeItemFromField, setChildField } from '~/utils/stateHelper'; |
| 5 | +import WeeklySummariesToggleFilter from './WeeklySummariesToggleFilter.jsx'; |
| 6 | +import { setField, removeItemFromField } from '~/utils/stateHelper'; |
6 | 7 |
|
7 | 8 | export default function FilterEditForm({ |
8 | 9 | state, |
@@ -52,18 +53,6 @@ export default function FilterEditForm({ |
52 | 53 | })); |
53 | 54 | }, [state.selectedCodes, summaries]); |
54 | 55 |
|
55 | | - const handleTrophyToggleChange = () => { |
56 | | - toggleField(setState, 'selectedTrophies'); |
57 | | - }; |
58 | | - |
59 | | - const handleBioStatusToggleChange = () => { |
60 | | - toggleField(setState, 'selectedBioStatus'); |
61 | | - }; |
62 | | - |
63 | | - const handleOverHoursToggleChange = () => { |
64 | | - toggleField(setState, 'selectedOverTime'); |
65 | | - }; |
66 | | - |
67 | 56 | return ( |
68 | 57 | <FormGroup> |
69 | 58 | <Row className="pt-4"> |
@@ -236,110 +225,13 @@ export default function FilterEditForm({ |
236 | 225 | )} |
237 | 226 | </Col> |
238 | 227 | </Row> |
239 | | - <div className={`${mainStyles.filterContainer} pt-4`}> |
240 | | - {hasPermissionToFilter && ( |
241 | | - <div className={`${mainStyles.filterStyle} ${mainStyles.marginRight}`}> |
242 | | - <span>Filter by Special Colors</span> |
243 | | - <div style={{ display: 'flex', alignItems: 'center', gap: '8px', marginTop: '2px' }}> |
244 | | - {['purple', 'green', 'navy'].map(color => ( |
245 | | - <div key={`${color}-toggle`} style={{ display: 'flex', alignItems: 'center' }}> |
246 | | - <div className={`${mainStyles.switchToggleControl}`}> |
247 | | - <input |
248 | | - type="checkbox" |
249 | | - className={`${mainStyles.switchToggle}`} |
250 | | - id={`filter-modal-${color}-toggle`} |
251 | | - checked={state.selectedSpecialColors[color]} |
252 | | - onChange={e => |
253 | | - setChildField(setState, 'selectedSpecialColors', color, e.target.checked) |
254 | | - } |
255 | | - /> |
256 | | - <Label |
257 | | - className={`${mainStyles.switchToggleLabel}`} |
258 | | - for={`filter-modal-${color}-toggle`} |
259 | | - > |
260 | | - <span className={`${mainStyles.switchToggleInner}`} /> |
261 | | - <span className={`${mainStyles.switchToggleSwitch}`} /> |
262 | | - </Label> |
263 | | - </div> |
264 | | - <span |
265 | | - style={{ |
266 | | - marginLeft: '3px', |
267 | | - fontSize: 'inherit', |
268 | | - textTransform: 'capitalize', |
269 | | - whiteSpace: 'nowrap', |
270 | | - fontWeight: 'normal', |
271 | | - }} |
272 | | - > |
273 | | - {color} |
274 | | - </span> |
275 | | - </div> |
276 | | - ))} |
277 | | - </div> |
278 | | - </div> |
279 | | - )} |
280 | | - </div> |
281 | | - <div className={`${mainStyles.filterContainer} pt-4`}> |
282 | | - {(hasPermissionToFilter || canSeeBioHighlight) && ( |
283 | | - <div className={`${mainStyles.filterStyle} ${mainStyles.marginRight}`}> |
284 | | - <span>Filter by Bio Status</span> |
285 | | - <div className={`${mainStyles.switchToggleControl}`}> |
286 | | - <input |
287 | | - type="checkbox" |
288 | | - className={`${mainStyles.switchToggle}`} |
289 | | - id="filter-modal-bio-status-toggle" |
290 | | - checked={state.selectedBioStatus} |
291 | | - onChange={handleBioStatusToggleChange} |
292 | | - /> |
293 | | - <Label |
294 | | - className={`${mainStyles.switchToggleLabel}`} |
295 | | - for="filter-modal-bio-status-toggle" |
296 | | - > |
297 | | - <span className={`${mainStyles.switchToggleInner}`} /> |
298 | | - <span className={`${mainStyles.switchToggleSwitch}`} /> |
299 | | - </Label> |
300 | | - </div> |
301 | | - </div> |
302 | | - )} |
303 | | - {hasPermissionToFilter && ( |
304 | | - <div className={`${mainStyles.filterStyle} ${mainStyles.marginRight}`}> |
305 | | - <span>Filter by Trophies</span> |
306 | | - <div className={`${mainStyles.switchToggleControl}`}> |
307 | | - <input |
308 | | - type="checkbox" |
309 | | - className={`${mainStyles.switchToggle}`} |
310 | | - checked={state.selectedTrophies} |
311 | | - id="filter-modal-trophy-toggle" |
312 | | - onChange={handleTrophyToggleChange} |
313 | | - /> |
314 | | - <Label className={`${mainStyles.switchToggleLabel}`} for="filter-modal-trophy-toggle"> |
315 | | - <span className={`${mainStyles.switchToggleInner}`} /> |
316 | | - <span className={`${mainStyles.switchToggleSwitch}`} /> |
317 | | - </Label> |
318 | | - </div> |
319 | | - </div> |
320 | | - )} |
321 | | - {hasPermissionToFilter && ( |
322 | | - <div className={`${mainStyles.filterStyle} ${mainStyles.marginRight}`}> |
323 | | - <span>Filter by Over Hours</span> |
324 | | - <div className={`${mainStyles.switchToggleControl}`}> |
325 | | - <input |
326 | | - type="checkbox" |
327 | | - className={`${mainStyles.switchToggle}`} |
328 | | - checked={state.selectedOverTime} |
329 | | - id="filter-modal-over-hours-toggle" |
330 | | - onChange={handleOverHoursToggleChange} |
331 | | - /> |
332 | | - <Label |
333 | | - className={`${mainStyles.switchToggleLabel}`} |
334 | | - for="filter-modal-over-hours-toggle" |
335 | | - > |
336 | | - <span className={`${mainStyles.switchToggleInner}`} /> |
337 | | - <span className={`${mainStyles.switchToggleSwitch}`} /> |
338 | | - </Label> |
339 | | - </div> |
340 | | - </div> |
341 | | - )} |
342 | | - </div> |
| 228 | + <WeeklySummariesToggleFilter |
| 229 | + state={state} |
| 230 | + setState={setState} |
| 231 | + hasPermissionToFilter={hasPermissionToFilter} |
| 232 | + editable={true} |
| 233 | + formId="filter-edit" |
| 234 | + /> |
343 | 235 | </FormGroup> |
344 | 236 | ); |
345 | 237 | } |
0 commit comments