import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { Play, UserCheck, UserPlus } from "lucide-react"; import { Link, useParams } from "react-router-dom"; import { artistsApi } from "../lib/api"; import { usePlayer } from "../store/player"; import { Cover } from "../components/Cover"; import { ShareButton } from "../components/ShareButton"; import { TrackRow } from "../components/TrackRow"; export function ArtistPage() { const { id = "" } = useParams(); const qc = useQueryClient(); const playQueue = usePlayer((s) => s.playQueue); const { data, isLoading } = useQuery({ queryKey: ["artist", id], queryFn: () => artistsApi.get(id), enabled: Boolean(id), }); const { data: tracks = [] } = useQuery({ queryKey: ["artist-tracks", id], queryFn: () => artistsApi.tracks(id), enabled: Boolean(id), }); const follow = useMutation({ mutationFn: () => (data?.following ? artistsApi.unfollow(id) : artistsApi.follow(id)), onSuccess: () => { void qc.invalidateQueries({ queryKey: ["artist", id] }); void qc.invalidateQueries({ queryKey: ["library"] }); }, }); if (isLoading) return
Загрузка...
; if (!data) returnАртист не найден.
; const { artist } = data; return ({artist.followersCount} подписчиков {artist.trackCount !== undefined && ` · ${artist.trackCount} треков`} {artist.country && ` · ${artist.country}`}
{artist.description && ({artist.description}
)}Треков пока нет.
)}