"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"; interface MixCardProps { mix: { id: string; name: string; description: string; coverUrls: string[]; trackCount: number; }; index?: number; } const MixCard = memo( function MixCard({ mix, index }: MixCardProps) { return (
{/* Circular mosaic cover art */}
{mix.coverUrls.length > 0 ? (
{mix.coverUrls.slice(0, 4).map((url, idx) => { const proxiedUrl = api.getCoverArtUrl( url, 300 ); return (
); })} {/* Fill remaining cells if less than 4 covers */} {Array.from({ length: Math.max( 0, 4 - mix.coverUrls.length ), }).map((_, idx) => (
))}
) : (
)}

{mix.name}

{mix.description}

); }, (prevProps, nextProps) => { // Compare id, name, description, trackCount, and coverUrls to detect content changes // This ensures the card re-renders when mood mix content changes even if ID is the same return ( prevProps.mix.id === nextProps.mix.id && prevProps.mix.name === nextProps.mix.name && prevProps.mix.description === nextProps.mix.description && prevProps.mix.trackCount === nextProps.mix.trackCount && prevProps.mix.coverUrls.length === nextProps.mix.coverUrls.length && prevProps.mix.coverUrls.every( (url, i) => url === nextProps.mix.coverUrls[i] ) ); } ); export { MixCard };