.
This commit is contained in:
parent
aaaf92b6e5
commit
8ca2ef1fab
@ -1,85 +0,0 @@
|
|||||||
import {
|
|
||||||
AlertDialog,
|
|
||||||
AlertDialogAction,
|
|
||||||
AlertDialogCancel,
|
|
||||||
AlertDialogContent,
|
|
||||||
AlertDialogDescription,
|
|
||||||
AlertDialogFooter,
|
|
||||||
AlertDialogHeader,
|
|
||||||
AlertDialogTitle,
|
|
||||||
Spinner,
|
|
||||||
} from "@repo/shadcn-ui/components";
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
interface IssueInvoiceDialogProps {
|
|
||||||
open: boolean;
|
|
||||||
onOpenChange: (open: boolean) => void;
|
|
||||||
proformaId: number;
|
|
||||||
proformaReference: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ProformaDeleteDialog({
|
|
||||||
open,
|
|
||||||
onOpenChange,
|
|
||||||
proformaId,
|
|
||||||
proformaReference,
|
|
||||||
}: IssueInvoiceDialogProps) {
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
||||||
|
|
||||||
const handleDelete = async () => {
|
|
||||||
setIsSubmitting(true);
|
|
||||||
|
|
||||||
/*try {
|
|
||||||
const result = await issueInvoiceFromProforma(proformaId);
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
toast({
|
|
||||||
title: "Factura emitida",
|
|
||||||
description: `Se ha emitido la factura #${result.invoiceId} desde la proforma.`,
|
|
||||||
});
|
|
||||||
onOpenChange(false);
|
|
||||||
} else {
|
|
||||||
throw new Error(result.error);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
toast({
|
|
||||||
title: "Error",
|
|
||||||
description: error instanceof Error ? error.message : "Error al emitir la factura",
|
|
||||||
variant: "destructive",
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
setIsSubmitting(false);
|
|
||||||
}*/
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AlertDialog onOpenChange={onOpenChange} open={open}>
|
|
||||||
<AlertDialogContent>
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>¿Eliminar proforma?</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>
|
|
||||||
Esta acción no se puede deshacer. La proforma será eliminada permanentemente.
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel disabled={isSubmitting}>Cancelar</AlertDialogCancel>
|
|
||||||
<AlertDialogAction
|
|
||||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
||||||
disabled={isSubmitting}
|
|
||||||
onClick={() => proformaId && handleDelete()}
|
|
||||||
>
|
|
||||||
{isSubmitting ? (
|
|
||||||
<>
|
|
||||||
<Spinner className="mr-2 size-4" />
|
|
||||||
Eliminando...
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
"Eliminar proforma"
|
|
||||||
)}
|
|
||||||
Eliminar
|
|
||||||
</AlertDialogAction>
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user