- Timestamp:
- 01/26/26 20:19:20 (6 months ago)
- Branches:
- main
- Children:
- d47e225
- Parents:
- fd81a18
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/components/userProfile/UserDetailView.tsx
rfd81a18 ra3ae097 48 48 const navigate = useNavigate(); 49 49 const [user, setUser] = useState<User | null>(null); 50 const [error, setError] = useState<string | null>(null); 50 51 51 52 useEffect(() => { 52 53 const fetchUser = async () => { 53 console.log(userId); 54 const response = await fetch(`http://localhost:8080/users/${userId}`); 55 const data = await response.json(); 56 console.log("Fetched user data:", data); 57 setUser(data); 54 setError(null); 55 try { 56 const response = await fetch(`http://localhost:8080/users/${userId}`); 57 58 if (!response.ok) { 59 const errorData = await response.json(); 60 throw new Error(errorData.error || "Failed to fetch user"); 61 } 62 63 const data = await response.json(); 64 setUser(data); 65 } catch (err: any) { 66 setError(err.message); 67 } 58 68 }; 59 69 fetchUser(); 60 70 }, [userId]); 71 72 if (error) { 73 return ( 74 <div className="p-6 bg-red-50 border border-red-200 text-red-700 rounded-lg"> 75 <h2 className="font-bold">Error</h2> 76 <p>{error}</p> 77 </div> 78 ); 79 } 61 80 62 81 if (!user) return <div className="p-6">Loading...</div>; … … 72 91 73 92 <div className="bg-white shadow-lg rounded-lg p-8"> 74 {/* Profile Header */}75 93 <div className="flex items-start gap-6 mb-8"> 76 {/* Profile Photo */}77 94 <div className="shrink-0"> 78 95 <div className="w-32 h-32 rounded-full bg-linear-to-br from-blue-400 to-purple-500 flex items-center justify-center text-white text-4xl font-bold shadow-lg"> … … 81 98 </div> 82 99 83 {/* User Info */}84 100 <div className="flex-1"> 85 101 <h1 className="text-4xl font-bold mb-2">{user.fullName}</h1> … … 88 104 </span> 89 105 90 {/* Followers/Following Stats */}91 106 <div className="flex gap-6 mb-4 text-gray-700"> 92 107 <div className="flex flex-col">
Note:
See TracChangeset
for help on using the changeset viewer.
