- Timestamp:
- 01/27/26 12:55:23 (6 months ago)
- Branches:
- main
- Children:
- 4e5cf92
- Parents:
- c6e1892
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/components/userProfile/UserDetailView.tsx
rc6e1892 r0f71490 3 3 import ArtistView from "./ArtistView"; 4 4 import ListenerView from "./ListenerView"; 5 6 interface MusicalEntityDTO { 7 id: number; 8 title: string; 9 genre: string; 10 type: string; 11 } 12 13 interface ArtistContributionDTO { 14 musicalEntityId: number; 15 title: string; 16 role: string; 17 entityType: string; 18 } 19 20 interface Playlist { 21 id: number; 22 name: string; 23 cover: string; 24 creatorName: string; 25 } 5 import axiosInstance from "../../api/axiosInstance"; 6 import type { ArtistContributionDTO } from "../../types"; 7 import type { MusicalEntityDTO } from "../../types"; 8 import type { Playlist } from "../../types"; 26 9 27 10 interface User { … … 32 15 followers: number; 33 16 following: number; 17 isFollowedByCurrentUser: boolean; 34 18 35 19 musicalEntities?: { … … 45 29 46 30 const UserDetail = () => { 31 // user refers to the selected user NOT to the user from context 47 32 const { userId } = useParams(); 48 33 const navigate = useNavigate(); … … 54 39 setError(null); 55 40 try { 56 const response = await fetch(`http://localhost:8080/users/${userId}`);41 const response = await axiosInstance.get(`/users/${userId}`); 57 42 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); 43 setUser(response.data); 65 44 } catch (err: any) { 66 setError(err.message); 45 const errorMessage = 46 err.response?.data?.error || "Failed to fetch user"; 47 setError(errorMessage); 67 48 } 68 49 }; … … 115 96 </div> 116 97 117 <button className="px-6 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors font-medium">118 Follow98 <button className="px-6 py-2 bg-blue-500 hover:bg-blue-600 text-white font-semibold rounded-lg shadow-md transition-colors duration-200 cursor-pointer"> 99 {user.isFollowedByCurrentUser ? "Unfollow" : "Follow"} 119 100 </button> 120 101 </div>
Note:
See TracChangeset
for help on using the changeset viewer.
