"use client"; import Link from "next/link"; import Image from "next/image"; import { Music } from "lucide-react"; import { api } from "@/lib/api"; import { memo } from "react"; import { HorizontalCarousel, CarouselItem } from "@/components/ui/HorizontalCarousel"; interface Artist { id: string; mbid?: string; name: string; coverArt?: string; albumCount?: number; } interface ArtistsGridProps { artists: Artist[]; } // Helper to get the correct image source const getArtistImageSrc = (coverArt: string | undefined) => { if (!coverArt) { return null; } return api.getCoverArtUrl(coverArt, 300); }; interface ArtistCardProps { artist: Artist; index: number; } const ArtistCard = memo( function ArtistCard({ artist, index }: ArtistCardProps) { const imageSrc = getArtistImageSrc(artist.coverArt); return (
{artist.coverArt && imageSrc ? ( {artist.name} ) : ( )}

{artist.name}

Artist

); }, (prevProps, nextProps) => { return prevProps.artist.id === nextProps.artist.id && prevProps.index === nextProps.index; } ); const ArtistsGrid = memo(function ArtistsGrid({ artists }: ArtistsGridProps) { return ( {artists.map((artist, index) => ( ))} ); }); export { ArtistsGrid, getArtistImageSrc };