mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 04:43:35 +00:00
48093b8651
* ux/54-help tooltips * ux/54-help refetch after mutation * ux/54-help broadcast event index * ux/54-help prevent multiple keypresses when key held * ux/54-help fat clock * ux/54-help progress bar user defined * ux/54-help onAir is button * ux/54-help OSC: add missing presenter message * ux/54-help OSC: enable / disable OSC * ux/54-help handle timezone in excel date import * ux/54-help tray left click to show app * ux/54-help create queriable endpoint * ux/54-help fix memoisation in lower thirds * ux/54-help revise icons * ux/54-help clarify text * ux/54-help forgiving text parsing * ux/54-help add smart keywords * ux/54-help version bump
62 lines
1.6 KiB
React
62 lines
1.6 KiB
React
import EditableTimer from 'common/input/EditableTimer';
|
|
import { useContext } from 'react';
|
|
import { LoggingContext } from '../../../app/context/LoggingContext';
|
|
import { validateTimes } from '../../../app/entryValidator';
|
|
import PropTypes from 'prop-types';
|
|
|
|
export default function EventTimes(props) {
|
|
const { actionHandler, delay, timeStart, timeEnd, previousEnd } = props;
|
|
const { emitWarning } = useContext(LoggingContext);
|
|
|
|
const handleValidate = (entry, val) => {
|
|
if (val == null || timeStart == null || timeEnd == null) return true;
|
|
if (timeStart === 0) return true;
|
|
|
|
let start = timeStart;
|
|
let end = timeEnd;
|
|
if (entry === 'timeStart') {
|
|
start = val;
|
|
} else if (entry === 'timeEnd') {
|
|
end = val;
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
const valid = validateTimes(start, end);
|
|
// give warning but not enforce validation
|
|
if (!valid.value) {
|
|
emitWarning(`Time Input Warning: ${valid.catch}`);
|
|
}
|
|
return valid.value;
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<EditableTimer
|
|
name='timeStart'
|
|
validate={handleValidate}
|
|
actionHandler={actionHandler}
|
|
time={timeStart}
|
|
delay={delay}
|
|
previousEnd={previousEnd}
|
|
/>
|
|
<EditableTimer
|
|
name='timeEnd'
|
|
validate={handleValidate}
|
|
actionHandler={actionHandler}
|
|
time={timeEnd}
|
|
delay={delay}
|
|
previousEnd={previousEnd}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
|
|
EventTimes.propTypes = {
|
|
actionHandler: PropTypes.func.isRequired,
|
|
delay: PropTypes.number.isRequired,
|
|
timeStart: PropTypes.number.isRequired,
|
|
timeEnd: PropTypes.number.isRequired,
|
|
previousEnd: PropTypes.number.isRequired,
|
|
};
|