mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-10 00:29:41 +00:00
bugfix: handle time 0
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import EditableTimer from '../../input/EditableTimer';
|
import EditableTimer from '../../input/EditableTimer';
|
||||||
import DelayValue from '../../input/DelayValue';
|
import DelayValue from '../../input/DelayValue';
|
||||||
|
import { showErrorToast } from '../../helpers/toastManager';
|
||||||
|
|
||||||
export default function EventTimes(props) {
|
export default function EventTimes(props) {
|
||||||
const { updateValues, delay, timeStart, timeEnd } = 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 one of the fields is not set, all good
|
||||||
|
|
||||||
if (v == null || timeStart == null || timeEnd == null) return true;
|
if (v == null || timeStart == null || timeEnd == null) return true;
|
||||||
|
if (v === 0 || timeStart === 0 || timeEnd === 0) return true;
|
||||||
|
|
||||||
if (entry === 'timeStart') return v < timeEnd;
|
let validate = { value: false, catch: 'undefined error' };
|
||||||
else if (entry === 'timeEnd') return v > timeStart;
|
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
|
if (validate.value === false)
|
||||||
return false;
|
showErrorToast('Time Input Invalid', validate.catch);
|
||||||
|
return validate.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DelayValue delay={delay} />
|
<DelayValue delay={delay} />
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
export const timeFormat = 'HH:mm';
|
export const timeFormat = 'HH:mm';
|
||||||
export const timeFormatSeconds = 'HH:mm:ss';
|
export const timeFormatSeconds = 'HH:mm:ss';
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ export const stringFromMillis = (
|
|||||||
const seconds = showWith0(Math.floor((ms / 1000) % 60));
|
const seconds = showWith0(Math.floor((ms / 1000) % 60));
|
||||||
return showSeconds
|
return showSeconds
|
||||||
? `${parseInt(hours) ? `${hours}${delim}` : ''}${minutes}${delim}${seconds}`
|
? `${parseInt(hours) ? `${hours}${delim}` : ''}${minutes}${delim}${seconds}`
|
||||||
: `${parseInt(hours) ? `${hours}${delim}` : ''}${minutes}`;
|
: `${parseInt(hours) ? `${hours}` : '00'}${delim}${minutes}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// millis to seconds
|
// millis to seconds
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ const event = {
|
|||||||
title: '',
|
title: '',
|
||||||
subtitle: '',
|
subtitle: '',
|
||||||
presenter: '',
|
presenter: '',
|
||||||
timeStart: null,
|
timeStart: 0,
|
||||||
timeEnd: null,
|
timeEnd: 0,
|
||||||
clockStarted: null,
|
clockStarted: null,
|
||||||
|
isPublic: false,
|
||||||
type: 'event',
|
type: 'event',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user