'use client'; import { useState } from 'react'; import Image from 'next/image'; import type { ScriptCard } from '~/types/script'; import { TypeBadge, UpdateableBadge } from './Badge'; interface ScriptCardProps { script: ScriptCard; onClick: (script: ScriptCard) => void; isSelected?: boolean; onToggleSelect?: (slug: string) => void; } export function ScriptCard({ script, onClick, isSelected = false, onToggleSelect }: ScriptCardProps) { const [imageError, setImageError] = useState(false); const handleImageError = () => { setImageError(true); }; const handleCheckboxClick = (e: React.MouseEvent) => { e.stopPropagation(); if (onToggleSelect && script.slug) { onToggleSelect(script.slug); } }; return (
onClick(script)} > {/* Checkbox in top-left corner */} {onToggleSelect && (
{isSelected && ( )}
)}
{/* Header with logo and name */}
{script.logo && !imageError ? ( {`${script.name} ) : (
{script.name?.charAt(0)?.toUpperCase() || '?'}
)}

{script.name || 'Unnamed Script'}

{/* Type and Updateable status on first row */}
{script.updateable && }
{/* Download Status */}
{script.isDownloaded ? 'Downloaded' : 'Not Downloaded'}
{/* Description */}

{script.description || 'No description available'}

{/* Footer with website link */} {script.website && (
e.stopPropagation()} > Website
)}
); }