diff --git a/apps/Frontend/src/components/payments/payments-recent-table.tsx b/apps/Frontend/src/components/payments/payments-recent-table.tsx index b46bce1f..061258c6 100755 --- a/apps/Frontend/src/components/payments/payments-recent-table.tsx +++ b/apps/Frontend/src/components/payments/payments-recent-table.tsx @@ -96,9 +96,8 @@ export default function PaymentsRecentTable({ const [currentPayment, setCurrentPayment] = useState< PaymentWithExtras | undefined >(undefined); - const [selectedPaymentId, setSelectedPaymentId] = useState( - null - ); + const [selectedPaymentId, setSelectedPaymentId] = useState(null); + const [checkedPaymentIds, setCheckedPaymentIds] = useState>(new Set()); const [isRevertOpen, setIsRevertOpen] = useState(false); const [revertPaymentId, setRevertPaymentId] = useState(null); @@ -112,6 +111,18 @@ export default function PaymentsRecentTable({ } }; + const handleToggleCheck = (paymentId: number) => { + setCheckedPaymentIds((prev) => { + const next = new Set(prev); + if (next.has(paymentId)) { + next.delete(paymentId); + } else { + next.add(paymentId); + } + return next; + }); + }; + const queryKey = qkPaymentsRecent({ patientId: patientId ?? undefined, page: currentPage, @@ -138,6 +149,25 @@ export default function PaymentsRecentTable({ placeholderData: { payments: [], totalCount: 0 }, }); + const currentPageIds = (paymentsData?.payments ?? []).map((p) => p.id); + const allOnPageChecked = + currentPageIds.length > 0 && + currentPageIds.every((id) => checkedPaymentIds.has(id)); + const someOnPageChecked = + !allOnPageChecked && currentPageIds.some((id) => checkedPaymentIds.has(id)); + + const handleToggleAll = () => { + setCheckedPaymentIds((prev) => { + const next = new Set(prev); + if (allOnPageChecked) { + currentPageIds.forEach((id) => next.delete(id)); + } else { + currentPageIds.forEach((id) => next.add(id)); + } + return next; + }); + }; + const updatePaymentMutation = useMutation({ mutationFn: async (data: NewTransactionPayload) => { const response = await apiRequest( @@ -478,11 +508,46 @@ export default function PaymentsRecentTable({ return (
+ {/* Check MH Payment action bar */} + {allowCheckbox && checkedPaymentIds.size > 0 && ( +
+ + {checkedPaymentIds.size} record{checkedPaymentIds.size > 1 ? "s" : ""} selected + + + +
+ )} +
- {allowCheckbox && Select} + {allowCheckbox && ( + + + + )} Payment ID Claim ID Patient Name @@ -538,10 +603,11 @@ export default function PaymentsRecentTable({ return ( {allowCheckbox && ( - + handleSelectPayment(payment)} + checked={checkedPaymentIds.has(payment.id)} + onCheckedChange={() => handleToggleCheck(payment.id)} + aria-label={`Select payment ${payment.id}`} /> )} diff --git a/apps/Frontend/src/pages/payments-page.tsx b/apps/Frontend/src/pages/payments-page.tsx index 3ef50ba6..1aaae30f 100755 --- a/apps/Frontend/src/pages/payments-page.tsx +++ b/apps/Frontend/src/pages/payments-page.tsx @@ -6,7 +6,8 @@ import { CardContent, CardDescription, } from "@/components/ui/card"; -import { DollarSign } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { DollarSign, CalendarIcon } from "lucide-react"; import { Select, SelectContent, @@ -14,6 +15,12 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { Calendar } from "@/components/ui/calendar"; import PaymentsRecentTable from "@/components/payments/payments-recent-table"; import PaymentsOfPatientModal from "@/components/payments/payments-of-patient-table"; import PaymentOCRBlock from "@/components/payments/payment-ocr-block"; @@ -26,6 +33,12 @@ import PaymentEditModal from "@/components/payments/payment-edit-modal"; export default function PaymentsPage() { const [paymentPeriod, setPaymentPeriod] = useState("all-time"); + // Check Payments Online date range + const [mhFromDate, setMhFromDate] = useState(undefined); + const [mhToDate, setMhToDate] = useState(undefined); + const [fromCalendarOpen, setFromCalendarOpen] = useState(false); + const [toCalendarOpen, setToCalendarOpen] = useState(false); + // for auto-open from appointment redirect const [location] = useLocation(); const [initialPatientForModal, setInitialPatientForModal] = @@ -212,6 +225,87 @@ export default function PaymentsPage() { + {/* Check Payments Online */} + + + Check Payments Online + + Select a date range and check MH payment status online + + + +
+ {/* From date picker */} +
+ From: + + + + + + { + setMhFromDate(d); + setFromCalendarOpen(false); + }} + onClose={() => setFromCalendarOpen(false)} + /> + + +
+ + {/* To date picker */} +
+ To: + + + + + + { + setMhToDate(d); + setToCalendarOpen(false); + }} + onClose={() => setToCalendarOpen(false)} + /> + + +
+ + {/* Check All MH Payment button */} + +
+
+
+ {/* Recent Payments table */} @@ -221,7 +315,7 @@ export default function PaymentsPage() { - +