import { useQuery } from "@tanstack/react-query"; import ArtistLinks from "./ArtistLinks"; import { getTopArtists, imageUrl, type getItemsArgs } from "api/api"; import { Link } from "react-router"; import TopListSkeleton from "./skeletons/TopListSkeleton"; import TopItemList from "./TopItemList"; interface Props { limit: number; period: string; artistId?: Number; albumId?: Number; } export default function TopArtists(props: Props) { const { isPending, isError, data, error } = useQuery({ queryKey: [ "top-artists", { limit: props.limit, period: props.period, page: 0 }, ], queryFn: ({ queryKey }) => getTopArtists(queryKey[1] as getItemsArgs), }); if (isPending) { return (

Top Artists

Loading...

); } else if (isError) { return (

Top Artists

Error: {error.message}

); } return (

Top Artists

{data.items.length < 1 ? "Nothing to show" : ""}
); }