|
13 | 13 | */ |
14 | 14 |
|
15 | 15 | import type { Options } from "@/components/fieldEditors/SelectFE"; |
16 | | -import type { TableModeColumnsForType, TableModeType } from "@/services/api/tablemode/types"; |
17 | | - |
18 | | -//////////////////////////////////////////////////////////////// |
19 | | -// Types |
20 | | -//////////////////////////////////////////////////////////////// |
21 | | - |
22 | | -type TableModeColumnsByType = { |
23 | | - [K in TableModeType]: TableModeColumnsForType<K>; |
24 | | -}; |
25 | | - |
26 | | -//////////////////////////////////////////////////////////////// |
27 | | -// Constants |
28 | | -//////////////////////////////////////////////////////////////// |
29 | | - |
30 | | -const TABLE_MODE_TYPES = [ |
31 | | - "areas", |
32 | | - "links", |
33 | | - "thermals", |
34 | | - "renewables", |
35 | | - "st-storages", |
36 | | - "binding-constraints", |
37 | | - "st-storages-additional-constraints", |
38 | | -] as const satisfies TableModeType[]; |
39 | | - |
40 | | -const TABLE_MODE_COLUMNS_BY_TYPE = { |
41 | | - areas: [ |
42 | | - "nonDispatchPower", |
43 | | - "dispatchHydroPower", |
44 | | - "otherDispatchPower", |
45 | | - "energyCostUnsupplied", |
46 | | - "spreadUnsuppliedEnergyCost", |
47 | | - "energyCostSpilled", |
48 | | - "spreadSpilledEnergyCost", |
49 | | - "filterSynthesis", |
50 | | - "filterByYear", |
51 | | - // Since v8.3 |
52 | | - "adequacyPatchMode", |
53 | | - ], |
54 | | - links: [ |
55 | | - "hurdlesCost", |
56 | | - "loopFlow", |
57 | | - "usePhaseShifter", |
58 | | - "transmissionCapacities", |
59 | | - "assetType", |
60 | | - "linkStyle", |
61 | | - "linkWidth", |
62 | | - "comments", |
63 | | - "displayComments", |
64 | | - "filterSynthesis", |
65 | | - "filterYearByYear", |
66 | | - ], |
67 | | - thermals: [ |
68 | | - "group", |
69 | | - "enabled", |
70 | | - "unitCount", |
71 | | - "nominalCapacity", |
72 | | - "genTs", |
73 | | - "minStablePower", |
74 | | - "minUpTime", |
75 | | - "minDownTime", |
76 | | - "mustRun", |
77 | | - "spinning", |
78 | | - "volatilityForced", |
79 | | - "volatilityPlanned", |
80 | | - "lawForced", |
81 | | - "lawPlanned", |
82 | | - "marginalCost", |
83 | | - "spreadCost", |
84 | | - "fixedCost", |
85 | | - "startupCost", |
86 | | - "marketBidCost", |
87 | | - "co2", |
88 | | - // Since v8.6 |
89 | | - "nh3", |
90 | | - "so2", |
91 | | - "nox", |
92 | | - "pm25", |
93 | | - "pm5", |
94 | | - "pm10", |
95 | | - "nmvoc", |
96 | | - "op1", |
97 | | - "op2", |
98 | | - "op3", |
99 | | - "op4", |
100 | | - "op5", |
101 | | - // Since v8.7 |
102 | | - "costGeneration", |
103 | | - "efficiency", |
104 | | - "variableOMCost", |
105 | | - ], |
106 | | - renewables: [ |
107 | | - // Since v8.1 |
108 | | - "group", |
109 | | - "enabled", |
110 | | - "tsInterpretation", |
111 | | - "unitCount", |
112 | | - "nominalCapacity", |
113 | | - ], |
114 | | - "st-storages": [ |
115 | | - // Since v8.6 |
116 | | - "group", |
117 | | - "injectionNominalCapacity", |
118 | | - "withdrawalNominalCapacity", |
119 | | - "reservoirCapacity", |
120 | | - "efficiency", |
121 | | - "initialLevel", |
122 | | - "initialLevelOptim", |
123 | | - // Since v8.8 |
124 | | - "enabled", |
125 | | - // Since v9.2 |
126 | | - "efficiencyWithdrawal", |
127 | | - "penalizeVariationInjection", |
128 | | - "penalizeVariationWithdrawal", |
129 | | - ], |
130 | | - "binding-constraints": [ |
131 | | - "enabled", |
132 | | - "timeStep", |
133 | | - "operator", |
134 | | - "comments", |
135 | | - // Since v8.3 |
136 | | - "filterSynthesis", |
137 | | - "filterYearByYear", |
138 | | - // Since v8.7 |
139 | | - "group", |
140 | | - ], |
141 | | - "st-storages-additional-constraints": [ |
142 | | - // Since v9.2 |
143 | | - "variable", |
144 | | - "operator", |
145 | | - "enabled", |
146 | | - ], |
147 | | -} as const satisfies TableModeColumnsByType; |
148 | | - |
149 | | -export const tableModeTypeOptions = TABLE_MODE_TYPES.map((type) => ({ |
| 16 | +import { |
| 17 | + areaColumnsSchema, |
| 18 | + bindingConstraintColumnsSchema, |
| 19 | + linkColumnsSchema, |
| 20 | + renewableColumnsSchema, |
| 21 | + stStorageAdditionalConstraintColumnsSchema, |
| 22 | + stStorageColumnsSchema, |
| 23 | + tableModeTypeSchema, |
| 24 | + thermalColumnsSchema, |
| 25 | +} from "@/services/api/tablemode/schemas"; |
| 26 | +import type { TableModeType } from "@/services/api/tablemode/types"; |
| 27 | + |
| 28 | +export const tableModeTypeOptions = tableModeTypeSchema.options.map((type) => ({ |
150 | 29 | value: type, |
151 | 30 | label: (t) => t(`tableMode.type.${type}`), |
152 | 31 | })) satisfies Options<TableModeType>; |
153 | 32 |
|
154 | | -//////////////////////////////////////////////////////////////// |
155 | | -// Functions |
156 | | -//////////////////////////////////////////////////////////////// |
157 | | - |
158 | 33 | export function getTableColumnsForType<T extends TableModeType>(type: T) { |
159 | | - return TABLE_MODE_COLUMNS_BY_TYPE[type]; |
| 34 | + switch (type) { |
| 35 | + case "areas": |
| 36 | + return areaColumnsSchema.element.options; |
| 37 | + case "links": |
| 38 | + return linkColumnsSchema.element.options; |
| 39 | + case "thermals": |
| 40 | + return thermalColumnsSchema.element.options; |
| 41 | + case "renewables": |
| 42 | + return renewableColumnsSchema.element.options; |
| 43 | + case "st-storages": |
| 44 | + return stStorageColumnsSchema.element.options; |
| 45 | + case "binding-constraints": |
| 46 | + return bindingConstraintColumnsSchema.element.options; |
| 47 | + case "st-storages-additional-constraints": |
| 48 | + return stStorageAdditionalConstraintColumnsSchema.element.options; |
| 49 | + default: |
| 50 | + return []; |
| 51 | + } |
160 | 52 | } |
0 commit comments