Skip to content
Draft
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 @@ -9,7 +9,7 @@ import { useCallback } from 'react';
import { SubmitHandler, useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import { Box } from '@mui/material';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';
import { FieldConstants } from '../../../utils/constants/fieldConstants';
import { useSnackMessage } from '../../../hooks/useSnackMessage';
import { CustomMuiDialog } from '../customMuiDialog/CustomMuiDialog';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useCallback, useEffect, useState } from 'react';
import { Grid, Box, Button, CircularProgress, Typography } from '@mui/material';
import { SubmitHandler, useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';
import { TreeViewFinderNodeProps } from '../../treeViewFinder';
import { DescriptionField, RadioInput, UniqueNameInput } from '../../inputs';
import { DirectoryItemSelector } from '../../directoryItemSelector';
Expand Down
2 changes: 1 addition & 1 deletion src/components/filter/FilterCreationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
getExplicitNamingFilterEmptyFormData,
} from './explicitNaming/ExplicitNamingFilterForm';
import { FieldConstants } from '../../utils/constants/fieldConstants';
import yup from '../../utils/yupConfig';
import * as yup from 'yup';

Check failure on line 20 in src/components/filter/FilterCreationDialog.tsx

View workflow job for this annotation

GitHub Actions / build / build

`yup` import should occur before import of `./utils/filterApi`
import { FilterForm } from './FilterForm';
import { expertFilterSchema, getExpertFilterEmptyFormData } from './expert/ExpertFilterForm';
import { FilterType } from './constants/FilterConstants';
Expand Down
2 changes: 1 addition & 1 deletion src/components/filter/HeaderFilterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import type { UUID } from 'node:crypto';
import { ElementType, FieldConstants, MAX_CHAR_DESCRIPTION } from '../../utils';
import { DescriptionField, UniqueNameInput } from '../inputs';
import yup from '../../utils/yupConfig';
import * as yup from 'yup';

Check failure on line 12 in src/components/filter/HeaderFilterForm.tsx

View workflow job for this annotation

GitHub Actions / build / build

`yup` import should occur before import of `../../utils`
import type { MuiStyles } from '../../utils/styles';

export const filterStyles = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/filter/expert/ExpertFilterEditionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { useSnackMessage } from '../../../hooks/useSnackMessage';
import { FetchStatus } from '../../../utils/constants/fetchStatus';
import { FieldConstants } from '../../../utils/constants/fieldConstants';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';

Check failure on line 14 in src/components/filter/expert/ExpertFilterEditionDialog.tsx

View workflow job for this annotation

GitHub Actions / build / build

`yup` import should occur before import of `../../../hooks/useSnackMessage`
import { CustomMuiDialog } from '../../dialogs/customMuiDialog/CustomMuiDialog';
import { FilterType, NO_ITEM_SELECTION_FOR_COPY } from '../constants/FilterConstants';
import { FilterEditionProps } from '../filter.type';
Expand Down
12 changes: 0 additions & 12 deletions src/components/filter/expert/ExpertFilterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ import { filterStyles } from '../HeaderFilterForm';
import { EquipmentType } from '../../../utils';
import { useCustomFormContext } from '../../inputs';

yup.setLocale({
mixed: {
required: 'YupRequired',
notType: ({ type }) => {
if (type === 'number') {
return 'YupNotTypeNumber';
}
return 'YupNotTypeDefault';
},
},
});

