@@ -13,7 +13,7 @@ import { useOpenShortWaitFetching } from 'components/dialogs/commons/handle-modi
1313import { FORM_LOADING_DELAY } from 'components/network/constants.js' ;
1414import { TABULAR_PROPERTIES , MODIFICATIONS_TABLE , CSV_FILENAME , TYPE } from 'components/utils/field-constants.js' ;
1515import { ModificationDialog } from 'components/dialogs/commons/modificationDialog.js' ;
16- import { createTabularCreation , createTabularModification } from 'services/study/network-modifications.js' ;
16+ import { createTabularModification } from 'services/study/network-modifications.js' ;
1717import { FetchStatus } from 'services/utils.type' ;
1818import {
1919 convertGeneratorOrBatteryModificationFromBackToFront ,
@@ -32,9 +32,7 @@ import {
3232 Modification ,
3333 tabularFormSchema ,
3434 TabularFormType ,
35- TabularModificationCreationType ,
3635 TabularModificationEditDataType ,
37- TabularModificationModificationType ,
3836 TabularModificationType ,
3937 transformProperties ,
4038} from './tabular-common.js' ;
@@ -51,12 +49,12 @@ import { NetworkModificationDialogProps } from '../../../graph/menus/network-mod
5149function convertCreations ( creations : Modification [ ] ) : Modification [ ] {
5250 return creations . map ( ( creat : Modification ) => {
5351 let creation : Modification = { } ;
54- Object . keys ( formatModification ( creat ) ) . forEach ( ( key ) => {
52+ for ( const key of Object . keys ( formatModification ( creat ) ) ) {
5553 const entry = convertCreationFieldFromBackToFront ( key , creat [ key ] ) ;
56- ( Array . isArray ( entry ) ? entry : [ entry ] ) . forEach ( ( item ) => {
54+ for ( const item of Array . isArray ( entry ) ? entry : [ entry ] ) {
5755 creation [ item . key ] = item . value ;
58- } ) ;
59- } ) ;
56+ }
57+ }
6058 creation = addPropertiesFromBack ( creation , creat ?. [ TABULAR_PROPERTIES ] ) ;
6159 return creation ;
6260 } ) ;
@@ -98,7 +96,7 @@ export function TabularDialog({
9896 const disableSave = Object . keys ( errors ) . length > 0 ;
9997
10098 const initTabularModificationData = useCallback (
101- ( editData : TabularModificationModificationType ) => {
99+ ( editData : TabularModificationEditDataType ) => {
102100 const modificationType = editData . modificationType ;
103101 const modifications = editData . modifications . map ( ( modif : Modification ) => {
104102 let modification = formatModification ( modif ) ;
@@ -108,9 +106,9 @@ export function TabularDialog({
108106 ) {
109107 modification = convertGeneratorOrBatteryModificationFromBackToFront ( modification ) ;
110108 } else {
111- Object . keys ( modification ) . forEach ( ( key ) => {
109+ for ( const key of Object . keys ( modification ) ) {
112110 modification [ key ] = convertInputValues ( getFieldType ( modificationType , key ) , modif [ key ] ) ;
113- } ) ;
111+ }
114112 }
115113 modification = addPropertiesFromBack ( modification , modif ?. [ TABULAR_PROPERTIES ] ) ;
116114 return modification ;
@@ -126,9 +124,9 @@ export function TabularDialog({
126124 ) ;
127125
128126 const initTabularCreationData = useCallback (
129- ( editData : TabularModificationCreationType ) => {
130- const equipmentType = getEquipmentTypeFromCreationType ( editData ?. creationType ) ;
131- const creations = convertCreations ( editData ?. creations ) ;
127+ ( editData : TabularModificationEditDataType ) => {
128+ const equipmentType = getEquipmentTypeFromCreationType ( editData ?. modificationType ) ;
129+ const creations = convertCreations ( editData ?. modifications ) ;
132130 reset ( {
133131 [ TYPE ] : equipmentType ,
134132 [ MODIFICATIONS_TABLE ] : creations ,
@@ -142,9 +140,9 @@ export function TabularDialog({
142140 useEffect ( ( ) => {
143141 if ( editData ) {
144142 if ( dialogMode === TabularModificationType . CREATION ) {
145- initTabularCreationData ( editData as TabularModificationCreationType ) ;
143+ initTabularCreationData ( editData ) ;
146144 } else {
147- initTabularModificationData ( editData as TabularModificationModificationType ) ;
145+ initTabularModificationData ( editData ) ;
148146 }
149147 }
150148 } , [ editData , dialogMode , initTabularCreationData , initTabularModificationData ] ) ;
@@ -162,7 +160,7 @@ export function TabularDialog({
162160 modificationType,
163161 modifications,
164162 modificationUuid : editData ?. uuid ,
165- type : ModificationType . TABULAR_MODIFICATION ,
163+ tabularType : ModificationType . TABULAR_MODIFICATION ,
166164 csvFilename : formData [ CSV_FILENAME ] ,
167165 properties : formData [ TABULAR_PROPERTIES ] ,
168166 } ) . catch ( ( error ) => {
@@ -177,21 +175,24 @@ export function TabularDialog({
177175
178176 const submitTabularCreation = useCallback (
179177 ( formData : TabularFormType ) => {
180- const creationType = TABULAR_CREATION_TYPES [ formData [ TYPE ] ] ;
181- const creations = formData [ MODIFICATIONS_TABLE ] ?. map ( ( row ) => {
178+ const modificationType = TABULAR_CREATION_TYPES [ formData [ TYPE ] ] ;
179+ const modifications = formData [ MODIFICATIONS_TABLE ] ?. map ( ( row ) => {
182180 const creation : Modification = {
183- type : creationType ,
181+ type : modificationType ,
184182 } ;
185183 // first transform and clean "property_*" fields
186184 const propertiesModifications = transformProperties ( row ) ;
187185
188186 // then transform all other fields
189- Object . keys ( row ) . forEach ( ( key ) => {
187+ for ( const key of Object . keys ( row ) ) {
190188 const entry = convertCreationFieldFromFrontToBack ( key , row [ key ] ) ;
191189 creation [ entry . key ] = entry . value ;
192- } ) ;
190+ }
193191 // For now, we do not manage reactive limits by diagram
194- if ( creationType === 'GENERATOR_CREATION' || creationType === 'BATTERY_CREATION' ) {
192+ if (
193+ modificationType === ModificationType . GENERATOR_CREATION ||
194+ modificationType === ModificationType . BATTERY_CREATION
195+ ) {
195196 convertReactiveCapabilityCurvePointsFromFrontToBack ( creation ) ;
196197 }
197198
@@ -200,12 +201,13 @@ export function TabularDialog({
200201 }
201202 return creation ;
202203 } ) ;
203- createTabularCreation ( {
204+ createTabularModification ( {
204205 studyUuid,
205206 nodeUuid : currentNodeUuid ,
206- creationType ,
207- creations ,
207+ modificationType ,
208+ modifications ,
208209 modificationUuid : editData ?. uuid ,
210+ tabularType : ModificationType . TABULAR_CREATION ,
209211 csvFilename : formData [ CSV_FILENAME ] ,
210212 properties : formData [ TABULAR_PROPERTIES ] ,
211213 } ) . catch ( ( error ) => {
0 commit comments