Skip to content

Commit e869f3d

Browse files
authored
Merge pull request #262 from codeunia-dev/feat/profilepicture
feat(users): Enhance profile picture display and preview functionality
2 parents 6c66c2f + d973fe5 commit e869f3d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

components/users/ProfilePictureUpload.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export function ProfilePictureUpload({
3131
const [showCropper, setShowCropper] = useState(false)
3232
const fileInputRef = useRef<HTMLInputElement>(null)
3333

34+
// Update preview when currentAvatarUrl changes
35+
React.useEffect(() => {
36+
setPreviewUrl(currentAvatarUrl || null)
37+
}, [currentAvatarUrl])
38+
3439
const getInitials = () => {
3540
if (firstName && lastName) {
3641
return `${firstName[0]}${lastName[0]}`

components/users/PublicProfileView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useAuth } from '@/lib/hooks/useAuth'
55
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'
66
import { Badge } from '@/components/ui/badge'
77
import { Button } from '@/components/ui/button'
8-
import { Avatar, AvatarFallback } from '@/components/ui/avatar'
8+
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
99
import { ContributionGraph } from '@/components/ui/contribution-graph'
1010
import { useContributionGraph } from '@/hooks/useContributionGraph'
1111
import { usePublicProfileByUsername } from '@/hooks/useProfile'
@@ -149,6 +149,7 @@ export function PublicProfileView({ username }: PublicProfileViewProps) {
149149
<CardHeader>
150150
<div className="flex flex-col sm:flex-row gap-6 items-start sm:items-center">
151151
<Avatar className="w-20 h-20 sm:w-24 sm:h-24">
152+
{profile.avatar_url && <AvatarImage src={profile.avatar_url} alt={getFullName()} />}
152153
<AvatarFallback className="text-2xl font-bold bg-gradient-to-br from-blue-500 to-purple-600 text-white">
153154
{getInitials()}
154155
</AvatarFallback>
@@ -232,6 +233,7 @@ export function PublicProfileView({ username }: PublicProfileViewProps) {
232233
<CardHeader>
233234
<div className="flex flex-col sm:flex-row gap-6 items-start sm:items-center">
234235
<Avatar className="w-20 h-20 sm:w-24 sm:h-24">
236+
{profile.avatar_url && <AvatarImage src={profile.avatar_url} alt={getFullName()} />}
235237
<AvatarFallback className="text-2xl font-bold bg-gradient-to-br from-blue-500 to-purple-600 text-white">
236238
{getInitials()}
237239
</AvatarFallback>

0 commit comments

Comments
 (0)