diff --git a/src/components/dialogs/contingency-list/creation/contingency-list-creation-dialog.jsx b/src/components/dialogs/contingency-list/creation/contingency-list-creation-dialog.jsx index c8e54a22..29da8d51 100644 --- a/src/components/dialogs/contingency-list/creation/contingency-list-creation-dialog.jsx +++ b/src/components/dialogs/contingency-list/creation/contingency-list-creation-dialog.jsx @@ -12,12 +12,12 @@ import { getCriteriaBasedSchema, PARAM_LANGUAGE, useSnackMessage, + yup, } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; -import { yupResolver } from '@hookform/resolvers/yup/dist/yup'; +import { yupResolver } from '@hookform/resolvers/yup'; import ContingencyListCreationForm from './contingency-list-creation-form'; import { getContingencyListEmptyFormData, getFormContent } from '../contingency-list-utils'; -import yup from '../../../utils/yup-config'; import { getExplicitNamingSchema } from '../explicit-naming/explicit-naming-form'; import { ContingencyListType } from '../../../../utils/elementType'; import { useParameterState } from '../../parameters-dialog'; diff --git a/src/components/dialogs/contingency-list/edition/criteria-based/criteria-based-edition-dialog.jsx b/src/components/dialogs/contingency-list/edition/criteria-based/criteria-based-edition-dialog.jsx index b86297ef..8dedf57d 100644 --- a/src/components/dialogs/contingency-list/edition/criteria-based/criteria-based-edition-dialog.jsx +++ b/src/components/dialogs/contingency-list/edition/criteria-based/criteria-based-edition-dialog.jsx @@ -11,15 +11,15 @@ import { getCriteriaBasedSchema, PARAM_LANGUAGE, useSnackMessage, + yup, } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; -import { yupResolver } from '@hookform/resolvers/yup/dist/yup'; +import { yupResolver } from '@hookform/resolvers/yup'; import { useEffect, useState } from 'react'; import { getContingencyListEmptyFormData, getCriteriaBasedFormDataFromFetchedElement, } from '../../contingency-list-utils'; -import yup from 'components/utils/yup-config'; import CriteriaBasedEditionForm from './criteria-based-edition-form'; import { useDispatch, useSelector } from 'react-redux'; import { noSelectionForCopy } from 'utils/constants'; diff --git a/src/components/dialogs/contingency-list/edition/explicit-naming/explicit-naming-edition-dialog.jsx b/src/components/dialogs/contingency-list/edition/explicit-naming/explicit-naming-edition-dialog.jsx index 341cc237..4774266e 100644 --- a/src/components/dialogs/contingency-list/edition/explicit-naming/explicit-naming-edition-dialog.jsx +++ b/src/components/dialogs/contingency-list/edition/explicit-naming/explicit-naming-edition-dialog.jsx @@ -5,15 +5,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomMuiDialog, FieldConstants, useSnackMessage } from '@gridsuite/commons-ui'; +import { CustomMuiDialog, FieldConstants, useSnackMessage, yup } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; -import { yupResolver } from '@hookform/resolvers/yup/dist/yup'; +import { yupResolver } from '@hookform/resolvers/yup'; import { useEffect, useState } from 'react'; import { getContingencyListEmptyFormData, getExplicitNamingFormDataFromFetchedElement, } from '../../contingency-list-utils'; -import yup from 'components/utils/yup-config'; import { getExplicitNamingEditSchema } from '../../explicit-naming/explicit-naming-form'; import ExplicitNamingEditionForm from './explicit-naming-edition-form'; import { prepareContingencyListForBackend } from 'components/dialogs/contingency-list-helper'; diff --git a/src/components/dialogs/contingency-list/edition/script/script-edition-dialog.jsx b/src/components/dialogs/contingency-list/edition/script/script-edition-dialog.jsx index d814a21f..fcc78823 100644 --- a/src/components/dialogs/contingency-list/edition/script/script-edition-dialog.jsx +++ b/src/components/dialogs/contingency-list/edition/script/script-edition-dialog.jsx @@ -5,12 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { CustomMuiDialog, FieldConstants, useSnackMessage } from '@gridsuite/commons-ui'; +import { CustomMuiDialog, FieldConstants, useSnackMessage, yup } from '@gridsuite/commons-ui'; import { useForm } from 'react-hook-form'; -import { yupResolver } from '@hookform/resolvers/yup/dist/yup'; +import { yupResolver } from '@hookform/resolvers/yup'; import { useEffect, useState } from 'react'; import { getContingencyListEmptyFormData, getScriptFormDataFromFetchedElement } from '../../contingency-list-utils'; -import yup from 'components/utils/yup-config'; import ScriptEditionForm from './script-edition-form'; import { useDispatch, useSelector } from 'react-redux'; import { noSelectionForCopy } from 'utils/constants'; diff --git a/src/components/dialogs/contingency-list/explicit-naming/explicit-naming-form.jsx b/src/components/dialogs/contingency-list/explicit-naming/explicit-naming-form.jsx index 0852d8fa..cf6e6b07 100644 --- a/src/components/dialogs/contingency-list/explicit-naming/explicit-naming-form.jsx +++ b/src/components/dialogs/contingency-list/explicit-naming/explicit-naming-form.jsx @@ -7,12 +7,17 @@ import { useIntl } from 'react-intl'; import React, { useCallback, useMemo } from 'react'; -import yup from '../../../utils/yup-config'; import { makeDefaultRowData } from '../contingency-list-utils'; import ChipsArrayEditor from '../../../utils/rhf-inputs/ag-grid-table-rhf/cell-editors/chips-array-editor'; import { ContingencyListType } from 'utils/elementType'; import { v4 as uuid4 } from 'uuid'; -import { FieldConstants, gridItem, CustomAgGridTable, ROW_DRAGGING_SELECTION_COLUMN_DEF } from '@gridsuite/commons-ui'; +import { + CustomAgGridTable, + FieldConstants, + gridItem, + ROW_DRAGGING_SELECTION_COLUMN_DEF, + yup, +} from '@gridsuite/commons-ui'; export const getExplicitNamingSchema = (id) => { return { diff --git a/src/components/dialogs/copy-to-script-dialog.tsx b/src/components/dialogs/copy-to-script-dialog.tsx index fba7b6af..8440c774 100644 --- a/src/components/dialogs/copy-to-script-dialog.tsx +++ b/src/components/dialogs/copy-to-script-dialog.tsx @@ -6,11 +6,10 @@ */ import { FunctionComponent, useCallback, useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; -import yup from 'components/utils/yup-config'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { CircularProgress, Grid } from '@mui/material'; -import { CustomMuiDialog, ElementType, FieldConstants, UniqueNameInput } from '@gridsuite/commons-ui'; +import { CustomMuiDialog, ElementType, FieldConstants, UniqueNameInput, yup } from '@gridsuite/commons-ui'; import { useSelector } from 'react-redux'; import { UUID } from 'crypto'; import { AppState } from '../../redux/reducer'; diff --git a/src/components/dialogs/create-case-dialog/create-case-dialog-utils.ts b/src/components/dialogs/create-case-dialog/create-case-dialog-utils.ts index 78f01fc6..a1d50b57 100644 --- a/src/components/dialogs/create-case-dialog/create-case-dialog-utils.ts +++ b/src/components/dialogs/create-case-dialog/create-case-dialog-utils.ts @@ -5,8 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import yup from '../../utils/yup-config'; -import { FieldConstants } from '@gridsuite/commons-ui'; +import { FieldConstants, yup } from '@gridsuite/commons-ui'; export const getCreateCaseDialogFormValidationDefaultValues = () => ({ [FieldConstants.CASE_NAME]: '', diff --git a/src/components/dialogs/create-case-dialog/create-case-dialog.tsx b/src/components/dialogs/create-case-dialog/create-case-dialog.tsx index 747f528c..33fcd87c 100644 --- a/src/components/dialogs/create-case-dialog/create-case-dialog.tsx +++ b/src/components/dialogs/create-case-dialog/create-case-dialog.tsx @@ -12,7 +12,7 @@ import { Grid } from '@mui/material'; import { addUploadingElement, removeUploadingElement } from '../../../redux/actions'; import UploadNewCase from '../commons/upload-new-case'; import { useForm } from 'react-hook-form'; -import { yupResolver } from '@hookform/resolvers/yup/dist/yup'; +import { yupResolver } from '@hookform/resolvers/yup'; import { createCaseDialogFormValidationSchema, getCreateCaseDialogFormValidationDefaultValues, diff --git a/src/components/dialogs/create-study-dialog/create-study-dialog-utils.js b/src/components/dialogs/create-study-dialog/create-study-dialog-utils.js index bd425dbe..313769d1 100644 --- a/src/components/dialogs/create-study-dialog/create-study-dialog-utils.js +++ b/src/components/dialogs/create-study-dialog/create-study-dialog-utils.js @@ -5,8 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import yup from '../../utils/yup-config'; -import { FieldConstants } from '@gridsuite/commons-ui'; +import { FieldConstants, yup } from '@gridsuite/commons-ui'; export const getCreateStudyDialogFormDefaultValues = ({ directory = '', diff --git a/src/components/dialogs/create-study-dialog/create-study-dialog.jsx b/src/components/dialogs/create-study-dialog/create-study-dialog.jsx index 61ed02e6..e1b29d3c 100644 --- a/src/components/dialogs/create-study-dialog/create-study-dialog.jsx +++ b/src/components/dialogs/create-study-dialog/create-study-dialog.jsx @@ -29,7 +29,7 @@ import { createStudyDialogFormValidationSchema, getCreateStudyDialogFormDefaultValues, } from './create-study-dialog-utils'; -import { yupResolver } from '@hookform/resolvers/yup/dist/yup'; +import { yupResolver } from '@hookform/resolvers/yup'; import PrefilledNameInput from '../commons/prefilled-name-input'; import { handleMaxElementsExceededError } from '../../utils/rest-errors'; import { caseSrv, exploreSrv, networkConversionSrv } from '../../../services'; diff --git a/src/components/utils/yup-config.js b/src/components/utils/yup-config.js deleted file mode 100644 index 4209b421..00000000 --- a/src/components/utils/yup-config.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2023, 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 * as yup from 'yup'; - -yup.setLocale({ - mixed: { - required: 'YupRequired', - notType: ({ type }) => { - if (type === 'number') { - return 'YupNotTypeNumber'; - } else { - return 'YupNotTypeDefault'; - } - }, - }, -}); - -export default yup;