Skip to content

Commit d1a747c

Browse files
committed
fix: avatar endpoint not ready - implemented name initials instead
1 parent b92481f commit d1a747c

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

src/components/ui/Avatar.tsx

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import Link from "next/link";
33
import { CSSProperties, ReactElement, useMemo, useState } from "react";
44
import VerifiedIcon from "@/icons/verified.svg";
55
import classNames from "classnames";
6-
6+
import { Submission } from "@/types/bounty";
7+
import { Community } from "@/types/community";
8+
import { Metadata } from "@/types/course";
9+
import { useSelector } from "@/hooks/useTypedSelector";
710
/**
811
* Interface for User
912
* @date 3/22/2023 - 5:42:26 PM
@@ -17,6 +20,32 @@ interface User {
1720
avatar?: string;
1821
}
1922

23+
/**
24+
* Interface for User
25+
* @date 3/22/2023 - 5:42:26 PM
26+
*
27+
* @typedef {User}
28+
*/
29+
30+
interface Certificate {
31+
id: string;
32+
ref: string;
33+
created_at: string;
34+
updated_at: string;
35+
metadata: Metadata;
36+
answer: string;
37+
user_id: string;
38+
course: string;
39+
type: string;
40+
community: Community;
41+
entity: string;
42+
timestamp: number;
43+
description: string;
44+
submission: Submission;
45+
minting: any;
46+
}
47+
48+
2049
/**
2150
* Interface for Avatar component props
2251
* @date 3/22/2023 - 5:42:18 PM
@@ -38,6 +67,7 @@ interface AvatarProps {
3867
isKycVerified?: boolean;
3968
style?: CSSProperties;
4069
className?: string;
70+
achievement?: Certificate | null;
4171
}
4272

4373
/**
@@ -60,6 +90,7 @@ export default function Avatar({
6090
icon,
6191
image,
6292
color,
93+
// achievement = null,
6394
user = null,
6495
size = "small",
6596
shape = "circular",
@@ -70,6 +101,9 @@ export default function Avatar({
70101
}: AvatarProps): ReactElement {
71102
const [userAvatarLoaded, setUserAvatarLoaded] = useState(true);
72103
const initials = user?.displayName ? user?.displayName[0] : null;
104+
const achievement = useSelector((state) => state.profileCertificate.current);
105+
// const achievementInitials = achievement.metadata?.recipientName ? achievement?.metadata?.recipientName[0] : null;
106+
73107

74108
const link = user?.username && useLink ? `/profile/${user.username}` : "#";
75109

@@ -131,6 +165,25 @@ export default function Avatar({
131165
<span>{initials}</span>
132166
)}
133167

168+
{/* { achievement && achievement.metadata.comment ? (
169+
<Image
170+
src={achievement.metadata.image}
171+
alt="user-avatar"
172+
fill={true}
173+
className="object-cover w-full h-full"
174+
onError={() => {
175+
setUserAvatarLoaded(false);
176+
}}
177+
/>
178+
) : (
179+
<span>{achievement?.metadata?.recipientName[0]}</span>
180+
)} */}
181+
182+
{ achievement && achievement.metadata ? (
183+
184+
<span>{achievement?.metadata?.recipientName[0]}</span>
185+
): null }
186+
134187
{icon && <Image fill={true} src={icon} alt="icon image" className="p-2" />}
135188
{image && <Image src={image} fill={true} alt="icon image" className="p-0 object-cover w-full h-full" />}
136189
</div>

src/pages/achievements/[id].tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ const Achievement = () => {
129129
<div className="mt-5 flex flex-col md:gap-6 gap-5">
130130
<AchievementViewItem name={t("profile.achievement.award") as string}>
131131
<div className="inline-flex items-center space-x-2 pr-3 bg-gray-200 p-1 rounded-full">
132-
<Avatar user={user} size="small-fixed" hideVerificationBadge />
132+
{/* <Avatar user={user} size="small-fixed" hideVerificationBadge /> */}
133+
<Avatar achievement={achievement} size="small-fixed" hideVerificationBadge />
133134
<p className="text-sm md:text-base">{achievement?.metadata?.recipientName}</p>
134135
</div>
135136
</AchievementViewItem>

0 commit comments

Comments
 (0)