mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 03:43:50 +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}>
|
||||
|
||||
@@ -135,7 +135,6 @@ export function createBlockPatch(originalBlock: OntimeBlock, patchBlock: Partial
|
||||
title: makeString(patchBlock.title, originalBlock.title),
|
||||
note: makeString(patchBlock.note, originalBlock.note),
|
||||
entries: patchBlock.entries ?? originalBlock.entries,
|
||||
isNextDay: typeof patchBlock.isNextDay === 'boolean' ? patchBlock.isNextDay : originalBlock.isNextDay,
|
||||
targetDuration: maybeTargetDuration(),
|
||||
colour: makeString(patchBlock.colour, originalBlock.colour),
|
||||
revision: originalBlock.revision,
|
||||
@@ -231,7 +230,6 @@ export function createBlock(patch?: Partial<OntimeBlock>): OntimeBlock {
|
||||
title: patch.title ?? '',
|
||||
note: patch.note ?? '',
|
||||
entries: patch.entries ?? [],
|
||||
isNextDay: patch.isNextDay ?? false,
|
||||
targetDuration: patch.targetDuration ?? null,
|
||||
colour: makeString(patch.colour, ''),
|
||||
custom: patch.custom ?? {},
|
||||
|
||||
@@ -45,7 +45,6 @@ export const demoDb: DatabaseModel = {
|
||||
id: 'block',
|
||||
title: 'Test Block',
|
||||
note: '',
|
||||
isNextDay: false,
|
||||
targetDuration: null,
|
||||
colour: 'hotpink',
|
||||
revision: 0,
|
||||
@@ -212,7 +211,6 @@ export const demoDb: DatabaseModel = {
|
||||
note: '',
|
||||
colour: '',
|
||||
entries: [],
|
||||
isNextDay: false,
|
||||
targetDuration: null,
|
||||
custom: {},
|
||||
revision: 0,
|
||||
@@ -375,7 +373,6 @@ export const demoDb: DatabaseModel = {
|
||||
note: '',
|
||||
colour: '',
|
||||
entries: [],
|
||||
isNextDay: false,
|
||||
targetDuration: null,
|
||||
custom: {},
|
||||
revision: 0,
|
||||
|
||||
@@ -58,7 +58,6 @@ export const block: Omit<OntimeBlock, 'id'> = {
|
||||
title: '',
|
||||
note: '',
|
||||
entries: [],
|
||||
isNextDay: false,
|
||||
targetDuration: null,
|
||||
colour: '',
|
||||
custom: {},
|
||||
|
||||
@@ -37,7 +37,6 @@ export type OntimeBlock = OntimeBaseEvent & {
|
||||
title: string;
|
||||
note: string;
|
||||
entries: EntryId[];
|
||||
isNextDay: boolean;
|
||||
targetDuration: MaybeNumber;
|
||||
colour: string;
|
||||
custom: EntryCustomFields;
|
||||
|
||||
Reference in New Issue
Block a user