Skip to content

Commit 6e98cb9

Browse files
committed
Case import : compute base name from case-server instead of front computation
1 parent c057c95 commit 6e98cb9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/components/dialogs/commons/upload-new-case.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Button, CircularProgress, Grid, Input } from '@mui/material';
1111
import { useController, useFormContext } from 'react-hook-form';
1212
import { FieldConstants } from '@gridsuite/commons-ui';
1313
import { UUID } from 'crypto';
14-
import { createCaseWithoutDirectoryElementCreation, deleteCase } from '../../../utils/rest-api';
14+
import { createCaseWithoutDirectoryElementCreation, deleteCase, getBaseName } from '../../../utils/rest-api';
1515

1616
export interface UploadNewCaseProps {
1717
isNewStudyCreation?: boolean;
@@ -99,14 +99,16 @@ export default function UploadNewCase({
9999
const caseName = getValues(FieldConstants.CASE_NAME);
100100
if (currentCaseFileName && caseName !== currentCaseFileName) {
101101
clearErrors(FieldConstants.CASE_NAME);
102-
setValue(
103-
FieldConstants.CASE_NAME,
104-
currentCaseFileName.substring(0, currentCaseFileName.indexOf('.')),
105-
{
106-
shouldDirty: true,
107-
shouldValidate: true,
108-
}
109-
);
102+
getBaseName(currentCaseFileName)
103+
.then((response) => {
104+
setValue(FieldConstants.CASE_NAME, response, {
105+
shouldDirty: true,
106+
shouldValidate: true,
107+
});
108+
})
109+
.catch((error) => {
110+
console.error('Error fetching file base name:', error);
111+
});
110112
}
111113
}
112114
} else {

0 commit comments

Comments
 (0)