"use client"; import * as React from "react"; import { motion } from "framer-motion"; import { api, type AlbumCard, type ArtistHeader, type Track } from "@/lib/api"; import { tint } from "@/lib/colour"; import { Hero } from "@/components/hero"; import { TrackRow } from "@/components/track-row"; import { Skeletons } from "@/components/skeletons"; export function ArtistView({ id, onAlbum, onQueued, }: { id: number; onAlbum: (id: number) => void; onQueued?: () => void; }) { const [data, setData] = React.useState<{ artist: ArtistHeader; tracks: Track[]; albums: AlbumCard[]; } | null>(null); const [err, setErr] = React.useState(null); React.useEffect(() => { let live = true; setData(null); setErr(null); api .artist(id) .then((d) => { if (!live) return; setData(d); void tint(d.artist.picture); }) .catch((e) => live && setErr((e as Error).message)); return () => { live = false; }; }, [id]); if (err) return
Could not load artist: {err}
; if (!data) return ; const { artist, tracks, albums } = data; return ( <> Top tracks {tracks.map((t, i) => ( ))} {albums.length > 0 && ( <> Releases
{albums.map((a, i) => ( onAlbum(a.album_id)} className="cursor-pointer text-left" > {/* eslint-disable-next-line @next/next/no-img-element */} (e.currentTarget.style.visibility = "hidden")} />
{a.title}
{[a.year, a.record_type].filter(Boolean).join(" ยท ")}
))}
)} ); } function SectionHead({ children }: { children: React.ReactNode }) { return (

{children}

); }