-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/remove_fetch_utils
- Loading branch information
Showing
24 changed files
with
394 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) 2024, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
import { FieldConstants } from '@gridsuite/commons-ui'; | ||
|
||
interface ContingencyList { | ||
[FieldConstants.NAME]: string; | ||
[FieldConstants.EQUIPMENT_TABLE]: Array<{ | ||
[FieldConstants.CONTINGENCY_NAME]: string; | ||
[FieldConstants.EQUIPMENT_IDS]: string[]; | ||
}>; | ||
} | ||
|
||
interface Identifier { | ||
type: 'ID_BASED'; | ||
identifier: string; | ||
} | ||
|
||
interface IdentifierList { | ||
type: 'LIST'; | ||
contingencyId: string; | ||
identifierList: Identifier[]; | ||
} | ||
|
||
interface PrepareContingencyListForBackend { | ||
id: string; | ||
identifierContingencyList: { | ||
type: 'identifier'; | ||
version: string; | ||
name: string; | ||
identifiers: IdentifierList[]; | ||
}; | ||
type: 'IDENTIFIERS'; | ||
} | ||
|
||
export const prepareContingencyListForBackend = ( | ||
id: string, | ||
contingencyList: ContingencyList | ||
): PrepareContingencyListForBackend => { | ||
const identifiersList: IdentifierList[] = contingencyList[FieldConstants.EQUIPMENT_TABLE].map((contingency) => { | ||
const identifierList: Identifier[] = contingency[FieldConstants.EQUIPMENT_IDS].map((identifier) => { | ||
return { | ||
type: 'ID_BASED', | ||
identifier: identifier, | ||
}; | ||
}); | ||
|
||
return { | ||
type: 'LIST', | ||
contingencyId: contingency[FieldConstants.CONTINGENCY_NAME], | ||
identifierList: identifierList, | ||
}; | ||
}); | ||
|
||
return { | ||
id: id, | ||
identifierContingencyList: { | ||
type: 'identifier', | ||
version: '1.2', | ||
name: contingencyList[FieldConstants.NAME], | ||
identifiers: identifiersList, | ||
}, | ||
type: 'IDENTIFIERS', | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
src/components/dialogs/create-study-dialog/create-study-dialog-utils.js
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
src/components/dialogs/create-study-dialog/create-study-dialog-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Copyright (c) 2024, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { ElementAttributes, FieldConstants, Parameter, yup } from '@gridsuite/commons-ui'; | ||
import { UUID } from 'crypto'; | ||
|
||
export const getCreateStudyDialogFormDefaultValues = ({ | ||
directory = '', | ||
studyName = '', | ||
caseFile, | ||
caseUuid, | ||
}: { | ||
directory?: string; | ||
studyName?: string; | ||
caseFile?: ElementAttributes | null; | ||
caseUuid?: UUID; | ||
}): CreateStudyDialogFormValues => { | ||
return { | ||
[FieldConstants.STUDY_NAME]: studyName, | ||
[FieldConstants.DESCRIPTION]: '', | ||
[FieldConstants.CASE_FILE]: caseFile ?? null, | ||
[FieldConstants.CASE_UUID]: caseUuid ?? null, | ||
[FieldConstants.FORMATTED_CASE_PARAMETERS]: [], | ||
[FieldConstants.CURRENT_PARAMETERS]: {}, | ||
[FieldConstants.DIRECTORY]: directory, | ||
[FieldConstants.CASE_FORMAT]: '', | ||
[FieldConstants.CASE_NAME]: '', | ||
}; | ||
}; | ||
|
||
export const createStudyDialogFormValidationSchema = yup.object().shape({ | ||
[FieldConstants.STUDY_NAME]: yup.string().trim().required('nameEmpty'), | ||
[FieldConstants.FORMATTED_CASE_PARAMETERS]: yup.mixed<Parameter[]>().required(), | ||
[FieldConstants.DESCRIPTION]: yup.string().max(500, 'descriptionLimitError'), | ||
[FieldConstants.CURRENT_PARAMETERS]: yup.mixed<Record<string, string>>().required(), | ||
[FieldConstants.CASE_UUID]: yup.string<UUID>().nullable().required(), | ||
[FieldConstants.CASE_FILE]: yup.mixed<ElementAttributes>().nullable().required(), | ||
[FieldConstants.DIRECTORY]: yup.string().required(), | ||
[FieldConstants.CASE_FORMAT]: yup.string().optional(), | ||
[FieldConstants.CASE_NAME]: yup.string().optional(), | ||
}); | ||
|
||
export interface CreateStudyDialogFormValues { | ||
[FieldConstants.STUDY_NAME]: string; | ||
[FieldConstants.DESCRIPTION]?: string; | ||
[FieldConstants.CASE_FILE]: ElementAttributes | null; | ||
[FieldConstants.CASE_UUID]: UUID | null; | ||
[FieldConstants.FORMATTED_CASE_PARAMETERS]: Parameter[]; | ||
[FieldConstants.CURRENT_PARAMETERS]: Record<string, string>; | ||
[FieldConstants.DIRECTORY]: string; | ||
[FieldConstants.CASE_FORMAT]?: string; | ||
[FieldConstants.CASE_NAME]?: string; | ||
} |
Oops, something went wrong.