@@ -13,8 +13,9 @@ type UserProfileProps = {
13
13
songData : SongPreviewDto [ ] | null ;
14
14
} ;
15
15
16
- const UserProfile = ( { userData, songData } : UserProfileProps ) => {
17
- const { lastSeen, username, description, profileImage } = userData ;
16
+ export const UserProfile = ( { userData, songData } : UserProfileProps ) => {
17
+ const { lastSeen, username, description, profileImage, socialLinks } =
18
+ userData ;
18
19
19
20
return (
20
21
< div className = 'max-w-screen-lg mx-auto' >
@@ -23,7 +24,7 @@ const UserProfile = ({ userData, songData }: UserProfileProps) => {
23
24
< div className = 'flex items-center gap-8' >
24
25
< Image
25
26
src = { profileImage }
26
- alt = { username }
27
+ alt = { `Profile picture of ${ username } ` }
27
28
className = 'w-32 h-32 rounded-full'
28
29
width = { 128 }
29
30
height = { 128 }
@@ -38,29 +39,30 @@ const UserProfile = ({ userData, songData }: UserProfileProps) => {
38
39
{ /* Username/handle */ }
39
40
< p className = 'text-zinc-400 my-1' >
40
41
< span className = 'font-black text-zinc-200' > { `@${ username } ` } </ span >
41
- { ` • 5 songs • 2,534 plays` }
42
+ { ` • ${ songData ?. length || 0 } songs • 2,534 plays` } { ' ' }
43
+ { /* Dynamic song count */ }
42
44
</ p >
43
45
44
46
{ /* Description */ }
45
47
< p className = 'text-zinc-400 my-1 line-clamp-3' >
46
- Hello! This is my user description.
48
+ { description || 'No description available.' } { ' ' }
49
+ { /* Dynamic description */ }
47
50
</ p >
48
51
49
52
{ /* Social links */ }
50
53
< div className = 'flex-grow flex flex-row gap-1.5 mt-4' >
51
- < UserSocialIcon icon = 'twitter' href = '#' />
52
- < UserSocialIcon icon = 'youtube' href = '#' />
53
- < UserSocialIcon icon = 'github' href = '#' />
54
- < UserSocialIcon icon = 'discord' href = '#' />
55
- < UserSocialIcon icon = 'patreon' href = '#' />
54
+ { Object . entries ( socialLinks ) . map ( ( [ key , value ] , i ) => (
55
+ < UserSocialIcon key = { i } icon = { key } href = { value } />
56
+ ) ) }
56
57
</ div >
57
58
</ div >
59
+
58
60
< div className = 'flex-grow' > </ div >
61
+
59
62
< div >
60
63
{ /* Joined */ }
61
64
< p className = 'text-zinc-500' > Joined</ p >
62
65
< p className = 'font-bold text-zinc-400 mb-4' >
63
- { /* TODO: lastSeen is supposed to be a date, but it's a string */ }
64
66
{ new Date ( lastSeen ) . toLocaleDateString ( 'en-UK' ) }
65
67
< span className = 'font-normal text-zinc-400' > { ` (${ formatTimeAgo (
66
68
new Date ( lastSeen ) ,
@@ -70,7 +72,6 @@ const UserProfile = ({ userData, songData }: UserProfileProps) => {
70
72
{ /* Last seen */ }
71
73
< p className = 'text-zinc-500' > Last seen</ p >
72
74
< p className = 'font-bold text-zinc-400' >
73
- { /* TODO: lastSeen is supposed to be a date, but it's a string */ }
74
75
{ new Date ( lastSeen ) . toLocaleDateString ( 'en-UK' ) }
75
76
< span className = 'font-normal text-zinc-400' > { ` (${ formatTimeAgo (
76
77
new Date ( lastSeen ) ,
@@ -85,14 +86,16 @@ const UserProfile = ({ userData, songData }: UserProfileProps) => {
85
86
{ /* UPLOADED SONGS */ }
86
87
< section >
87
88
< h2 className = 'flex-1 text-xl uppercase mb-4 text-zinc-200' > Songs</ h2 >
88
- < SongCardGroup >
89
- { songData ?. map ( ( song , i ) => (
90
- < SongCard key = { i } song = { song } />
91
- ) ) }
92
- </ SongCardGroup >
89
+ { songData ? (
90
+ < SongCardGroup >
91
+ { songData . map ( ( song , i ) => (
92
+ < SongCard key = { i } song = { song } />
93
+ ) ) }
94
+ </ SongCardGroup >
95
+ ) : (
96
+ < p className = 'text-zinc-400' > No songs uploaded yet.</ p >
97
+ ) }
93
98
</ section >
94
99
</ div >
95
100
) ;
96
101
} ;
97
-
98
- export default UserProfile ;
0 commit comments