filter out unknown mappers (#1559)
This commit is contained in:
parent
119fac0916
commit
bb46594d84
1 changed files with 24 additions and 16 deletions
|
@ -56,22 +56,30 @@ export const MapperList = ({
|
|||
setAddMapperDialogOpen(!addMapperDialogOpen);
|
||||
};
|
||||
|
||||
const loader = async () =>
|
||||
Promise.resolve(
|
||||
(mapperList || [])
|
||||
.map((mapper) => {
|
||||
const mapperType = mapperTypes.filter(
|
||||
(type) => type.id === mapper.protocolMapper
|
||||
)[0];
|
||||
return {
|
||||
...mapper,
|
||||
category: mapperType.category,
|
||||
type: mapperType.name,
|
||||
priority: mapperType.priority,
|
||||
} as Row;
|
||||
})
|
||||
.sort((a, b) => a.priority - b.priority)
|
||||
);
|
||||
const loader = async () => {
|
||||
if (!mapperList) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const list = mapperList.reduce<Row[]>((rows, mapper) => {
|
||||
const mapperType = mapperTypes.find(
|
||||
({ id }) => id === mapper.protocolMapper
|
||||
);
|
||||
|
||||
if (!mapperType) {
|
||||
return rows;
|
||||
}
|
||||
|
||||
return rows.concat({
|
||||
...mapper,
|
||||
category: mapperType.category,
|
||||
type: mapperType.name,
|
||||
priority: mapperType.priority,
|
||||
});
|
||||
}, []);
|
||||
|
||||
return list.sort((a, b) => a.priority - b.priority);
|
||||
};
|
||||
|
||||
const MapperLink = ({ id, name }: Row) => (
|
||||
<Link to={detailLink(id!)}>{name}</Link>
|
||||
|
|
Loading…
Reference in a new issue