@@ -17,26 +17,12 @@ import VoltageLevelModificationDialog from 'components/dialogs/network-modificat
17
17
import { type FunctionComponent , type ReactElement , useCallback , useMemo , useState } from 'react' ;
18
18
import { useSelector } from 'react-redux' ;
19
19
import { type AppState } from 'redux/reducer' ;
20
- import { SpreadsheetEquipmentType } from '../../../types/spreadsheet.type' ;
20
+ import { type EditableEquipmentType , SpreadsheetEquipmentType } from '../../../types/spreadsheet.type' ;
21
21
22
22
export type UseEquipmentModificationProps = {
23
23
equipmentType : SpreadsheetEquipmentType ;
24
24
} ;
25
25
26
- type EditableEquipmentType = Exclude <
27
- SpreadsheetEquipmentType ,
28
- | SpreadsheetEquipmentType . BRANCH
29
- | SpreadsheetEquipmentType . BUS
30
- | SpreadsheetEquipmentType . BUSBAR_SECTION
31
- | SpreadsheetEquipmentType . DANGLING_LINE
32
- | SpreadsheetEquipmentType . HVDC_LINE
33
- | SpreadsheetEquipmentType . LCC_CONVERTER_STATION
34
- | SpreadsheetEquipmentType . STATIC_VAR_COMPENSATOR
35
- | SpreadsheetEquipmentType . THREE_WINDINGS_TRANSFORMER
36
- | SpreadsheetEquipmentType . TIE_LINE
37
- | SpreadsheetEquipmentType . VSC_CONVERTER_STATION
38
- > ;
39
-
40
26
const EQUIPMENT_DIALOG_MAPPING : Readonly < Record < EditableEquipmentType , FunctionComponent < any > > > = {
41
27
[ SpreadsheetEquipmentType . SUBSTATION ] : SubstationModificationDialog ,
42
28
[ SpreadsheetEquipmentType . VOLTAGE_LEVEL ] : VoltageLevelModificationDialog ,
@@ -52,7 +38,7 @@ function isEditableEquipmentType(type: SpreadsheetEquipmentType): type is Editab
52
38
return type in EQUIPMENT_DIALOG_MAPPING ;
53
39
}
54
40
55
- export function useEquipmentModification ( { equipmentType } : UseEquipmentModificationProps ) {
41
+ export function useEquipmentModification ( { equipmentType } : Readonly < UseEquipmentModificationProps > ) {
56
42
const [ modificationDialog , setModificationDialog ] = useState < ReactElement | null > ( null ) ;
57
43
58
44
const currentNode = useSelector ( ( state : AppState ) => state . currentTreeNode ) ;
@@ -80,7 +66,7 @@ export function useEquipmentModification({ equipmentType }: UseEquipmentModifica
80
66
if ( ! isEditableEquipmentType ( equipmentType ) ) {
81
67
return null ;
82
68
}
83
- return createDialogWithProps ( EQUIPMENT_DIALOG_MAPPING [ equipmentType as EditableEquipmentType ] , equipmentId ) ;
69
+ return createDialogWithProps ( EQUIPMENT_DIALOG_MAPPING [ equipmentType ] , equipmentId ) ;
84
70
} ,
85
71
[ createDialogWithProps , equipmentType ]
86
72
) ;
0 commit comments