Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,16 @@ export function LimitSetsTabularModificationForm({ dataFetching }: Readonly<Tabu
return commentData;
}, [intl, csvTranslatedColumns, language]);

const handleChangeType = useCallback(() => {
clearErrors(MODIFICATIONS_TABLE);
tableRef.current?.replace([]);
const resetFileStateOnTypeChange = useCallback(() => {
setValue(CSV_FILENAME, undefined);
setSelectedFile(undefined);
setFileErrorMessage(undefined);
}, [clearErrors, setValue]);
}, [setValue]);

const resetFormStateOnTypeChange = useCallback(() => {
clearErrors(MODIFICATIONS_TABLE);
tableRef.current?.replace([]);
}, [clearErrors]);

const csvFilename = getValues(CSV_FILENAME);

Expand All @@ -225,7 +228,8 @@ export function LimitSetsTabularModificationForm({ dataFetching }: Readonly<Tabu
size={'small'}
formProps={{ variant: 'outlined' }}
shouldOpenPopup={() => hasNonEmptyRows(getValues(MODIFICATIONS_TABLE))}
resetOnConfirmation={handleChangeType}
resetOnChange={resetFileStateOnTypeChange}
resetOnConfirmation={resetFormStateOnTypeChange}
message="changeTypeMessage"
validateButtonLabel="button.changeType"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,17 @@ export function TabularForm({ dataFetching, dialogMode }: Readonly<TabularFormPr
);
}, [dialogMode]);

const handleChangeType = useCallback(() => {
clearErrors(MODIFICATIONS_TABLE);
tableRef.current?.replace([]);
const resetFileStateOnTypeChange = useCallback(() => {
setValue(CSV_FILENAME, undefined);
setValue(TABULAR_PROPERTIES, []);
setSelectedFile(undefined);
setFileErrorMessage(undefined);
setFileWarningMessage(undefined);
}, [setValue]);

const resetFormStateOnTypeChange = useCallback(() => {
clearErrors(MODIFICATIONS_TABLE);
tableRef.current?.replace([]);
setValue(TABULAR_PROPERTIES, []);
}, [clearErrors, setValue]);

const equipmentTypeField = (
Expand All @@ -433,7 +436,8 @@ export function TabularForm({ dataFetching, dialogMode }: Readonly<TabularFormPr
size={'small'}
formProps={{ variant: 'outlined' }}
shouldOpenPopup={() => hasNonEmptyRows(getValues(MODIFICATIONS_TABLE))}
resetOnConfirmation={handleChangeType}
resetOnChange={resetFileStateOnTypeChange}
resetOnConfirmation={resetFormStateOnTypeChange}
message="changeTypeMessage"
validateButtonLabel="button.changeType"
/>
Expand Down
Loading