import { formatPrice, formatWeight } from "../lib/formatters";
import { LucideIcon } from "../lib/iconData";
import { useUIStore } from "../stores/uiStore";
interface CandidateCardProps {
id: number;
name: string;
weightGrams: number | null;
priceCents: number | null;
categoryName: string;
categoryIcon: string;
imageFilename: string | null;
productUrl?: string | null;
threadId: number;
isActive: boolean;
}
export function CandidateCard({
id,
name,
weightGrams,
priceCents,
categoryName,
categoryIcon,
imageFilename,
productUrl,
threadId,
isActive,
}: CandidateCardProps) {
const openCandidateEditPanel = useUIStore((s) => s.openCandidateEditPanel);
const openConfirmDeleteCandidate = useUIStore(
(s) => s.openConfirmDeleteCandidate,
);
const openResolveDialog = useUIStore((s) => s.openResolveDialog);
const openExternalLink = useUIStore((s) => s.openExternalLink);
return (
{productUrl && (
openExternalLink(productUrl)}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
openExternalLink(productUrl);
}
}}
className="absolute top-2 right-2 z-10 w-6 h-6 flex items-center justify-center rounded-full bg-gray-100/80 text-gray-400 hover:bg-blue-100 hover:text-blue-500 opacity-0 group-hover:opacity-100 transition-all cursor-pointer"
title="Open product link"
>
)}
{imageFilename ? (

) : (
)}
{name}
{weightGrams != null && (
{formatWeight(weightGrams)}
)}
{priceCents != null && (
{formatPrice(priceCents)}
)}
{" "}
{categoryName}
{isActive && (
)}
);
}