From dbdc953d9808940221b5e1f451903f6a2729b6b2 Mon Sep 17 00:00:00 2001 From: Gunaseelan P Date: Thu, 24 Sep 2026 14:48:59 +0530 Subject: [PATCH] Revert button labels to Download Digital & Print Bulk Orders and auto-generate both PNG & PDF formats together --- src/App.tsx | 78 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 27 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 7bd4e0a..2eb16fe 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -321,19 +321,21 @@ export default function App() { saveAs(blob, "sample_employees.csv"); }; - const handleDownloadSingle = async (format: "png" | "pdf" = "png") => { + const handleDownloadSingleBoth = async () => { if (!cardRef.current) return; setIsGenerating(true); try { const dataUrl = await toPng(cardRef.current, { pixelRatio: 3 }); - if (format === "png") { - const link = document.createElement("a"); - link.download = `${currentEmployee.name || "ID"}_${currentRegion.name}.png`; - link.href = dataUrl; - link.click(); - } else { - // PDF Export (Standard portrait card format 54mm x 85.6mm) + + // 1. Download PNG Image + const link = document.createElement("a"); + link.download = `${currentEmployee.name || "ID"}_${currentRegion.name}.png`; + link.href = dataUrl; + link.click(); + + // 2. Download PDF Document (Standard portrait card format 54mm x 85.6mm) + setTimeout(() => { const pdf = new jsPDF({ orientation: "portrait", unit: "mm", @@ -341,7 +343,8 @@ export default function App() { }); pdf.addImage(dataUrl, "PNG", 0, 0, 54, 85.6); pdf.save(`${currentEmployee.name || "ID"}_${currentRegion.name}.pdf`); - } + }, 300); + logCreation(currentEmployee.unitId, 1); } catch (err) { console.error("Error generating card:", err); @@ -1099,46 +1102,67 @@ export default function App() { > Next + {isBatchMode ? ( +
+
+ {employees.findIndex((e) => e.id === currentEmployee.id) + 1}{" "} + of {employees.length} +
) : (
-
)}