let's support also entities without spec.type

Signed-off-by: Jan Vilimek <jan.vilimek@oriflame.com>
This commit is contained in:
Jan Vilimek
2021-12-11 12:46:17 +01:00
committed by Jan Vilimek
parent a3ec122170
commit da156f2831
@@ -162,17 +162,15 @@ export const OwnershipCard = ({
const counts = ownedEntitiesList.reduce(
(acc: EntityTypeProps[], ownedEntity) => {
if (typeof ownedEntity.spec?.type !== 'string') return acc;
const match = acc.find(
x => x.kind === ownedEntity.kind && x.type === ownedEntity.spec?.type,
x => x.kind === ownedEntity.kind && x.type === (ownedEntity.spec?.type ?? ownedEntity.kind),
);
if (match) {
match.count += 1;
} else {
acc.push({
kind: ownedEntity.kind,
type: ownedEntity.spec?.type,
type: ownedEntity.spec?.type?.toString() ?? ownedEntity.kind,
count: 1,
});
}