chore: cleanup

This commit is contained in:
Carlos Valente
2024-01-05 21:57:47 +01:00
parent cb23b83b9d
commit 3753d51d85
3 changed files with 1 additions and 43 deletions
@@ -18,20 +18,6 @@ interface TimeInputProps {
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) {
const { id, name, submitHandler, time = 0, delay = 0, placeholder, previousEnd = 0, className } = props;
const { emitError } = useEmitLog();
@@ -152,19 +138,8 @@ export default function TimeInput(props: TimeInputProps) {
resetValue();
}, [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 TooltipLabel = useMemo(() => {
return ButtonTooltip(name, '');
}, [name]);
const ButtonText = useMemo(() => {
return ButtonInitial(name);
}, [name]);
return (
<Input
size='sm'
@@ -16,7 +16,6 @@ interface TimeInputProps {
time?: number;
delay?: number;
placeholder: string;
validationHandler: (entry: TimeEntryField, val: number) => boolean;
previousEnd?: number;
warning?: string;
}
@@ -40,17 +39,7 @@ function ButtonTooltip(name: TimeEntryField, warning?: string) {
}
export default function TimeInputWithButton(props: TimeInputProps) {
const {
id,
name,
submitHandler,
time = 0,
delay = 0,
placeholder,
validationHandler,
previousEnd = 0,
warning,
} = props;
const { id, name, submitHandler, time = 0, delay = 0, placeholder, previousEnd = 0, warning } = props;
const isDelayed = delay !== 0;
const inputClasses = cx([style.timeInput, isDelayed ? style.delayed : null]);
@@ -88,7 +77,6 @@ export default function TimeInputWithButton(props: TimeInputProps) {
time={time}
delay={delay}
placeholder={placeholder}
validationHandler={validationHandler}
previousEnd={previousEnd}
className={style.inputField}
/>
@@ -40,7 +40,6 @@ const EventEditorTimes = (props: EventEditorTimesProps) => {
props;
const { updateEvent } = useEventAction();
const handleSubmit = (field: TimeActions, value: number | string | boolean) => {
const newEventData: Partial<OntimeEvent> = { id: eventId };
switch (field) {
@@ -156,10 +155,8 @@ const EventEditorTimes = (props: EventEditorTimesProps) => {
id='timeWarning'
name='timeWarning'
submitHandler={handleSubmit}
validationHandler={timerValidationHandler}
time={timeWarning}
placeholder='Duration'
warning={warning.duration}
/>
<label className={style.inputLabel} htmlFor='timeDanger'>
Danger Time
@@ -168,10 +165,8 @@ const EventEditorTimes = (props: EventEditorTimesProps) => {
id='timeDanger'
name='timeDanger'
submitHandler={handleSubmit}
validationHandler={timerValidationHandler}
time={timeDanger}
placeholder='Duration'
warning={warning.duration}
/>
</div>
</div>