'use client'
import { trpc } from "@/app/_trpc/client"
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
import { DropdownMenuItem } from "@/components/ui/dropdown-menu"
import useDeleteUser from "../hooks/useDeleteUser"
interface AlertDeleteUserProps{
userId:string
}
export function AlertDeleteUser({userId}:AlertDeleteUserProps) {
const {deleteUser}=useDeleteUser()
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<DropdownMenuItem onSelect={(e) => e.preventDefault()}>Eliminar</DropdownMenuItem>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Esta seguro que quiere eliminar este usuario?</AlertDialogTitle>
<AlertDialogDescription>
Esta accion no se puede deshacer.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancelar</AlertDialogCancel>
<AlertDialogAction>
<button disabled={deleteUser.isPending} type="button" onClick={()=>deleteUser.mutate({userId})}>Confirmar</button>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}