function isSupportedEquipmentType(equipmentType: EquipmentType): boolean {
return Object.values(EXPERT_FILTER_EQUIPMENTS)
.map((equipments) => equipments.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { v4 as uuid4 } from 'uuid';
import { useSnackMessage } from '../../../hooks/useSnackMessage';
import { FieldConstants } from '../../../utils/constants/fieldConstants';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';

Check failure on line 15 in src/components/filter/explicitNaming/ExplicitNamingFilterEditionDialog.tsx

View workflow job for this annotation

GitHub Actions / build / build

`yup` import should occur before import of `../../../hooks/useSnackMessage`
import { CustomMuiDialog } from '../../dialogs/customMuiDialog/CustomMuiDialog';
import { saveExplicitNamingFilter } from '../utils/filterApi';
import { explicitNamingFilterSchema } from './ExplicitNamingFilterForm';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { v4 as uuid4 } from 'uuid';
import type { UUID } from 'node:crypto';
import { FieldConstants } from '../../../utils/constants/fieldConstants';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';

Check failure on line 16 in src/components/filter/explicitNaming/ExplicitNamingFilterForm.tsx

View workflow job for this annotation

GitHub Actions / build / build

`yup` import should occur before import of `../../../utils/constants/fieldConstants`
import { CustomAgGridTable } from '../../inputs/reactHookForm/agGridTable/CustomAgGridTable';
import { SelectInput } from '../../inputs/reactHookForm/selectInputs/SelectInput';
import { Generator, Load } from '../../../utils/types/equipmentTypes';
Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/reactHookForm/numbers/RangeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { type ObjectSchema } from 'yup';
import { FormControl, Grid, InputLabel } from '@mui/material';
import { FloatInput } from './FloatInput';
import yup from '../../../../utils/yupConfig';
import * as yup from 'yup';

Check failure on line 13 in src/components/inputs/reactHookForm/numbers/RangeInput.tsx

View workflow job for this annotation

GitHub Actions / build / build

`yup` import should occur before import of `./FloatInput`
import { MuiSelectInput } from '../selectInputs/MuiSelectInput';
import { FieldConstants } from '../../../../utils/constants/fieldConstants';
import type { MuiStyles } from '../../../../utils/styles';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { array, boolean, object, string } from 'yup';
import {
DUPLICATED_PROPS_ERROR,
FieldConstants,
isBlankOrEmpty,
PredefinedProperties,
YUP_REQUIRED,
} from '../../../../utils';
import { DUPLICATED_PROPS_ERROR, FieldConstants, isBlankOrEmpty, PredefinedProperties } from '../../../../utils';
import { fetchStudyMetadata } from '../../../../services';
import { FilledProperty, Properties, Property } from './properties.type';

Expand Down Expand Up @@ -178,11 +172,11 @@ export const creationPropertiesSchema = object({
[FieldConstants.ADDITIONAL_PROPERTIES]: array()
.of(
object().shape({
[FieldConstants.NAME]: string().required(YUP_REQUIRED),
[FieldConstants.VALUE]: string().required(YUP_REQUIRED),
[FieldConstants.NAME]: string().required(),
[FieldConstants.VALUE]: string().required(),
[FieldConstants.PREVIOUS_VALUE]: string().nullable(),
[FieldConstants.DELETION_MARK]: boolean().required(YUP_REQUIRED),
[FieldConstants.ADDED]: boolean().required(YUP_REQUIRED),
[FieldConstants.DELETION_MARK]: boolean().required(),
[FieldConstants.ADDED]: boolean().required(),
})
)
.test('checkUniqueProperties', DUPLICATED_PROPS_ERROR, (values) => checkUniquePropertyNames(values)),
Expand All @@ -192,16 +186,16 @@ export const modificationPropertiesSchema = object({
[FieldConstants.ADDITIONAL_PROPERTIES]: array()
.of(
object().shape({
[FieldConstants.NAME]: string().required(YUP_REQUIRED),
[FieldConstants.NAME]: string().required(),
[FieldConstants.VALUE]: string()
.nullable()
.when([FieldConstants.ADDED], {
is: (added: boolean) => added,
then: (schema) => schema.required(YUP_REQUIRED),
then: (schema) => schema.required(),
}),
[FieldConstants.PREVIOUS_VALUE]: string().nullable(),
[FieldConstants.DELETION_MARK]: boolean().required(YUP_REQUIRED),
[FieldConstants.ADDED]: boolean().required(YUP_REQUIRED),
[FieldConstants.DELETION_MARK]: boolean().required(),
[FieldConstants.ADDED]: boolean().required(),
})
)
.test('checkUniqueProperties', DUPLICATED_PROPS_ERROR, (values) => checkUniquePropertyNames(values)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
sanitizeString,
UNDEFINED_CONNECTION_DIRECTION,
UNDEFINED_LOAD_TYPE,
YUP_REQUIRED,
} from '../../../../utils';
import {
getConnectivityFormDataProps,
Expand All @@ -29,15 +28,15 @@ import { LoadCreationDto } from './loadCreation.types';

export const loadCreationFormSchema = object()
.shape({
[FieldConstants.EQUIPMENT_ID]: string().required(YUP_REQUIRED),
[FieldConstants.EQUIPMENT_ID]: string().required(),
[FieldConstants.EQUIPMENT_NAME]: string().nullable(),
[FieldConstants.LOAD_TYPE]: string().nullable(),
[FieldConstants.ACTIVE_POWER_SET_POINT]: number().nullable().required(YUP_REQUIRED),
[FieldConstants.REACTIVE_POWER_SET_POINT]: number().nullable().required(YUP_REQUIRED),
[FieldConstants.ACTIVE_POWER_SET_POINT]: number().nullable().required(),
[FieldConstants.REACTIVE_POWER_SET_POINT]: number().nullable().required(),
[FieldConstants.CONNECTIVITY]: getConnectivityWithPositionSchema(false),
})
.concat(creationPropertiesSchema)
.required(YUP_REQUIRED);
.required();

export type LoadCreationFormData = InferType<typeof loadCreationFormSchema>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getFilledPropertiesFromModification,
toModificationProperties,
} from '../../common/properties/propertyUtils';
import { FieldConstants, ModificationType, sanitizeString, YUP_REQUIRED } from '../../../../utils';
import { FieldConstants, ModificationType, sanitizeString } from '../../../../utils';
import { SubstationCreationDto } from './substationCreation.types';

export const substationCreationFormToDto = (substationForm: SubstationCreationFormData): SubstationCreationDto => {
Expand All @@ -34,12 +34,12 @@ export const substationCreationDtoToForm = (substationDto: SubstationCreationDto

export const substationCreationFormSchema = object()
.shape({
[FieldConstants.EQUIPMENT_ID]: string().required(YUP_REQUIRED),
[FieldConstants.EQUIPMENT_ID]: string().required(),
[FieldConstants.EQUIPMENT_NAME]: string().nullable(),
[FieldConstants.COUNTRY]: string().nullable(),
})
.concat(creationPropertiesSchema)
.required(YUP_REQUIRED);
.required();

export type SubstationCreationFormData = InferType<typeof substationCreationFormSchema>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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 yup from '../../../../utils/yupConfig';
import * as yup from 'yup';
import {
getPropertiesFromModification,
modificationPropertiesSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { array, object, string } from 'yup';
import { FieldConstants, YUP_REQUIRED } from '../../../../../../utils';
import { FieldConstants } from '../../../../../../utils';

export const getSwitchTypeSchema = () =>
object().shape({
[FieldConstants.SWITCH_KIND]: string().nullable().required(YUP_REQUIRED),
[FieldConstants.SWITCH_KIND]: string().nullable().required(),
});

export const getCreateSwitchesValidationSchema = (id = FieldConstants.SWITCH_KINDS) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
getPropertiesFromModification,
toModificationProperties,
} from '../../common/properties/propertyUtils';
import { FieldConstants, sanitizeString, YUP_REQUIRED } from '../../../../utils';
import { FieldConstants, sanitizeString } from '../../../../utils';
import { convertInputValue, convertOutputValue } from '../../../../utils/conversionUtils';
import { FieldType } from '../../../../utils/types/fieldType';
import { MODIFICATION_TYPES } from '../../../../utils/types/modificationType';
Expand Down Expand Up @@ -44,7 +44,7 @@ export const getCreateSwitchesValidationSchema = (id = FieldConstants.SWITCH_KIN
.nullable()
.of(
object().shape({
[FieldConstants.SWITCH_KIND]: string().nullable().required(YUP_REQUIRED),
[FieldConstants.SWITCH_KIND]: string().nullable().required(),
})
),
};
Expand All @@ -57,7 +57,7 @@ export const getCreateSwitchesEmptyFormData = (sectionCount: number, id = FieldC
export const voltageLevelCreationFormSchema = object()
.shape({
[FieldConstants.EQUIPMENT_ID]: string()
.required(YUP_REQUIRED)
.required()
.when([FieldConstants.ADD_SUBSTATION_CREATION], {
is: (addSubstationCreation: boolean) => !addSubstationCreation,
then: (schema) =>
Expand All @@ -75,14 +75,14 @@ export const voltageLevelCreationFormSchema = object()
),
}),
[FieldConstants.EQUIPMENT_NAME]: string().nullable(),
[FieldConstants.ADD_SUBSTATION_CREATION]: boolean().required(YUP_REQUIRED),
[FieldConstants.ADD_SUBSTATION_CREATION]: boolean().required(),
[FieldConstants.SUBSTATION_ID]: string()
.nullable()
.when([FieldConstants.ADD_SUBSTATION_CREATION], {
is: (addSubstationCreation: boolean) => !addSubstationCreation,
then: (schema) =>
schema
.required(YUP_REQUIRED)
.required()
.notOneOf(
[ref(FieldConstants.EQUIPMENT_ID), null],
'CreateSubstationInVoltageLevelIdenticalId'
Expand All @@ -94,7 +94,7 @@ export const voltageLevelCreationFormSchema = object()
is: (addSubstationCreation: boolean) => addSubstationCreation,
then: (schema) =>
schema
.required(YUP_REQUIRED)
.required()
.notOneOf(
[ref(FieldConstants.EQUIPMENT_ID), null],
'CreateSubstationInVoltageLevelIdenticalId'
Expand All @@ -103,12 +103,12 @@ export const voltageLevelCreationFormSchema = object()
[FieldConstants.SUBSTATION_NAME]: string().nullable(),
[FieldConstants.COUNTRY]: string().nullable(),
[FieldConstants.SUBSTATION_CREATION]: creationPropertiesSchema,
[FieldConstants.HIDE_NOMINAL_VOLTAGE]: boolean().required(YUP_REQUIRED),
[FieldConstants.HIDE_NOMINAL_VOLTAGE]: boolean().required(),
[FieldConstants.NOMINAL_V]: number()
.nullable()
.when([FieldConstants.HIDE_NOMINAL_VOLTAGE], {
is: (hideNominalVoltage: boolean) => !hideNominalVoltage,
then: (schema) => schema.min(0, 'mustBeGreaterOrEqualToZero').required(YUP_REQUIRED),
then: (schema) => schema.min(0, 'mustBeGreaterOrEqualToZero').required(),
}),
[FieldConstants.LOW_VOLTAGE_LIMIT]: number()
.nullable()
Expand All @@ -124,39 +124,39 @@ export const voltageLevelCreationFormSchema = object()
.min(0, 'ShortCircuitCurrentLimitMustBeGreaterOrEqualToZero')
.when([FieldConstants.LOW_SHORT_CIRCUIT_CURRENT_LIMIT], {
is: (lowShortCircuitCurrentLimit: number | null) => lowShortCircuitCurrentLimit != null,
then: (schema) => schema.required(YUP_REQUIRED),
then: (schema) => schema.required(),
}),
[FieldConstants.HIDE_BUS_BAR_SECTION]: boolean().required(YUP_REQUIRED),
[FieldConstants.HIDE_BUS_BAR_SECTION]: boolean().required(),
[FieldConstants.BUS_BAR_COUNT]: number()
.nullable()
.when([FieldConstants.HIDE_BUS_BAR_SECTION], {
is: (hideBusBarSection: boolean) => !hideBusBarSection,
then: (schema) => schema.min(1, 'BusBarCountMustBeGreaterThanOrEqualToOne').required(YUP_REQUIRED),
then: (schema) => schema.min(1, 'BusBarCountMustBeGreaterThanOrEqualToOne').required(),
}),
[FieldConstants.SECTION_COUNT]: number()
.nullable()
.when([FieldConstants.HIDE_BUS_BAR_SECTION], {
is: (hideBusBarSection: boolean) => !hideBusBarSection,
then: (schema) => schema.min(1, 'SectionCountMustBeGreaterThanOrEqualToOne').required(YUP_REQUIRED),
then: (schema) => schema.min(1, 'SectionCountMustBeGreaterThanOrEqualToOne').required(),
}),
[FieldConstants.SWITCHES_BETWEEN_SECTIONS]: string()
.nullable()
.when([FieldConstants.SECTION_COUNT], {
is: (sectionCount: number) => sectionCount > 1,
then: (schema) => schema.required(YUP_REQUIRED),
then: (schema) => schema.required(),
}),
[FieldConstants.SWITCH_KINDS]: array().of(
object().shape({
[FieldConstants.SWITCH_KIND]: string().required(YUP_REQUIRED),
[FieldConstants.SWITCH_KIND]: string().required(),
})
),
[FieldConstants.TOPOLOGY_KIND]: string().nullable(),
[FieldConstants.COUPLING_OMNIBUS]: array().of(
object().shape({
[FieldConstants.BUS_BAR_SECTION_ID1]: string().nullable().required(YUP_REQUIRED),
[FieldConstants.BUS_BAR_SECTION_ID1]: string().nullable().required(),
[FieldConstants.BUS_BAR_SECTION_ID2]: string()
.nullable()
.required(YUP_REQUIRED)
.required()
.notOneOf([ref(FieldConstants.BUS_BAR_SECTION_ID1), null], 'CreateCouplingDeviceIdenticalBusBar'),
})
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { Parameters, ColumnsDef, ID, NAME, DESCRIPTION, ACTIVATED } from '../parameter-table';
import { ElementType } from '../../../../utils';
import { CONTINGENCY_LISTS_INFOS, CONTINGENCY_LISTS } from '../constants';
import yup from '../../../../utils/yupConfig';
import * as yup from 'yup';

Check failure on line 10 in src/components/parameters/common/contingency-table/columns-definitions.ts

View workflow job for this annotation

GitHub Actions / build / build

`yup` import should occur before import of `../parameter-table`
import { IdName, ContingencyListsInfos } from './types';

export const COLUMNS_DEFINITIONS_CONTINGENCY_LISTS_INFOS: ColumnsDef[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { NumberSchema } from 'yup';
import yup from '../../../../utils/yupConfig';
import * as yup from 'yup';

export const LIMIT_REDUCTIONS_FORM = 'limitReductionsForm';
export const VOLTAGE_LEVELS_FORM = 'voltageLevelsForm';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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 yup from '../../../../utils/yupConfig';
import * as yup from 'yup';
import { DESCRIPTION, NAME } from '../../../inputs';

export function getNameElementEditorEmptyFormData(
Expand Down
2 changes: 1 addition & 1 deletion src/components/parameters/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
SpecificParametersValues,
} from '../../../utils';
import { SPECIFIC_PARAMETERS } from './constants';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';

Check failure on line 18 in src/components/parameters/common/utils.ts

View workflow job for this annotation

GitHub Actions / build / build

`yup` import should occur before import of `../../../utils`

export const getSpecificParametersFormSchema = (specificParameters: SpecificParameterInfos[] | undefined) => {
const shape: { [key: string]: yup.AnySchema } = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { useMemo } from 'react';
import { useIntl } from 'react-intl';
import { Grid, SxProps } from '@mui/material';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';
import {
ACCURACY,
ACTIVE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { Grid } from '@mui/material';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';
import {
LOAD_INCREASE_START_TIME,
LOAD_INCREASE_STOP_TIME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { FieldValues, useForm } from 'react-hook-form';
import { useEffect, useMemo } from 'react';
import { yupResolver } from '@hookform/resolvers/yup';
import yup from '../../../utils/yupConfig';
import * as yup from 'yup';
import { DynamicMarginCalculationParametersInfos } from '../../../utils/types/dynamic-margin-calculation.type';
import { emptyFormData as timeDelayEmptyFormData, formSchema as timeDelayFormSchema } from './time-delay-parameters';
import {
Expand Down
Loading
Loading