Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
e056e8d1b9
commit
b08890dc9d
@@ -56,10 +56,10 @@ export function ItlForm() {
|
||||
(parseFloat(adminFees) || 0) -
|
||||
(parseFloat(lessPayments) || 0);
|
||||
|
||||
const handleExport = () => {
|
||||
const buildPdf = () => {
|
||||
if (!client || !template) {
|
||||
toast.error("Select a client first");
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
const returnAddress = [client.name];
|
||||
@@ -87,7 +87,7 @@ export function ItlForm() {
|
||||
total,
|
||||
});
|
||||
|
||||
const doc = renderLetterPdf({
|
||||
return renderLetterPdf({
|
||||
template,
|
||||
returnAddress,
|
||||
topRightLine: tokens.date as string,
|
||||
@@ -98,13 +98,33 @@ export function ItlForm() {
|
||||
total: { label: labels.totalDue ?? "TOTAL DUE", amount: total },
|
||||
filename: `ITL_${ownerFullName(homeowner) || "draft"}_${letterDate}`,
|
||||
});
|
||||
};
|
||||
|
||||
const name = promptFilename(`ITL_${ownerFullName(homeowner) || "draft"}_${letterDate}`, "pdf");
|
||||
const defaultName = `ITL_${ownerFullName(homeowner) || "draft"}_${letterDate}`;
|
||||
|
||||
const handleExport = () => {
|
||||
const doc = buildPdf();
|
||||
if (!doc) return;
|
||||
const name = promptFilename(defaultName, "pdf");
|
||||
if (!name) return;
|
||||
doc.save(`${name}.pdf`);
|
||||
toast.success("ITL PDF downloaded");
|
||||
};
|
||||
|
||||
const handleSaveToCase = async ({ caseId, name, folder }: { caseId: string; name: string; folder: string }) => {
|
||||
const doc = buildPdf();
|
||||
if (!doc) return;
|
||||
const filename = name.endsWith(".pdf") ? name : `${name}.pdf`;
|
||||
await savePdfToDocuments({
|
||||
blob: doc.output("blob"),
|
||||
caseId,
|
||||
name: filename,
|
||||
folder,
|
||||
mimeType: "application/pdf",
|
||||
});
|
||||
toast.success("Saved to case files");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Card>
|
||||
|
||||
Reference in New Issue
Block a user