import { useNavigate } from "react-router-dom"; import { useState } from "react"; import { Music, Disc3, Play, Plus } from "lucide-react"; import type { ArtistContribution } from "../../utils/types"; import axiosInstance from "../../api/axiosInstance"; interface ArtistViewProps { contributions: ArtistContribution[]; } const ArtistView = ({ contributions }: ArtistViewProps) => { const navigate = useNavigate(); const [items, setItems] = useState(contributions); const [toast, setToast] = useState<{ message: string; show: boolean }>({ message: "", show: false, }); const albums = items.filter((c) => c.entityType === "ALBUM"); const songs = items.filter((c) => c.entityType === "SONG"); const getRoleColor = (role: string) => { const colors: { [key: string]: string } = { COMPOSER: "bg-purple-100 text-purple-700", PERFORMER: "bg-blue-100 text-blue-700", PRODUCER: "bg-green-100 text-green-700", MAIN_VOCAL: "bg-pink-100 text-pink-700", }; return colors[role] || "bg-gray-100 text-gray-700"; }; const showToast = (message: string) => { setToast({ message, show: true }); setTimeout(() => { setToast({ message: "", show: false }); }, 2000); }; const handleLike = async (id: number, title: string) => { try { const response = await axiosInstance.post(`/musical-entity/${id}/like`); const data = response.data; setItems((prevItems) => prevItems.map((item) => item.id === data.entityId ? { ...item, isLikedByCurrentUser: data.isLiked } : item, ), ); showToast( data.isLiked ? `Liked "${title}"` : `Removed ${title} from likes`, ); } catch (err: any) { showToast(err.response?.data?.error); } }; return (
No contributions yet
Start creating music to see it here