bugfix: handle time 0

This commit is contained in:
cv
2021-04-17 12:29:01 +02:00
parent 37145ee076
commit 2890687f73
3 changed files with 14 additions and 9 deletions
@@ -1,5 +1,6 @@
import EditableTimer from '../../input/EditableTimer';
import DelayValue from '../../input/DelayValue';
import { showErrorToast } from '../../helpers/toastManager';
export default function EventTimes(props) {
const { updateValues, delay, timeStart, timeEnd } = props;
@@ -9,15 +10,19 @@ export default function EventTimes(props) {
// if one of the fields is not set, all good
if (v == null || timeStart == null || timeEnd == null) return true;
if (v === 0 || timeStart === 0 || timeEnd === 0) return true;
if (entry === 'timeStart') return v < timeEnd;
else if (entry === 'timeEnd') return v > timeStart;
let validate = { value: false, catch: 'undefined error' };
if (entry === 'timeStart')
validate = { value: v < timeEnd, catch: 'Start time later than end time' };
else if (entry === 'timeEnd')
validate = { value: v > timeStart, catch: 'End time earlier than start time' };
// shouldnt come to this
return false;
if (validate.value === false)
showErrorToast('Time Input Invalid', validate.catch);
return validate.value;
};
return (
<>
<DelayValue delay={delay} />