fix(ui): clarify scheduler logic

- use full conditional syntax with `{}`
- do not mutate `action.payload` in a reducer
This commit is contained in:
psychedelicious
2023-06-18 18:47:59 +10:00
parent be8c0bb952
commit f1a8b9daee
2 changed files with 15 additions and 5 deletions

View File

@ -24,14 +24,17 @@ const ParamScheduler = () => {
const { t } = useTranslation();
useEffect(() => {
if (selectedSchedulers.length === 0)
if (selectedSchedulers.length === 0) {
dispatch(setSelectedSchedulers([...SCHEDULER_ITEMS]));
}
const schedulerFound = activeSchedulers.find(
(activeSchedulers) => activeSchedulers.value === scheduler
);
if (!schedulerFound)
if (!schedulerFound) {
dispatch(setScheduler(activeSchedulers[0].value as Scheduler));
}
}, [dispatch, selectedSchedulers, scheduler, activeSchedulers]);
const handleChange = useCallback(