mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 21:24:11 +00:00
refactor: remove isNextDay block property
This commit is contained in:
committed by
Carlos Valente
parent
ab8bfbcd59
commit
a98c14406d
@@ -6,7 +6,6 @@ import * as Editor from '../../../common/components/editor-utils/EditorUtils';
|
||||
import SwatchSelect from '../../../common/components/input/colour-input/SwatchSelect';
|
||||
import NullableTimeInput from '../../../common/components/input/time-input/NullableTimeInput';
|
||||
import AppLink from '../../../common/components/link/app-link/AppLink';
|
||||
import Switch from '../../../common/components/switch/Switch';
|
||||
import { useEntryActions } from '../../../common/hooks/useEntryAction';
|
||||
import useCustomFields from '../../../common/hooks-query/useCustomFields';
|
||||
import { enDash, timerPlaceholder } from '../../../common/utils/styleUtils';
|
||||
@@ -21,7 +20,6 @@ import style from './EntryEditor.module.scss';
|
||||
// title + colour + custom field labels
|
||||
export type BlockEditorUpdateTextFields = 'targetDuration' | 'title' | 'colour' | string;
|
||||
export type BlockEditorUpdateMaybeNumberFields = 'targetDuration';
|
||||
export type BlockEditorBooleanFields = 'isNextDay';
|
||||
|
||||
interface BlockEditorProps {
|
||||
block: OntimeBlock;
|
||||
@@ -32,10 +30,7 @@ export default function BlockEditor({ block }: BlockEditorProps) {
|
||||
const { updateEntry } = useEntryActions();
|
||||
|
||||
const handleSubmit = useCallback(
|
||||
(
|
||||
field: BlockEditorUpdateTextFields | BlockEditorUpdateMaybeNumberFields | BlockEditorBooleanFields,
|
||||
value: string | boolean,
|
||||
) => {
|
||||
(field: BlockEditorUpdateTextFields | BlockEditorUpdateMaybeNumberFields, value: string | boolean) => {
|
||||
// Handle custom fields
|
||||
if (typeof field === 'string' && field.startsWith('custom-')) {
|
||||
const fieldLabel = field.split('custom-')[1];
|
||||
@@ -51,10 +46,6 @@ export default function BlockEditor({ block }: BlockEditorProps) {
|
||||
return updateEntry({ id: block.id, targetDuration: parseUserTime(value as string) });
|
||||
}
|
||||
|
||||
if (field === 'isNextDay') {
|
||||
return updateEntry({ id: block.id, isNextDay: value as boolean });
|
||||
}
|
||||
|
||||
// all other strings are text fields
|
||||
return updateEntry({ id: block.id, [field]: value as string });
|
||||
},
|
||||
@@ -112,18 +103,6 @@ export default function BlockEditor({ block }: BlockEditorProps) {
|
||||
</TextLikeInput>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Editor.Label htmlFor='isNextDay'>Is next day?</Editor.Label>
|
||||
<Editor.Label className={style.switchLabel}>
|
||||
<Switch
|
||||
checked={block.isNextDay}
|
||||
onCheckedChange={(checked) => {
|
||||
handleSubmit('isNextDay', checked);
|
||||
}}
|
||||
/>
|
||||
{block.isNextDay ? 'Events start the day after' : '-'}
|
||||
</Editor.Label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={style.column}>
|
||||
|
||||
Reference in New Issue
Block a user