- Timestamp:
- 01/30/26 00:08:04 (5 months ago)
- Branches:
- main
- Children:
- 2b08bed
- Parents:
- 6de2873
- Location:
- frontend/src
- Files:
-
- 4 edited
-
components/userProfile/ArtistView.tsx (modified) (1 diff)
-
components/userProfile/ListenerView.tsx (modified) (6 diffs)
-
pages/UserDetailView.tsx (modified) (6 diffs)
-
utils/types.ts (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/components/userProfile/ArtistView.tsx
r6de2873 r98992cf 1 1 import { useNavigate } from "react-router-dom"; 2 2 import { Music, Disc3 } from "lucide-react"; 3 import type { ArtistContribution DTO} from "../../utils/types";3 import type { ArtistContribution } from "../../utils/types"; 4 4 5 5 interface ArtistViewProps { 6 contributions: ArtistContribution DTO[];6 contributions: ArtistContribution[]; 7 7 } 8 8 -
frontend/src/components/userProfile/ListenerView.tsx
r6de2873 r98992cf 1 1 import { useNavigate } from "react-router-dom"; 2 2 import { Heart, ListMusic, Music, Album } from "lucide-react"; 3 import type { Playlist, MusicalEntity DTO} from "../../utils/types";3 import type { Playlist, MusicalEntity } from "../../utils/types"; 4 4 5 5 interface ListenerViewProps { 6 likedEntities: MusicalEntity DTO[];7 playlists ?: Playlist[];6 likedEntities: MusicalEntity[] | []; 7 playlists: Playlist[] | []; 8 8 } 9 9 … … 11 11 const navigate = useNavigate(); 12 12 13 const likedSongs = likedEntities .filter((e) => e.type === "SONG");14 const likedAlbums = likedEntities .filter((e) => e.type === "ALBUM");13 const likedSongs = likedEntities?.filter((e) => e.type === "SONG"); 14 const likedAlbums = likedEntities?.filter((e) => e.type === "ALBUM"); 15 15 16 16 return ( … … 55 55 )} 56 56 57 {likedSongs .length > 0 && (57 {likedSongs && likedSongs.length > 0 && ( 58 58 <section> 59 59 <div className="flex items-center gap-2 mb-6 pb-2 border-b-2 border-gray-200"> … … 61 61 <h3 className="text-2xl font-bold text-gray-800">Liked Songs</h3> 62 62 <span className="text-sm text-gray-400 ml-1"> 63 ({likedSongs .length})63 ({likedSongs?.length}) 64 64 </span> 65 65 </div> … … 90 90 )} 91 91 92 {likedAlbums .length > 0 && (92 {likedAlbums && likedAlbums.length > 0 && ( 93 93 <section> 94 94 <div className="flex items-center gap-2 mb-6 pb-2 border-b-2 border-gray-200"> … … 120 120 )} 121 121 122 {likedEntities.length === 0 && (!playlists || playlists.length === 0) && ( 123 <div className="flex flex-col items-center justify-center py-16 text-gray-300"> 124 <p className="text-lg font-medium text-gray-400">Nothing here yet</p> 125 <p className="text-sm text-gray-400 mt-1"> 126 Start exploring music to build your collection 127 </p> 128 </div> 129 )} 122 {likedEntities && 123 likedEntities.length === 0 && 124 (!playlists || playlists.length === 0) && ( 125 <div className="flex flex-col items-center justify-center py-16 text-gray-300"> 126 <p className="text-lg font-medium text-gray-400"> 127 Nothing here yet 128 </p> 129 <p className="text-sm text-gray-400 mt-1"> 130 Start exploring music to build your collection 131 </p> 132 </div> 133 )} 130 134 </div> 131 135 ); -
frontend/src/pages/UserDetailView.tsx
r6de2873 r98992cf 5 5 import ListenerView from "../components/userProfile/ListenerView"; 6 6 import type { 7 ArtistContributionDTO, 8 MusicalEntityDTO, 7 MusicalEntity, 9 8 Playlist, 9 ArtistContribution, 10 10 } from "../utils/types"; 11 11 12 interface User {12 interface BaseUser { 13 13 id: number; 14 username: string;15 14 fullName: string; 16 15 userType: string; … … 18 17 following: number; 19 18 isFollowedByCurrentUser: boolean; 19 } 20 20 21 musicalEntities?: { 22 contributions: ArtistContributionDTO[]; 23 }; 21 interface Artist extends BaseUser { 22 userType: "ARTIST"; 23 contributions: ArtistContribution[]; 24 } 25 interface Listener extends BaseUser { 26 userType: "LISTENER"; 27 likedEntities: MusicalEntity[]; 28 createdPlaylists: Playlist[]; 29 } 24 30 25 likes?: { 26 likedEntities: MusicalEntityDTO[]; 27 }; 28 29 createdPlaylists?: Playlist[]; 30 } 31 type UserProfile = Artist | Listener; 31 32 32 33 const UserDetail = () => { … … 34 35 const { userId } = useParams(); 35 36 const navigate = useNavigate(); 36 const [user, setUser] = useState<User | null>(null);37 const [user, setUser] = useState<UserProfile | null>(null); 37 38 const [error, setError] = useState<string | null>(null); 38 39 const [isFollowing, setIsFollowing] = useState(false); … … 43 44 setIsFollowing(true); 44 45 try { 45 const response = await axiosInstance.post<User >(46 const response = await axiosInstance.post<UserProfile>( 46 47 `/users/follow/${userId}`, 47 48 ); 48 setUser(response.data);49 49 } catch (err: any) { 50 50 console.error(err.response?.data?.error); … … 59 59 try { 60 60 const response = await axiosInstance.get(`/users/${userId}`); 61 console.log(response.data); 61 62 62 63 setUser(response.data); … … 135 136 </div> 136 137 137 {user.userType === "ARTIST" && user.musicalEntities?.contributions && ( 138 <ArtistView contributions={user.musicalEntities.contributions} /> 139 )} 140 141 {user.userType === "LISTENER" && user.likes?.likedEntities && ( 138 {user.userType === "ARTIST" ? ( 139 <ArtistView contributions={user.contributions} /> 140 ) : ( 142 141 <ListenerView 143 likedEntities={user.like s.likedEntities}142 likedEntities={user.likedEntities} 144 143 playlists={user.createdPlaylists} 145 144 /> -
frontend/src/utils/types.ts
r6de2873 r98992cf 1 1 export interface User { 2 username: string;3 fullName: string;4 email?: string;5 profilePhoto?: string | null;6 role?: "ADMIN" | "NONADMIN";2 username: string; 3 fullName: string; 4 email?: string; 5 profilePhoto?: string | null; 6 role?: "ADMIN" | "NONADMIN"; 7 7 } 8 8 9 export interface ArtistContribution DTO{10 musicalEntityId: number;11 title: string;12 genre: string;13 role: string;14 entityType: string;9 export interface ArtistContribution { 10 musicalEntityId: number; 11 title: string; 12 genre: string; 13 role: string; 14 entityType: string; 15 15 } 16 export interface MusicalEntity DTO{17 id: number;18 title: string;19 genre: string;20 type: string;16 export interface MusicalEntity { 17 id: number; 18 title: string; 19 genre: string; 20 type: string; 21 21 } 22 22 23 23 export interface Playlist { 24 id: number;25 name: string;26 cover: string;27 creatorName: string;24 id: number; 25 name: string; 26 cover: string; 27 creatorName: string; 28 28 }
Note:
See TracChangeset
for help on using the changeset viewer.
