fix(pdf): decouple 6 distinct PDFs, fix layout issues and DataForSEO event loop
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧹 Lint (push) Failing after 1m1s
Monorepo Pipeline / 🧪 Test (push) Failing after 1m7s
Monorepo Pipeline / 🏗️ Build (push) Failing after 1m10s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Image Processor (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
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧹 Lint (push) Failing after 1m1s
Monorepo Pipeline / 🧪 Test (push) Failing after 1m7s
Monorepo Pipeline / 🏗️ Build (push) Failing after 1m10s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Image Processor (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
This commit is contained in:
@@ -22,13 +22,15 @@ import { EstimationPDF } from "../components/EstimationPDF.js";
|
||||
import { ConceptPDF } from "../components/ConceptPDF.js";
|
||||
import { InfoPDF } from "../components/InfoPDF.js";
|
||||
import { AgbsPDF } from "../components/AgbsPDF.js";
|
||||
import { FrontPagePDF } from "../components/FrontPagePDF.js";
|
||||
import { ClosingPDF } from "../components/ClosingPDF.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> {
|
||||
async generateEstimatePdf(state: any, outputPath: string, options: { headerIcon?: string; footerLogo?: string } = {}): Promise<string> {
|
||||
const totals = calculateTotals(state, PRICING);
|
||||
|
||||
await renderToFile(
|
||||
@@ -36,6 +38,7 @@ export class PdfEngine {
|
||||
state,
|
||||
totalPrice: totals.totalPrice,
|
||||
pricing: PRICING,
|
||||
...options
|
||||
} as any) as any,
|
||||
outputPath
|
||||
);
|
||||
@@ -43,10 +46,11 @@ export class PdfEngine {
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
async generateConceptPdf(concept: any, outputPath: string): Promise<string> {
|
||||
async generateConceptPdf(concept: any, outputPath: string, options: { headerIcon?: string; footerLogo?: string } = {}): Promise<string> {
|
||||
await renderToFile(
|
||||
createElement(ConceptPDF as any, {
|
||||
concept,
|
||||
...options
|
||||
} as any) as any,
|
||||
outputPath
|
||||
);
|
||||
@@ -56,7 +60,7 @@ export class PdfEngine {
|
||||
|
||||
async generateInfoPdf(outputPath: string, options: { headerIcon?: string; footerLogo?: string } = {}): Promise<string> {
|
||||
await renderToFile(
|
||||
createElement(InfoPDF as any, options as any) as any,
|
||||
createElement(InfoPDF as any, { ...options, pricing: PRICING } as any) as any,
|
||||
outputPath
|
||||
);
|
||||
|
||||
@@ -71,4 +75,25 @@ export class PdfEngine {
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
async generateFrontPagePdf(state: any, outputPath: string, options: { headerIcon?: string } = {}): Promise<string> {
|
||||
await renderToFile(
|
||||
createElement(FrontPagePDF as any, {
|
||||
state,
|
||||
...options
|
||||
} as any) as any,
|
||||
outputPath
|
||||
);
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
async generateClosingPdf(outputPath: string, options: { headerIcon?: string; footerLogo?: string } = {}): Promise<string> {
|
||||
await renderToFile(
|
||||
createElement(ClosingPDF as any, options as any) as any,
|
||||
outputPath
|
||||
);
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user