import { useState } from "react"; import { type Person } from "@/domain/types"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { useNavigate } from "@tanstack/react-router"; import { Trash2, UserSquare } from "lucide-react"; import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger, } from "@/components/ui/context-menu"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog"; import { useDeletePerson } from "@/features/people/use-people"; import { buttonVariants } from "@/components/ui/button"; type PersonCardProps = { person: Person; }; export function PersonCard({ person }: PersonCardProps) { const navigate = useNavigate(); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const { mutate: deletePerson, isPending: isDeleting } = useDeletePerson( person.id ); const handleDelete = () => { deletePerson(); }; return ( <> { // Navigate on left click navigate({ to: "/people/$personId", params: { personId: person.id }, }); }} >
{/* TODO: Add person thumbnail */}
{person.name}
setShowDeleteDialog(true)} disabled={isDeleting} > Delete Person
Are you sure? This action cannot be undone. This will permanently delete{" "} {person.name} and unassign all associated faces. Cancel {isDeleting ? "Deleting..." : "Delete"} ); }