fix: names corrections for multiple units

This commit is contained in:
2025-05-02 19:30:19 +02:00
parent 4a96ed3852
commit 93acfdb780
4 changed files with 51 additions and 47 deletions
+23 -7
View File
@@ -1,3 +1,11 @@
const unitNameCorrections: Record<string, string[]> = {
'2EN57': ['EN57', 'EN57'],
'201E': ['ET22'],
'4E': ['EU07'],
M62: ['ST44'],
CTLR4C: ['ST44']
};
export const getRegionNameById = (id: string) => {
switch (id) {
case 'eu':
@@ -20,10 +28,18 @@ export const getRegionNameById = (id: string) => {
}
};
export const unitNameCorrections: Record<string, string> = {
'2EN57': 'EN57',
'201E': 'ET22',
'4E': 'EU07',
M62: 'ST44',
CTLR4C: 'ST44',
};
export function getHeadUnits(stockString: string) {
const stockList = stockString.split(';').slice(0, 3);
return stockList.reduce((acc, unitType, i) => {
if (i != 0 && !/-\d+$/.test(unitType)) return acc;
const unitName = unitType.slice(0, unitType.indexOf('-'));
const correctedNames = unitNameCorrections[unitName] ?? [unitName];
acc.push(...correctedNames);
return acc;
}, [] as string[]);
}