diff --git a/src/screens/DailySalesReportPage.tsx b/src/screens/DailySalesReportPage.tsx index 76ccf42..f6d5e72 100644 --- a/src/screens/DailySalesReportPage.tsx +++ b/src/screens/DailySalesReportPage.tsx @@ -59,7 +59,7 @@ export function DailySalesReportPage() { doc.save(`Daily_Sales_Report_${date || 'Draft'}.pdf`); }; - const printReport = () => { + const printReport = async () => { const doc = new jsPDF(); // Headers @@ -95,10 +95,29 @@ export function DailySalesReportPage() { headStyles: { fillColor: [243, 244, 246], fontStyle: 'bold', halign: 'center' }, }); - const blobUrl = doc.output('bloburl'); + const blob = doc.output('blob'); + + // Attempt mobile native share (which includes OS-level Print) + if (navigator.share && navigator.canShare) { + const file = new File([blob], `Daily_Sales_Report_${date || 'Draft'}.pdf`, { type: 'application/pdf' }); + try { + if (navigator.canShare({ files: [file] })) { + await navigator.share({ + files: [file], + title: 'Daily Sales Report', + }); + return; + } + } catch (err) { + console.warn('Share failed or was cancelled', err); + } + } + + // Fallback for PC / unsupported browsers + const blobUrl = URL.createObjectURL(blob); const iframe = document.createElement('iframe'); iframe.style.display = 'none'; - iframe.src = blobUrl.toString(); + iframe.src = blobUrl; document.body.appendChild(iframe); iframe.onload = () => {