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

21 lines
483 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) {
const { name, handle, imageSet } = card.data.cardProfile;
const cardId = card.id;
return { cardId, name, handle, imageSet }
2023-01-11 06:10:05 +00:00
}
return {};
}