mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-23 07:59:10 +00:00
chore: cleanup
This commit is contained in:
@@ -18,20 +18,6 @@ interface TimeInputProps {
|
|||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ButtonInitial(name: TimeEntryField) {
|
|
||||||
if (name === 'timeStart') return 'S';
|
|
||||||
if (name === 'timeEnd') return 'E';
|
|
||||||
if (name === 'durationOverride') return 'D';
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function ButtonTooltip(name: TimeEntryField, tooltip?: string) {
|
|
||||||
if (name === 'timeStart') return `Start${tooltip ? `: ${tooltip}` : ''}`;
|
|
||||||
if (name === 'timeEnd') return `End${tooltip ? `: ${tooltip}` : ''}`;
|
|
||||||
if (name === 'durationOverride') return `Duration${tooltip ? `: ${tooltip}` : ''}`;
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function TimeInput(props: TimeInputProps) {
|
export default function TimeInput(props: TimeInputProps) {
|
||||||
const { id, name, submitHandler, time = 0, delay = 0, placeholder, previousEnd = 0, className } = props;
|
const { id, name, submitHandler, time = 0, delay = 0, placeholder, previousEnd = 0, className } = props;
|
||||||
const { emitError } = useEmitLog();
|
const { emitError } = useEmitLog();
|
||||||
@@ -152,19 +138,8 @@ export default function TimeInput(props: TimeInputProps) {
|
|||||||
resetValue();
|
resetValue();
|
||||||
}, [resetValue, time]);
|
}, [resetValue, time]);
|
||||||
|
|
||||||
const isDelayed = delay !== 0;
|
|
||||||
const inputClasses = cx([style.timeInput, isDelayed ? style.delayed : null]);
|
|
||||||
const buttonClasses = cx([style.inputButton, isDelayed ? style.delayed : null]);
|
|
||||||
const timeInputClass = className ? className : style.timeInput;
|
const timeInputClass = className ? className : style.timeInput;
|
||||||
|
|
||||||
const TooltipLabel = useMemo(() => {
|
|
||||||
return ButtonTooltip(name, '');
|
|
||||||
}, [name]);
|
|
||||||
|
|
||||||
const ButtonText = useMemo(() => {
|
|
||||||
return ButtonInitial(name);
|
|
||||||
}, [name]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Input
|
<Input
|
||||||
size='sm'
|
size='sm'
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ interface TimeInputProps {
|
|||||||
time?: number;
|
time?: number;
|
||||||
delay?: number;
|
delay?: number;
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
validationHandler: (entry: TimeEntryField, val: number) => boolean;
|
|
||||||
previousEnd?: number;
|
previousEnd?: number;
|
||||||
warning?: string;
|
warning?: string;
|
||||||
}
|
}
|
||||||
@@ -40,17 +39,7 @@ function ButtonTooltip(name: TimeEntryField, warning?: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function TimeInputWithButton(props: TimeInputProps) {
|
export default function TimeInputWithButton(props: TimeInputProps) {
|
||||||
const {
|
const { id, name, submitHandler, time = 0, delay = 0, placeholder, previousEnd = 0, warning } = props;
|
||||||
id,
|
|
||||||
name,
|
|
||||||
submitHandler,
|
|
||||||
time = 0,
|
|
||||||
delay = 0,
|
|
||||||
placeholder,
|
|
||||||
validationHandler,
|
|
||||||
previousEnd = 0,
|
|
||||||
warning,
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
const isDelayed = delay !== 0;
|
const isDelayed = delay !== 0;
|
||||||
const inputClasses = cx([style.timeInput, isDelayed ? style.delayed : null]);
|
const inputClasses = cx([style.timeInput, isDelayed ? style.delayed : null]);
|
||||||
@@ -88,7 +77,6 @@ export default function TimeInputWithButton(props: TimeInputProps) {
|
|||||||
time={time}
|
time={time}
|
||||||
delay={delay}
|
delay={delay}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
validationHandler={validationHandler}
|
|
||||||
previousEnd={previousEnd}
|
previousEnd={previousEnd}
|
||||||
className={style.inputField}
|
className={style.inputField}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ const EventEditorTimes = (props: EventEditorTimesProps) => {
|
|||||||
props;
|
props;
|
||||||
const { updateEvent } = useEventAction();
|
const { updateEvent } = useEventAction();
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = (field: TimeActions, value: number | string | boolean) => {
|
const handleSubmit = (field: TimeActions, value: number | string | boolean) => {
|
||||||
const newEventData: Partial<OntimeEvent> = { id: eventId };
|
const newEventData: Partial<OntimeEvent> = { id: eventId };
|
||||||
switch (field) {
|
switch (field) {
|
||||||
@@ -156,10 +155,8 @@ const EventEditorTimes = (props: EventEditorTimesProps) => {
|
|||||||
id='timeWarning'
|
id='timeWarning'
|
||||||
name='timeWarning'
|
name='timeWarning'
|
||||||
submitHandler={handleSubmit}
|
submitHandler={handleSubmit}
|
||||||
validationHandler={timerValidationHandler}
|
|
||||||
time={timeWarning}
|
time={timeWarning}
|
||||||
placeholder='Duration'
|
placeholder='Duration'
|
||||||
warning={warning.duration}
|
|
||||||
/>
|
/>
|
||||||
<label className={style.inputLabel} htmlFor='timeDanger'>
|
<label className={style.inputLabel} htmlFor='timeDanger'>
|
||||||
Danger Time
|
Danger Time
|
||||||
@@ -168,10 +165,8 @@ const EventEditorTimes = (props: EventEditorTimesProps) => {
|
|||||||
id='timeDanger'
|
id='timeDanger'
|
||||||
name='timeDanger'
|
name='timeDanger'
|
||||||
submitHandler={handleSubmit}
|
submitHandler={handleSubmit}
|
||||||
validationHandler={timerValidationHandler}
|
|
||||||
time={timeDanger}
|
time={timeDanger}
|
||||||
placeholder='Duration'
|
placeholder='Duration'
|
||||||
warning={warning.duration}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user