Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧹 Lint (push) Failing after 13s
Monorepo Pipeline / 🏗️ Build (push) Failing after 11s
Monorepo Pipeline / 🧪 Test (push) Failing after 25s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Directus (Base) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
25 lines
747 B
TypeScript
25 lines
747 B
TypeScript
import { renderToFile } from "@react-pdf/renderer";
|
|
import { createElement } from "react";
|
|
import { EstimationPDF } from "../components/EstimationPDF.js";
|
|
import { PRICING } from "../logic/pricing/constants.js";
|
|
import { calculateTotals } from "../logic/pricing/calculator.js";
|
|
|
|
export class PdfEngine {
|
|
constructor() { }
|
|
|
|
async generateEstimatePdf(state: any, outputPath: string): Promise<string> {
|
|
const totals = calculateTotals(state, PRICING);
|
|
|
|
await renderToFile(
|
|
createElement(EstimationPDF as any, {
|
|
state,
|
|
totalPrice: totals.totalPrice,
|
|
pricing: PRICING,
|
|
} as any) as any,
|
|
outputPath
|
|
);
|
|
|
|
return outputPath;
|
|
}
|
|
}
|