import { useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { SigviewRecord as Signature } from "@/lib/pbtypes"; import { getSignatureMeta } from "@/hooks/useSignatureCategories"; import { Trash2 } from "lucide-react"; import { SignatureEditModal } from "@/components/SignatureEditModal"; interface SignatureCardProps { signature: Signature; onDelete?: (signatureId: string) => Promise; onUpdate?: (updatedSignature: Partial) => Promise; } export const SignatureCard = ({ signature, onDelete, onUpdate }: SignatureCardProps) => { const [isEditModalOpen, setIsEditModalOpen] = useState(false); const meta = getSignatureMeta(signature.type); const isGasSite = signature.type?.toLowerCase().includes('gas'); const handleDelete = async () => { if (onDelete) { try { await onDelete(signature.id); } catch (error) { console.error('Failed to delete signature:', error); } } }; const handleUpdate = async (updatedSignature: Partial) => { if (onUpdate) { try { await onUpdate(updatedSignature); } catch (error) { console.error('Failed to update signature:', error); throw error; } } }; return ( <> setIsEditModalOpen(true)} >
{/* Type Badge - Most Important */}
{meta.icon} {signature.type || 'Unknown Type'}
{/* Signature Name */}

{signature.signame || 'Unnamed Signature'}

{signature.note && (
{signature.note}
)}
{/* Additional Info */}
System: {signature.system}
ID: {signature.id}
{/* Delete Button */} {onDelete && (
Delete Signature Are you sure you want to delete signature {signature.identifier}?
This action cannot be undone.
Cancel Delete
)}
{/* Edit Modal */} {onUpdate && ( setIsEditModalOpen(false)} onSave={handleUpdate} /> )} ); };