diff --git a/web-frontend/src/components/Canvas/ExportReportModal.tsx b/web-frontend/src/components/Canvas/ExportReportModal.tsx index 9ca2e7a..ecfdeb6 100644 --- a/web-frontend/src/components/Canvas/ExportReportModal.tsx +++ b/web-frontend/src/components/Canvas/ExportReportModal.tsx @@ -22,10 +22,12 @@ import { TbFileSpreadsheet } from "react-icons/tb"; import * as XLSX from "xlsx"; import { useEditorStore } from "@/store/useEditorStore"; +import { getReportFooterHTML } from "@/utils/exportFooter"; interface ExportReportModalProps { editorId: string; open: boolean; + projectName?: string; onClose: () => void; } @@ -51,11 +53,16 @@ interface FormatOption { export const ExportReportModal: React.FC = ({ editorId, open, + projectName, onClose, }) => { const editorState = useEditorStore((s) => s.editors[editorId]); const [exportFormat, setExportFormat] = useState("csv"); + const createdBy = localStorage.getItem("username") || "Unknown User"; + const dateStr = new Date().toLocaleDateString("en-US", { month: "long", day: "numeric", year: "numeric" }); + const footerHTML = getReportFooterHTML(projectName || "Untitled Project", createdBy, dateStr); + // Transform editor items to report items const items = useMemo(() => { if (!editorState?.items) return []; @@ -242,9 +249,13 @@ export const ExportReportModal: React.FC = ({ .stat-item { text-align: center; } .stat-value { font-size: 24px; font-weight: bold; color: #4F46E5; } .stat-label { font-size: 12px; color: #666; } + /* Title block table must not inherit outer table styles */ + .title-block table { margin-top: 0; border-collapse: collapse; } + .title-block td { border: none !important; padding: 5px 0; } @media print { body { margin: 0; } .no-print { display: none; } + * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; } } @@ -264,11 +275,10 @@ export const ExportReportModal: React.FC = ({
Unique Types
-
${ - items.filter( - (i) => i.description && i.description !== "No description", - ).length - }
+
${items.filter( + (i) => i.description && i.description !== "No description", + ).length + }
With Description
@@ -284,8 +294,8 @@ export const ExportReportModal: React.FC = ({ ${items - .map( - (item) => ` + .map( + (item) => ` ${item.slNo} ${item.tagNo} @@ -293,10 +303,11 @@ export const ExportReportModal: React.FC = ({ ${item.description} `, - ) - .join("")} + ) + .join("")} + ${footerHTML} @@ -362,6 +373,12 @@ export const ExportReportModal: React.FC = ({ th { background-color: #4F46E5; color: white; font-weight: 600; padding: 12px 10px; text-align: left; } td { padding: 10px; border-bottom: 1px solid #e5e7eb; } .footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid #e5e7eb; text-align: center; color: #6b7280; font-size: 9pt; } + /* Title block must not inherit outer table styles */ + .title-block table { margin-top: 0; border-collapse: collapse; } + .title-block td { border: none !important; padding: 5px 0; } + @media print { + * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; } + } @@ -380,11 +397,10 @@ export const ExportReportModal: React.FC = ({
Equipment Types
-
${ - items.filter( - (i) => i.description && i.description !== "No description", - ).length - }
+
${items.filter( + (i) => i.description && i.description !== "No description", + ).length + }
Documented Items
@@ -404,8 +420,8 @@ export const ExportReportModal: React.FC = ({ ${items - .map( - (item) => ` + .map( + (item) => ` ${item.slNo} ${item.tagNo} @@ -413,11 +429,13 @@ export const ExportReportModal: React.FC = ({ ${item.description} `, - ) - .join("")} + ) + .join("")} + ${footerHTML} +