@@ -3,7 +3,10 @@ import Link from "next/link";
3
3
import { CSSProperties , ReactElement , useMemo , useState } from "react" ;
4
4
import VerifiedIcon from "@/icons/verified.svg" ;
5
5
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" ;
7
10
/**
8
11
* Interface for User
9
12
* @date 3/22/2023 - 5:42:26 PM
@@ -17,6 +20,32 @@ interface User {
17
20
avatar ?: string ;
18
21
}
19
22
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
+
20
49
/**
21
50
* Interface for Avatar component props
22
51
* @date 3/22/2023 - 5:42:18 PM
@@ -38,6 +67,7 @@ interface AvatarProps {
38
67
isKycVerified ?: boolean ;
39
68
style ?: CSSProperties ;
40
69
className ?: string ;
70
+ achievement ?: Certificate | null ;
41
71
}
42
72
43
73
/**
@@ -60,6 +90,7 @@ export default function Avatar({
60
90
icon,
61
91
image,
62
92
color,
93
+ // achievement = null,
63
94
user = null ,
64
95
size = "small" ,
65
96
shape = "circular" ,
@@ -70,6 +101,9 @@ export default function Avatar({
70
101
} : AvatarProps ) : ReactElement {
71
102
const [ userAvatarLoaded , setUserAvatarLoaded ] = useState ( true ) ;
72
103
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
+
73
107
74
108
const link = user ?. username && useLink ? `/profile/${ user . username } ` : "#" ;
75
109
@@ -131,6 +165,25 @@ export default function Avatar({
131
165
< span > { initials } </ span >
132
166
) }
133
167
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
+
134
187
{ icon && < Image fill = { true } src = { icon } alt = "icon image" className = "p-2" /> }
135
188
{ image && < Image src = { image } fill = { true } alt = "icon image" className = "p-0 object-cover w-full h-full" /> }
136
189
</ div >
0 commit comments