Skip to content

Commit 330f563

Browse files
authored
fix order for lines creation catalog (#3203)
Signed-off-by: Etienne LESOT <[email protected]>
1 parent 2802980 commit 330f563

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/components/dialogs/line-types-catalog/line-types-catalog-selector-dialog.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,25 @@ export default function LineTypesCatalogSelectorDialog({
168168
return [];
169169
}
170170

171-
const uniqueAreas = [...new Set(limitsData.map((limit) => limit.area))];
172-
return uniqueAreas.map((area) => ({ id: area, label: area }));
171+
return [...new Set(limitsData.map((limit) => limit.area))]
172+
.toSorted((a, b) => a.localeCompare(b, undefined, { numeric: true }))
173+
.map((area) => ({ id: area, label: area }));
173174
};
174175

175176
const createOptionsFromTemperatures = (limitsData?: CurrentLimitsInfo[]) => {
176177
if (!limitsData?.length) {
177178
return [];
178179
}
179180

180-
const uniqueTemperatures = [...new Set(limitsData.map((limit) => limit.temperature))];
181-
return uniqueTemperatures.map((temp) => ({ id: temp, label: temp }));
181+
return [...new Set(limitsData.map((limit) => limit.temperature))]
182+
.toSorted((a, b) => a.localeCompare(b, undefined, { numeric: true }))
183+
.map((temp) => ({ id: temp, label: temp }));
182184
};
183185

184186
const createOptionsFromUndergroundShapeFactors = (lineInfo: LineTypeInfo): Option[] => {
185-
return lineInfo.shapeFactors.map((shapeFactor) => ({ id: String(shapeFactor), label: String(shapeFactor) }));
187+
return lineInfo.shapeFactors
188+
.toSorted((a, b) => a - b)
189+
.map((shapeFactor) => ({ id: String(shapeFactor), label: String(shapeFactor) }));
186190
};
187191

188192
const handleSelectedRowData = useCallback(

0 commit comments

Comments
 (0)