import { RiCalendarLine, RiLoader4Line, RiMoneyDollarCircleLine, } from "@remixicon/react"; import { type BillDialogState, formatBillDateLabel, getBillStatusBadgeVariant, } from "@/features/dashboard/bills/bills-helpers"; import type { BillPaymentAccountOption, DashboardBill, } from "@/features/dashboard/bills/bills-queries"; import { AccountCardSelectContent } from "@/features/transactions/components/select-items"; import { EstablishmentLogo } from "@/shared/components/entity-avatar"; import MoneyValues from "@/shared/components/money-values"; import { PaymentSuccess } from "@/shared/components/payment-success"; import { Badge } from "@/shared/components/ui/badge"; import { Button } from "@/shared/components/ui/button"; import { Card } from "@/shared/components/ui/card"; import { DatePicker } from "@/shared/components/ui/date-picker"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/shared/components/ui/dialog"; import { Label } from "@/shared/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/shared/components/ui/select"; import { Separator } from "@/shared/components/ui/separator"; type BillPaymentDialogProps = { bill: DashboardBill | null; open: boolean; modalState: BillDialogState; isPending: boolean; paymentAccountId: string; onPaymentAccountChange: (accountId: string) => void; paymentDate: Date; onPaymentDateChange: (date: Date) => void; paymentAccountOptions: BillPaymentAccountOption[]; onClose: () => void; onConfirm: () => void; }; export function BillPaymentDialog({ bill, open, modalState, isPending, paymentAccountId, onPaymentAccountChange, paymentDate, onPaymentDateChange, paymentAccountOptions, onClose, onConfirm, }: BillPaymentDialogProps) { const isProcessing = modalState === "processing" || isPending; const dueLabel = bill ? formatBillDateLabel(bill.dueDate, "Vencimento:") : null; const paidLabel = bill ? formatBillDateLabel(bill.boletoPaymentDate, "Pago em:") : null; const isBillPending = bill ? !bill.isSettled : false; const paymentDateValue = paymentDate.toISOString().split("T")[0] ?? ""; const selectedAccount = paymentAccountOptions.find( (option) => option.value === paymentAccountId, ); return ( { if (nextOpen || isProcessing) { return; } onClose(); }} > { if (isProcessing) { event.preventDefault(); } }} onPointerDownOutside={(event) => { if (isProcessing) { event.preventDefault(); } }} > {modalState === "success" ? ( ) : ( <>
Confirmar pagamento {isBillPending ? "Escolha a conta de origem e a data em que o boleto foi pago." : "Boleto"}
{bill ? (

Boleto

{bill.name}

Valor
{bill.isSettled ? "Pago em" : "Vencimento"}

{bill.isSettled ? (paidLabel?.replace("Pago em: ", "") ?? "—") : (dueLabel?.replace("Vencimento: ", "") ?? "—")}

{isBillPending ? (
{ if (value) { onPaymentDateChange(new Date(`${value}T00:00:00`)); } }} disabled={isProcessing} />
) : (
Status atual Pago
)}
) : null} )}
); }