Skip to content

Commit

Permalink
refactor: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
Devessier committed Dec 12, 2024
1 parent 23e6e26 commit 83abb94
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ type DraftValue =
value: string;
};

// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
function assertStaticDraftValue(
draftValue: DraftValue,
): asserts draftValue is DraftValue & { type: 'static' } {
if (draftValue.type !== 'static') {
throw new Error('Expected the draftValue to be static');
}
}

type FormDateFieldInputProps = {
label?: string;
defaultValue: string | undefined;
Expand Down Expand Up @@ -131,10 +122,9 @@ export const FormDateFieldInput = ({
};

const handlePickerChange = (newDate: Nullable<Date>) => {
assertStaticDraftValue(draftValue);

setDraftValue({
...draftValue,
type: 'static',
editingMode: 'edit',
value: newDate?.toDateString() ?? null,
});

Expand Down

0 comments on commit 83abb94

Please sign in to comment.