import { useQuery } from "@tanstack/react-query" import { getTopAlbums, imageUrl, type getItemsArgs } from "api/api" import { Link } from "react-router" interface Props { artistId: number name: string period: string } export default function ArtistAlbums({artistId, name, period}: Props) { const { isPending, isError, data, error } = useQuery({ queryKey: ['top-albums', {limit: 99, period: "all_time", artist_id: artistId, page: 0}], queryFn: ({ queryKey }) => getTopAlbums(queryKey[1] as getItemsArgs), }) if (isPending) { return (

Albums From This Artist

Loading...

) } if (isError) { return (

Albums From This Artist

Error:{error.message}

) } return (

Albums featuring {name}

{data.items.map((item) => ( {item.title}

{item.title}

{item.listen_count} play{item.listen_count > 1 ? 's' : ''}

))}
) }