From eae7a1db0b1ea14fe1dd42ae8c260da078282ddf Mon Sep 17 00:00:00 2001 From: Brandon Fancher Date: Mon, 11 Apr 2022 13:26:00 -0400 Subject: [PATCH] Don't crash webapp when displaying resigned members in election stats. --- packages/webapp/src/members/helpers/formatters.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/webapp/src/members/helpers/formatters.ts b/packages/webapp/src/members/helpers/formatters.ts index 98285b6ce..58527c737 100644 --- a/packages/webapp/src/members/helpers/formatters.ts +++ b/packages/webapp/src/members/helpers/formatters.ts @@ -10,14 +10,19 @@ export const formatMembersQueryNodeAsMemberNFT = ( data: MembersQueryNode ): MemberNFT | undefined => { if (!data) return; + + if (!data.profile) { + console.info(`${data.account} has since resigned`); + } + return { createdAt: data.createdAt ? new Date(data.createdAt).getTime() : 0, account: data.account, - name: data.profile.name, - image: data.profile.img, - attributions: data.profile.attributions, - bio: data.profile.bio, - socialHandles: JSON.parse(data.profile.social), + name: data.profile?.name ?? data.account, + image: data.profile?.img, + attributions: data.profile?.attributions, + bio: data.profile?.bio, + socialHandles: data.profile ? JSON.parse(data.profile.social) : {}, inductionVideo: data.inductionVideo, }; };