Skip to content

Commit

Permalink
polishing avatar page
Browse files Browse the repository at this point in the history
  • Loading branch information
boscohyun committed May 31, 2024
1 parent 519b7ca commit 59d7d9a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pages/[network]/avatar/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface FAV {
}

interface Avatar {
address: string;
name: string;
level: number;
actionPoint: number;
Expand Down Expand Up @@ -58,6 +59,10 @@ const AvatarPage: NextPage<AvatarPageProps> = ({ avatar }) => {
return <h1>There is no avatar.</h1>;
}

if (avatar.name === null || avatar.name === undefined) {
return <h1>Cannot find avatar. ({avatar.address})</h1>;
}

const aggregatedItems = new Map<number, number>();
for (const { itemSheetId, count } of avatar.inventory.items) {
aggregatedItems.set(itemSheetId, (aggregatedItems.get(itemSheetId) || 0) + count);
Expand Down Expand Up @@ -174,6 +179,7 @@ export const getServerSideProps: GetServerSideProps<AvatarPageProps> = async (
return {
props: {
avatar: {
address: avatarJsonObj.address,
name: avatarJsonObj.name,
actionPoint: avatarJsonObj.actionPoint,
level: avatarJsonObj.level,
Expand Down

0 comments on commit 59d7d9a

Please sign in to comment.