2024-02-06 22:58:49 +01:00
|
|
|
import slugg from 'slugg';
|
2017-11-11 22:35:41 +01:00
|
|
|
|
2024-12-07 16:16:31 +00:00
|
|
|
const parseOperator = (ctx, zugattrib) => {
|
2025-01-14 19:48:14 +00:00
|
|
|
if (zugattrib?.operatorName) {
|
2025-01-09 12:26:42 +00:00
|
|
|
return {
|
|
|
|
type: 'operator',
|
|
|
|
id: zugattrib.operatorCode,
|
|
|
|
name: zugattrib.operatorName,
|
|
|
|
};
|
|
|
|
}
|
2025-01-14 19:48:14 +00:00
|
|
|
if (!zugattrib || !Array.isArray(zugattrib)) {
|
|
|
|
return null;
|
|
|
|
}
|
2025-01-02 14:00:45 +00:00
|
|
|
const bef = zugattrib.find(z => z.key == 'BEF' || z.key == 'OP');
|
2024-12-07 16:16:31 +00:00
|
|
|
if (!bef) {
|
|
|
|
return null;
|
|
|
|
}
|
2025-01-02 14:00:45 +00:00
|
|
|
const name = bef.value || bef.text;
|
2024-02-06 22:58:49 +01:00
|
|
|
if (!name) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-11-11 22:35:41 +01:00
|
|
|
return {
|
|
|
|
type: 'operator',
|
2025-01-02 14:00:45 +00:00
|
|
|
id: slugg(name.trim()), // todo: find a more reliable way
|
2024-02-06 22:58:49 +01:00
|
|
|
name,
|
|
|
|
};
|
|
|
|
};
|
2017-11-11 22:35:41 +01:00
|
|
|
|
2022-05-07 16:17:37 +02:00
|
|
|
export {
|
|
|
|
parseOperator,
|
2024-02-06 22:58:49 +01:00
|
|
|
};
|