diff --git a/apps/hq-web/src/pages/DocumentView.tsx b/apps/hq-web/src/pages/DocumentView.tsx index c87ace0..e35dd90 100644 --- a/apps/hq-web/src/pages/DocumentView.tsx +++ b/apps/hq-web/src/pages/DocumentView.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState, type ReactNode } from 'react' import { Link, useNavigate, useParams } from 'react-router-dom' import { formatINR } from '@sims/domain' import { @@ -14,7 +14,7 @@ import { DOC_TONE, DOC_TYPE_TONE, DOC_TYPE_LABEL, useData } from './Clients' import { PaymentForm } from './client-forms' /** One pending confirmation — replaces the browser confirm() popup with the styled dialog. */ -interface Confirm { title: string; body: string; label: string; tone?: 'danger'; run: () => void } +interface Confirm { title: string; body: ReactNode; label: string; tone?: 'danger'; run: () => void | Promise } const TITLE: Record = { QUOTATION: 'Quotation', PROFORMA: 'Proforma Invoice', INVOICE: 'Tax Invoice', @@ -43,6 +43,7 @@ export function DocumentView() { const [paying, setPaying] = useState(false) const [sending, setSending] = useState(false) const [confirm, setConfirm] = useState() + const cancelReasonRef = useRef('') // read in the confirm's run() closure (state would be stale there) // PDF preview via blob URL — an