databag/net/web/src/context/cardUtil.js

21 lines
495 B
JavaScript
Raw Normal View History

2023-01-11 06:10:05 +00:00
export function getCardByGuid(cards, guid) {
let card = null;
cards.forEach((value, key, map) => {
2023-01-11 06:10:05 +00:00
if(value?.data?.cardProfile?.guid === guid) {
card = value;
}
});
return card;
}
export function getProfileByGuid(cards, guid) {
const card = getCardByGuid(cards, guid);
2023-01-11 06:10:05 +00:00
if (card?.data?.cardProfile) {
2023-01-25 18:56:43 +00:00
const { name, handle, imageSet, node } = card.data.cardProfile;
2023-01-11 06:10:05 +00:00
const cardId = card.id;
2023-01-25 18:56:43 +00:00
return { cardId, name, handle, imageSet, node }
2023-01-11 06:10:05 +00:00
}
return {};
}