diff --git a/apps/Frontend/src/components/payments/payments-recent-table.tsx b/apps/Frontend/src/components/payments/payments-recent-table.tsx index 6ebc119..293d916 100644 --- a/apps/Frontend/src/components/payments/payments-recent-table.tsx +++ b/apps/Frontend/src/components/payments/payments-recent-table.tsx @@ -19,6 +19,7 @@ import { TrendingUp, ThumbsDown, DollarSign, + Ban, } from "lucide-react"; import { apiRequest, queryClient } from "@/lib/queryClient"; import { useToast } from "@/hooks/use-toast"; @@ -35,7 +36,6 @@ import { Checkbox } from "@/components/ui/checkbox"; import { DeleteConfirmationDialog } from "../ui/deleteDialog"; import LoadingScreen from "../ui/LoadingScreen"; import { - ClaimStatus, NewTransactionPayload, PaymentStatus, PaymentWithExtras, @@ -321,6 +321,36 @@ export default function PaymentsRecentTable({ } }; + //VOID and UNVOID Feature + const handleVoid = (paymentId: number) => { + updatePaymentStatusMutation.mutate({ paymentId, status: "VOID" }); + }; + + const handleUnvoid = (paymentId: number) => { + updatePaymentStatusMutation.mutate({ paymentId, status: "PENDING" }); + }; + + const [isVoidOpen, setIsVoidOpen] = useState(false); + const [voidPaymentId, setVoidPaymentId] = useState(null); + + const [isUnvoidOpen, setIsUnvoidOpen] = useState(false); + const [unvoidPaymentId, setUnvoidPaymentId] = useState(null); + + const handleConfirmVoid = () => { + if (!voidPaymentId) return; + handleVoid(voidPaymentId); + setVoidPaymentId(null); + setIsVoidOpen(false); + }; + + const handleConfirmUnvoid = () => { + if (!unvoidPaymentId) return; + handleUnvoid(unvoidPaymentId); + setUnvoidPaymentId(null); + setIsUnvoidOpen(false); + }; + + // Pagination useEffect(() => { if (onPageChange) onPageChange(currentPage); }, [currentPage, onPageChange]); @@ -401,6 +431,13 @@ export default function PaymentsRecentTable({ color: "bg-red-100 text-red-800", icon: , }; + case "VOID": + return { + label: "Void", + color: "bg-gray-100 text-gray-800", + icon: , + }; + default: return { label: status @@ -598,17 +635,36 @@ export default function PaymentsRecentTable({ )} - {/* Pay Full Due */} - {payment.status !== "PAID" && ( - - )} - {/* Revert Full Due */} + + {/* When NOT PAID and NOT VOID → Pay in Full + Void */} + {payment.status !== "PAID" && + payment.status !== "VOID" && ( + <> + + + {/* NEW: Void */} + + + )} + + {/* When PAID → Revert */} {payment.status === "PAID" && ( + )} @@ -642,6 +712,28 @@ export default function PaymentsRecentTable({ onCancel={() => setIsRevertOpen(false)} /> + {/* NEW: Void Confirmation Dialog */} + setIsVoidOpen(false)} + /> + + {/* NEW: Unvoid Confirmation Dialog */} + setIsUnvoidOpen(false)} + /> +