"use client" import { useAccount } from "@/lib/providers/jazz-provider" import { useUser } from "@clerk/nextjs" import { useState, useRef, useCallback } from "react" import { useParams } from "next/navigation" import { Input } from "@/components/ui/input" import { Button } from "@/components/ui/button" import Link from "next/link" import { Avatar, AvatarImage } from "@/components/ui/avatar" interface ProfileStatsProps { number: number label: string } const ProfileStats: React.FC = ({ number, label }) => { return (

{number}

{label}

) } export const ProfileWrapper = () => { const account = useAccount() const params = useParams() const username = params.username as string const { user, isSignedIn } = useUser() const avatarInputRef = useRef(null) const editAvatar = (event: React.ChangeEvent) => { const file = event.target.files?.[0] if (file) { const imageUrl = URL.createObjectURL(file) if (account.me && account.me.profile) { account.me.profile.avatarUrl = imageUrl } } } const [isEditing, setIsEditing] = useState(false) const [newName, setNewName] = useState(account.me?.profile?.name || "") const [error, setError] = useState("") const editProfileClicked = () => { setIsEditing(true) setError("") } const changeName = (e: React.ChangeEvent) => { setNewName(e.target.value) setError("") } const validateName = useCallback((name: string) => { if (name.trim().length < 2) { return "Name must be at least 2 characters long" } if (name.trim().length > 40) { return "Name must not exceed 40 characters" } return "" }, []) const saveProfile = () => { const validationError = validateName(newName) if (validationError) { setError(validationError) return } if (account.me && account.me.profile) { account.me.profile.name = newName.trim() } setIsEditing(false) } const cancelEditing = () => { setNewName(account.me?.profile?.name || "") setIsEditing(false) setError("") } if (!account.me || !account.me.profile) { return (

Oops! This account doesn't exist.

Try searching for another.

The link you followed may be broken, or the page may have been removed. Go back to homepage .

) } return (

Profile

{username}

{isEditing ? ( <> {error &&

{error}

} ) : (

{account.me?.profile?.name}

)}
{isEditing ? (
) : ( )}

Public profiles are coming soon

) }