Initial MRP foundation scaffold
This commit is contained in:
50
server/src/modules/documents/router.ts
Normal file
50
server/src/modules/documents/router.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { permissions } from "@mrp/shared";
|
||||
import { Router } from "express";
|
||||
|
||||
import { renderPdf } from "../../lib/pdf.js";
|
||||
import { requirePermissions } from "../../lib/rbac.js";
|
||||
import { getActiveCompanyProfile } from "../settings/service.js";
|
||||
|
||||
export const documentsRouter = Router();
|
||||
|
||||
documentsRouter.get("/company-profile-preview.pdf", requirePermissions([permissions.companyRead]), async (_request, response) => {
|
||||
const profile = await getActiveCompanyProfile();
|
||||
const pdf = await renderPdf(`
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body { font-family: ${profile.theme.fontFamily}, Arial, sans-serif; color: #1b1f29; padding: 32px; }
|
||||
.card { border: 1px solid #d7deeb; border-radius: 18px; overflow: hidden; }
|
||||
.header { background: ${profile.theme.primaryColor}; color: white; padding: 24px 28px; }
|
||||
.body { padding: 28px; background: #ffffff; }
|
||||
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
|
||||
.label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #5a6a85; }
|
||||
.value { font-size: 16px; margin-top: 6px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<div class="header">
|
||||
<h1>${profile.companyName}</h1>
|
||||
<p>Brand profile preview generated through Puppeteer</p>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="grid">
|
||||
<div><div class="label">Legal name</div><div class="value">${profile.legalName}</div></div>
|
||||
<div><div class="label">Tax ID</div><div class="value">${profile.taxId}</div></div>
|
||||
<div><div class="label">Contact</div><div class="value">${profile.email}<br/>${profile.phone}</div></div>
|
||||
<div><div class="label">Website</div><div class="value">${profile.website}</div></div>
|
||||
<div><div class="label">Address</div><div class="value">${profile.addressLine1}<br/>${profile.addressLine2}<br/>${profile.city}, ${profile.state} ${profile.postalCode}<br/>${profile.country}</div></div>
|
||||
<div><div class="label">Theme</div><div class="value">Primary ${profile.theme.primaryColor}<br/>Accent ${profile.theme.accentColor}<br/>Surface ${profile.theme.surfaceColor}</div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
|
||||
response.setHeader("Content-Type", "application/pdf");
|
||||
response.setHeader("Content-Disposition", "inline; filename=company-profile-preview.pdf");
|
||||
return response.send(pdf);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user