This commit is contained in:
gpt-engineer-app[bot]
2026-02-27 03:00:17 +00:00
parent 2d39fcf68d
commit 407e6c9f13
4 changed files with 515 additions and 6 deletions
+220 -3
View File
@@ -47,6 +47,7 @@
"date-fns": "^3.6.0",
"embla-carousel-react": "^8.6.0",
"input-otp": "^1.4.2",
"jspdf": "^4.2.0",
"lucide-react": "^0.462.0",
"next-themes": "^0.3.0",
"react": "^18.3.1",
@@ -110,9 +111,9 @@
}
},
"node_modules/@babel/runtime": {
"version": "7.28.2",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.2.tgz",
"integrity": "sha512-KHp2IflsnGywDjBWDkR9iEqiWSpc8GIi0lgTT3mOElT0PP1tG26P4tmFI2YvAdzgq9RGyoHZQEIEdZy6Ec5xCA==",
"version": "7.28.6",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz",
"integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -3387,12 +3388,25 @@
"integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==",
"license": "MIT"
},
"node_modules/@types/pako": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/pako/-/pako-2.0.4.tgz",
"integrity": "sha512-VWDCbrLeVXJM9fihYodcLiIv0ku+AlOa/TQ1SvYOaBuyrSKgEcro95LJyIsJ4vSo6BXIxOKxiJAat04CmST9Fw==",
"license": "MIT"
},
"node_modules/@types/prop-types": {
"version": "15.7.13",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.13.tgz",
"integrity": "sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==",
"license": "MIT"
},
"node_modules/@types/raf": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz",
"integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==",
"license": "MIT",
"optional": true
},
"node_modules/@types/react": {
"version": "18.3.23",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.23.tgz",
@@ -3446,6 +3460,13 @@
"meshoptimizer": "~0.18.1"
}
},
"node_modules/@types/trusted-types": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
"license": "MIT",
"optional": true
},
"node_modules/@types/webxr": {
"version": "0.5.24",
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz",
@@ -4090,6 +4111,16 @@
"dev": true,
"license": "MIT"
},
"node_modules/base64-arraybuffer": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",
"integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">= 0.6.0"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -4296,6 +4327,26 @@
],
"license": "CC-BY-4.0"
},
"node_modules/canvg": {
"version": "3.0.11",
"resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.11.tgz",
"integrity": "sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==",
"license": "MIT",
"optional": true,
"dependencies": {
"@babel/runtime": "^7.12.5",
"@types/raf": "^3.4.0",
"core-js": "^3.8.3",
"raf": "^3.4.1",
"regenerator-runtime": "^0.13.7",
"rgbcolor": "^1.0.1",
"stackblur-canvas": "^2.0.0",
"svg-pathdata": "^6.0.3"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/case-anything": {
"version": "2.1.13",
"resolved": "https://registry.npmjs.org/case-anything/-/case-anything-2.1.13.tgz",
@@ -4476,6 +4527,18 @@
"dev": true,
"license": "MIT"
},
"node_modules/core-js": {
"version": "3.48.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.48.0.tgz",
"integrity": "sha512-zpEHTy1fjTMZCKLHUZoVeylt9XrzaIN2rbPXEt0k+q7JE5CkCZdo6bNq55bn24a69CH7ErAVLKijxJja4fw+UQ==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
}
},
"node_modules/cross-env": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
@@ -4516,6 +4579,16 @@
"node": ">=4"
}
},
"node_modules/css-line-break": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz",
"integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==",
"license": "MIT",
"optional": true,
"dependencies": {
"utrie": "^1.0.2"
}
},
"node_modules/css-to-react-native": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz",
@@ -4856,6 +4929,16 @@
"node": ">=12"
}
},
"node_modules/dompurify": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.1.tgz",
"integrity": "sha512-qkdCKzLNtrgPFP1Vo+98FRzJnBRGe4ffyCea9IwHB1fyxPOeNTHpLKYGd4Uk9xvNoH0ZoOjwZxNptyMwqrId1Q==",
"license": "(MPL-2.0 OR Apache-2.0)",
"optional": true,
"optionalDependencies": {
"@types/trusted-types": "^2.0.7"
}
},
"node_modules/dprint-node": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/dprint-node/-/dprint-node-1.0.8.tgz",
@@ -5366,6 +5449,17 @@
"dev": true,
"license": "MIT"
},
"node_modules/fast-png": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/fast-png/-/fast-png-6.4.0.tgz",
"integrity": "sha512-kAqZq1TlgBjZcLr5mcN6NP5Rv4V2f22z00c3g8vRrwkcqjerx7BEhPbOnWCPqaHUl2XWQBJQvOT/FQhdMT7X/Q==",
"license": "MIT",
"dependencies": {
"@types/pako": "^2.0.3",
"iobuffer": "^5.3.2",
"pako": "^2.1.0"
}
},
"node_modules/fastq": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz",
@@ -5761,6 +5855,20 @@
"node": ">=12"
}
},
"node_modules/html2canvas": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz",
"integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==",
"license": "MIT",
"optional": true,
"dependencies": {
"css-line-break": "^2.1.0",
"text-segmentation": "^1.0.3"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/http-proxy-agent": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
@@ -5895,6 +6003,12 @@
"node": ">=12"
}
},
"node_modules/iobuffer": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/iobuffer/-/iobuffer-5.4.0.tgz",
"integrity": "sha512-DRebOWuqDvxunfkNJAlc3IzWIPD5xVxwUNbHr7xKB8E6aLJxIPfNX3CoMJghcFjpv6RWQsrcJbghtEwSPoJqMA==",
"license": "MIT"
},
"node_modules/is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
@@ -6129,6 +6243,29 @@
"dev": true,
"license": "MIT"
},
"node_modules/jspdf": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/jspdf/-/jspdf-4.2.0.tgz",
"integrity": "sha512-hR/hnRevAXXlrjeqU5oahOE+Ln9ORJUB5brLHHqH67A+RBQZuFr5GkbI9XQI8OUFSEezKegsi45QRpc4bGj75Q==",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.28.6",
"fast-png": "^6.2.0",
"fflate": "^0.8.1"
},
"optionalDependencies": {
"canvg": "^3.0.11",
"core-js": "^3.6.0",
"dompurify": "^3.3.1",
"html2canvas": "^1.0.0-rc.5"
}
},
"node_modules/jspdf/node_modules/fflate": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz",
"integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==",
"license": "MIT"
},
"node_modules/keyv": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
@@ -6992,6 +7129,12 @@
"dev": true,
"license": "BlueOak-1.0.0"
},
"node_modules/pako": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz",
"integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==",
"license": "(MIT AND Zlib)"
},
"node_modules/parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
@@ -7078,6 +7221,13 @@
"node": ">= 14.16"
}
},
"node_modules/performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==",
"license": "MIT",
"optional": true
},
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
@@ -7360,6 +7510,16 @@
],
"license": "MIT"
},
"node_modules/raf": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",
"integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==",
"license": "MIT",
"optional": true,
"dependencies": {
"performance-now": "^2.1.0"
}
},
"node_modules/react": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
@@ -7684,6 +7844,13 @@
"node": ">=8"
}
},
"node_modules/regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
"license": "MIT",
"optional": true
},
"node_modules/require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
@@ -7739,6 +7906,16 @@
"node": ">=0.10.0"
}
},
"node_modules/rgbcolor": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz",
"integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==",
"license": "MIT OR SEE LICENSE IN FEEL-FREE.md",
"optional": true,
"engines": {
"node": ">= 0.8.15"
}
},
"node_modules/rollup": {
"version": "4.24.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.24.0.tgz",
@@ -7925,6 +8102,16 @@
"dev": true,
"license": "MIT"
},
"node_modules/stackblur-canvas": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz",
"integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=0.1.14"
}
},
"node_modules/stats-gl": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/stats-gl/-/stats-gl-2.4.2.tgz",
@@ -8233,6 +8420,16 @@
"react": ">=17.0"
}
},
"node_modules/svg-pathdata": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-6.0.3.tgz",
"integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/symbol-tree": {
"version": "3.2.4",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
@@ -8297,6 +8494,16 @@
"tailwindcss": ">=3.0.0 || insiders"
}
},
"node_modules/text-segmentation": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz",
"integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==",
"license": "MIT",
"optional": true,
"dependencies": {
"utrie": "^1.0.2"
}
},
"node_modules/thenify": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
@@ -8761,6 +8968,16 @@
"node": ">= 4"
}
},
"node_modules/utrie": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz",
"integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==",
"license": "MIT",
"optional": true,
"dependencies": {
"base64-arraybuffer": "^1.0.2"
}
},
"node_modules/vaul": {
"version": "0.9.9",
"resolved": "https://registry.npmjs.org/vaul/-/vaul-0.9.9.tgz",
+1
View File
@@ -52,6 +52,7 @@
"date-fns": "^3.6.0",
"embla-carousel-react": "^8.6.0",
"input-otp": "^1.4.2",
"jspdf": "^4.2.0",
"lucide-react": "^0.462.0",
"next-themes": "^0.3.0",
"react": "^18.3.1",
+262
View File
@@ -0,0 +1,262 @@
import jsPDF from 'jspdf';
import type { ChecklistItem, Measurement } from '@/stores/useModelStore';
interface ReportData {
fileName: string;
fileSize: number;
fineTuning: { posX: number; posY: number; posZ: number; rotY: number };
checklist: ChecklistItem[];
measurements: Measurement[];
screenshots: string[];
}
const STATUS_LABELS: Record<string, string> = {
pending: 'Pendente',
approved: 'Aprovado',
rejected: 'Reprovado',
};
const STATUS_COLORS: Record<string, [number, number, number]> = {
pending: [180, 180, 50],
approved: [34, 197, 94],
rejected: [239, 68, 68],
};
export async function generateInspectionReport(data: ReportData) {
const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' });
const pageW = pdf.internal.pageSize.getWidth();
const margin = 15;
const contentW = pageW - margin * 2;
let y = margin;
const addPage = () => {
pdf.addPage();
y = margin;
};
const checkSpace = (needed: number) => {
if (y + needed > 280) addPage();
};
// ── Header ──
pdf.setFillColor(15, 23, 42);
pdf.rect(0, 0, pageW, 35, 'F');
pdf.setFont('helvetica', 'bold');
pdf.setFontSize(18);
pdf.setTextColor(255, 255, 255);
pdf.text('TrackkSteelXR', margin, 16);
pdf.setFontSize(10);
pdf.setFont('helvetica', 'normal');
pdf.setTextColor(148, 163, 184);
pdf.text('Relatório de Inspeção', margin, 24);
const dateStr = new Date().toLocaleDateString('pt-BR', {
day: '2-digit', month: '2-digit', year: 'numeric',
hour: '2-digit', minute: '2-digit',
});
pdf.text(dateStr, pageW - margin, 24, { align: 'right' });
y = 45;
// ── Model Info ──
pdf.setFontSize(12);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor(30, 41, 59);
pdf.text('Informações do Modelo', margin, y);
y += 7;
pdf.setFontSize(9);
pdf.setFont('helvetica', 'normal');
pdf.setTextColor(71, 85, 105);
const infoLines = [
['Arquivo:', data.fileName],
['Tamanho:', `${(data.fileSize / (1024 * 1024)).toFixed(2)} MB`],
['Escala:', '1:1 (mm)'],
];
for (const [label, value] of infoLines) {
pdf.setFont('helvetica', 'bold');
pdf.text(label, margin, y);
pdf.setFont('helvetica', 'normal');
pdf.text(value, margin + 25, y);
y += 5;
}
// ── Fine Tuning ──
y += 5;
checkSpace(30);
pdf.setFontSize(12);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor(30, 41, 59);
pdf.text('Ajuste Fino (Offsets)', margin, y);
y += 7;
pdf.setFontSize(9);
pdf.setFont('helvetica', 'normal');
pdf.setTextColor(71, 85, 105);
const ft = data.fineTuning;
const ftLines = [
['Posição X:', `${ft.posX.toFixed(3)} m`],
['Posição Y:', `${ft.posY.toFixed(3)} m`],
['Posição Z:', `${ft.posZ.toFixed(3)} m`],
['Rotação Y:', `${ft.rotY.toFixed(1)}°`],
];
for (const [label, value] of ftLines) {
pdf.setFont('helvetica', 'bold');
pdf.text(label, margin, y);
pdf.setFont('helvetica', 'normal');
pdf.text(value, margin + 25, y);
y += 5;
}
// ── Checklist ──
y += 5;
checkSpace(50);
pdf.setFontSize(12);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor(30, 41, 59);
pdf.text('Checklist de Inspeção', margin, y);
y += 3;
// Summary bar
const approved = data.checklist.filter(i => i.status === 'approved').length;
const rejected = data.checklist.filter(i => i.status === 'rejected').length;
const pending = data.checklist.filter(i => i.status === 'pending').length;
y += 5;
pdf.setFontSize(8);
pdf.setFont('helvetica', 'normal');
pdf.setTextColor(71, 85, 105);
pdf.text(`Aprovados: ${approved} | Reprovados: ${rejected} | Pendentes: ${pending}`, margin, y);
y += 7;
for (const item of data.checklist) {
checkSpace(20);
const color = STATUS_COLORS[item.status] || [100, 100, 100];
// Status pill
pdf.setFillColor(color[0], color[1], color[2]);
pdf.roundedRect(margin, y - 3.5, 18, 5, 1.5, 1.5, 'F');
pdf.setFontSize(7);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor(255, 255, 255);
pdf.text(STATUS_LABELS[item.status] || item.status, margin + 9, y, { align: 'center' });
// Label
pdf.setFontSize(9);
pdf.setFont('helvetica', 'normal');
pdf.setTextColor(30, 41, 59);
pdf.text(item.label, margin + 22, y);
y += 5;
// Note
if (item.note) {
pdf.setFontSize(8);
pdf.setTextColor(100, 116, 139);
const noteLines = pdf.splitTextToSize(`Nota: ${item.note}`, contentW - 22);
pdf.text(noteLines, margin + 22, y);
y += noteLines.length * 4;
}
if (item.audioUrl) {
pdf.setFontSize(7);
pdf.setTextColor(100, 116, 139);
pdf.text('🎙️ Áudio gravado anexado', margin + 22, y);
y += 4;
}
y += 3;
}
// ── Measurements ──
if (data.measurements.length > 0) {
y += 3;
checkSpace(30);
pdf.setFontSize(12);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor(30, 41, 59);
pdf.text('Medições', margin, y);
y += 7;
// Table header
pdf.setFillColor(241, 245, 249);
pdf.rect(margin, y - 4, contentW, 6, 'F');
pdf.setFontSize(8);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor(71, 85, 105);
pdf.text('#', margin + 2, y);
pdf.text('Ponto A (mm)', margin + 12, y);
pdf.text('Ponto B (mm)', margin + 65, y);
pdf.text('Distância', margin + 120, y);
y += 6;
pdf.setFont('helvetica', 'normal');
pdf.setFontSize(8);
pdf.setTextColor(30, 41, 59);
data.measurements.forEach((m, idx) => {
checkSpace(8);
if (idx % 2 === 0) {
pdf.setFillColor(248, 250, 252);
pdf.rect(margin, y - 4, contentW, 6, 'F');
}
const fmtPt = (p: { x: number; y: number; z: number }) =>
`${(p.x * 1000).toFixed(1)}, ${(p.y * 1000).toFixed(1)}, ${(p.z * 1000).toFixed(1)}`;
pdf.text(`${idx + 1}`, margin + 2, y);
pdf.text(fmtPt(m.pointA), margin + 12, y);
pdf.text(fmtPt(m.pointB), margin + 65, y);
pdf.setFont('helvetica', 'bold');
pdf.text(`${m.distanceMM.toFixed(1)} mm`, margin + 120, y);
pdf.setFont('helvetica', 'normal');
y += 6;
});
}
// ── Screenshots ──
if (data.screenshots.length > 0) {
addPage();
pdf.setFontSize(12);
pdf.setFont('helvetica', 'bold');
pdf.setTextColor(30, 41, 59);
pdf.text('Screenshots / Anotações', margin, y);
y += 8;
for (let i = 0; i < data.screenshots.length; i++) {
checkSpace(100);
try {
const imgW = contentW;
const imgH = imgW * 0.56; // ~16:9
pdf.addImage(data.screenshots[i], 'PNG', margin, y, imgW, imgH);
y += imgH + 3;
pdf.setFontSize(7);
pdf.setFont('helvetica', 'normal');
pdf.setTextColor(148, 163, 184);
pdf.text(`Captura ${i + 1} de ${data.screenshots.length}`, margin, y);
y += 8;
} catch {
pdf.setFontSize(8);
pdf.setTextColor(200, 50, 50);
pdf.text(`[Erro ao inserir screenshot ${i + 1}]`, margin, y);
y += 8;
}
}
}
// ── Footer on last page ──
const pageH = pdf.internal.pageSize.getHeight();
pdf.setFillColor(241, 245, 249);
pdf.rect(0, pageH - 12, pageW, 12, 'F');
pdf.setFontSize(7);
pdf.setFont('helvetica', 'normal');
pdf.setTextColor(148, 163, 184);
pdf.text('Gerado por TrackkSteelXR', margin, pageH - 5);
pdf.text(`Página ${pdf.getNumberOfPages()}`, pageW - margin, pageH - 5, { align: 'right' });
// Save
const safeName = data.fileName.replace(/\.[^.]+$/, '');
pdf.save(`Inspecao_${safeName}_${new Date().toISOString().slice(0, 10)}.pdf`);
}
+32 -3
View File
@@ -1,5 +1,5 @@
import { useNavigate } from 'react-router-dom';
import { ArrowLeft, Glasses, Box, Ruler, FileText, Columns2 } from 'lucide-react';
import { ArrowLeft, Glasses, Box, Ruler, FileText, Columns2, Download } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { useModelStore } from '@/stores/useModelStore';
import { ModelViewerCanvas } from '@/components/three/ModelViewer';
@@ -9,14 +9,34 @@ import { FineTuningControls } from '@/components/FineTuningControls';
import { MeasurementsList } from '@/components/MeasurementsList';
import { ScreenshotGallery } from '@/components/ScreenshotGallery';
import { ComparePanel } from '@/components/ComparePanel';
import { useEffect } from 'react';
import { useEffect, useCallback } from 'react';
import { toast } from 'sonner';
import { ScrollArea } from '@/components/ui/scroll-area';
import { Separator } from '@/components/ui/separator';
import { generateInspectionReport } from '@/lib/generateReport';
const Viewer = () => {
const navigate = useNavigate();
const { model, xrSupported, compareMode, setCompareMode } = useModelStore();
const { model, xrSupported, compareMode, setCompareMode, checklist, measurements, screenshots, fineTuning } = useModelStore();
const handleExportPDF = useCallback(async () => {
if (!model) return;
toast.info('Gerando relatório PDF…');
try {
await generateInspectionReport({
fileName: model.fileName,
fileSize: model.fileSize,
fineTuning,
checklist,
measurements,
screenshots,
});
toast.success('Relatório exportado com sucesso!');
} catch (err) {
console.error(err);
toast.error('Erro ao gerar o relatório.');
}
}, [model, fineTuning, checklist, measurements, screenshots]);
useEffect(() => {
if (!model) {
@@ -51,6 +71,15 @@ const Viewer = () => {
</div>
<div className="flex items-center gap-2">
<Button
variant="outline"
size="sm"
className="gap-2"
onClick={handleExportPDF}
>
<Download className="h-4 w-4" />
Exportar PDF
</Button>
<Button
variant={compareMode ? 'default' : 'outline'}
size="sm"