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:
@@ -6,6 +6,7 @@ import {
|
||||
Text as PDFText,
|
||||
View as PDFView,
|
||||
StyleSheet as PDFStyleSheet,
|
||||
Document as PDFDocument,
|
||||
} from "@react-pdf/renderer";
|
||||
import {
|
||||
pdfStyles,
|
||||
@@ -213,30 +214,34 @@ export const AgbsPDF = ({
|
||||
|
||||
if (mode === "full") {
|
||||
return (
|
||||
<SimpleLayout
|
||||
companyData={companyData}
|
||||
bankData={bankData}
|
||||
headerIcon={headerIcon}
|
||||
footerLogo={footerLogo}
|
||||
showPageNumber={false}
|
||||
>
|
||||
{content}
|
||||
</SimpleLayout>
|
||||
<PDFDocument title="Allgemeine Geschäftsbedingungen">
|
||||
<SimpleLayout
|
||||
companyData={companyData}
|
||||
bankData={bankData}
|
||||
headerIcon={headerIcon}
|
||||
footerLogo={footerLogo}
|
||||
showPageNumber={false}
|
||||
>
|
||||
{content}
|
||||
</SimpleLayout>
|
||||
</PDFDocument>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<PDFPage size="A4" style={pdfStyles.page}>
|
||||
<FoldingMarks />
|
||||
<Header icon={headerIcon} showAddress={false} />
|
||||
{content}
|
||||
<Footer
|
||||
logo={footerLogo}
|
||||
companyData={companyData}
|
||||
_bankData={bankData}
|
||||
showDetails={false}
|
||||
showPageNumber={false}
|
||||
/>
|
||||
</PDFPage>
|
||||
<PDFDocument title="Allgemeine Geschäftsbedingungen">
|
||||
<PDFPage size="A4" style={pdfStyles.page}>
|
||||
<FoldingMarks />
|
||||
<Header icon={headerIcon} showAddress={false} />
|
||||
{content}
|
||||
<Footer
|
||||
logo={footerLogo}
|
||||
companyData={companyData}
|
||||
bankData={bankData}
|
||||
showDetails={false}
|
||||
showPageNumber={false}
|
||||
/>
|
||||
</PDFPage>
|
||||
</PDFDocument>
|
||||
);
|
||||
};
|
||||
|
||||
36
packages/pdf-library/src/components/ClosingPDF.tsx
Normal file
36
packages/pdf-library/src/components/ClosingPDF.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { Document as PDFDocument } from "@react-pdf/renderer";
|
||||
import { SimpleLayout } from "./pdf/SimpleLayout.js";
|
||||
import { ClosingModule } from "./pdf/modules/CommonModules.js";
|
||||
|
||||
export const ClosingPDF = ({ headerIcon, footerLogo }: any) => {
|
||||
const date = new Date().toLocaleDateString("de-DE", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
|
||||
const companyData = {
|
||||
name: "Marc Mintel",
|
||||
address1: "Georg-Meistermann-Straße 7",
|
||||
address2: "54586 Schüller",
|
||||
ustId: "DE367588065",
|
||||
};
|
||||
|
||||
const commonProps = {
|
||||
date,
|
||||
headerIcon,
|
||||
footerLogo,
|
||||
companyData,
|
||||
};
|
||||
|
||||
return (
|
||||
<PDFDocument title="Abschluss">
|
||||
<SimpleLayout {...commonProps}>
|
||||
<ClosingModule />
|
||||
</SimpleLayout>
|
||||
</PDFDocument>
|
||||
);
|
||||
};
|
||||
@@ -5,17 +5,12 @@ import { Page as PDFPage, Document as PDFDocument } from "@react-pdf/renderer";
|
||||
import { pdfStyles } from "./pdf/SharedUI.js";
|
||||
import { SimpleLayout } from "./pdf/SimpleLayout.js";
|
||||
|
||||
// Modules
|
||||
import { FrontPageModule } from "./pdf/modules/FrontPageModule.js";
|
||||
import { BriefingModule } from "./pdf/modules/BriefingModule.js";
|
||||
import { SitemapModule } from "./pdf/modules/SitemapModule.js";
|
||||
import { ClosingModule } from "./pdf/modules/CommonModules.js";
|
||||
|
||||
export const ConceptPDF = ({
|
||||
concept,
|
||||
headerIcon,
|
||||
footerLogo,
|
||||
}: any) => {
|
||||
export const ConceptPDF = (props: any) => {
|
||||
const { concept, headerIcon, footerLogo } = props;
|
||||
|
||||
const date = new Date().toLocaleDateString("de-DE", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
@@ -48,10 +43,6 @@ export const ConceptPDF = ({
|
||||
|
||||
return (
|
||||
<PDFDocument title={`Projektkonzept - ${flatState.companyName || "Projekt"}`}>
|
||||
<PDFPage size="A4" style={pdfStyles.titlePage}>
|
||||
<FrontPageModule state={flatState} headerIcon={headerIcon} date={date} />
|
||||
</PDFPage>
|
||||
|
||||
<SimpleLayout {...commonProps}>
|
||||
<BriefingModule state={flatState} />
|
||||
</SimpleLayout>
|
||||
@@ -61,10 +52,6 @@ export const ConceptPDF = ({
|
||||
<SitemapModule state={flatState} />
|
||||
</SimpleLayout>
|
||||
)}
|
||||
|
||||
<SimpleLayout {...commonProps}>
|
||||
<ClosingModule />
|
||||
</SimpleLayout>
|
||||
</PDFDocument>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -6,10 +6,7 @@ import { pdfStyles } from "./pdf/SharedUI.js";
|
||||
import { SimpleLayout } from "./pdf/SimpleLayout.js";
|
||||
|
||||
// Modules
|
||||
import { FrontPageModule } from "./pdf/modules/FrontPageModule.js";
|
||||
import { EstimationModule } from "./pdf/modules/EstimationModule.js";
|
||||
import { TransparenzModule } from "./pdf/modules/TransparenzModule.js";
|
||||
import { ClosingModule } from "./pdf/modules/CommonModules.js";
|
||||
|
||||
import { calculatePositions } from "../logic/pricing/calculator.js";
|
||||
|
||||
@@ -58,10 +55,6 @@ export const EstimationPDF = ({
|
||||
|
||||
return (
|
||||
<PDFDocument title={`Angebot - ${state.companyName || "Projekt"}`}>
|
||||
<PDFPage size="A4" style={pdfStyles.titlePage}>
|
||||
<FrontPageModule state={state} headerIcon={headerIcon} date={date} />
|
||||
</PDFPage>
|
||||
|
||||
<SimpleLayout {...commonProps}>
|
||||
<EstimationModule
|
||||
state={state}
|
||||
@@ -70,14 +63,6 @@ export const EstimationPDF = ({
|
||||
date={date}
|
||||
/>
|
||||
</SimpleLayout>
|
||||
|
||||
<SimpleLayout {...commonProps}>
|
||||
<TransparenzModule pricing={pricing} />
|
||||
</SimpleLayout>
|
||||
|
||||
<SimpleLayout {...commonProps}>
|
||||
<ClosingModule />
|
||||
</SimpleLayout>
|
||||
</PDFDocument>
|
||||
);
|
||||
};
|
||||
|
||||
22
packages/pdf-library/src/components/FrontPagePDF.tsx
Normal file
22
packages/pdf-library/src/components/FrontPagePDF.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import { Page as PDFPage, Document as PDFDocument } from "@react-pdf/renderer";
|
||||
import { pdfStyles } from "./pdf/SharedUI.js";
|
||||
import { FrontPageModule } from "./pdf/modules/FrontPageModule.js";
|
||||
|
||||
export const FrontPagePDF = ({ state, headerIcon }: any) => {
|
||||
const date = new Date().toLocaleDateString("de-DE", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
|
||||
return (
|
||||
<PDFDocument title={`Deckblatt - ${state?.companyName || "Projekt"}`}>
|
||||
<PDFPage size="A4" style={pdfStyles.titlePage}>
|
||||
<FrontPageModule state={state} headerIcon={headerIcon} date={date} />
|
||||
</PDFPage>
|
||||
</PDFDocument>
|
||||
);
|
||||
};
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
Divider,
|
||||
} from "./pdf/SharedUI.js";
|
||||
import { SimpleLayout } from "./pdf/SimpleLayout.js";
|
||||
import { TransparenzModule } from "./pdf/modules/TransparenzModule.js";
|
||||
|
||||
const styles = PDFStyleSheet.create({
|
||||
section: {
|
||||
@@ -74,7 +75,7 @@ const styles = PDFStyleSheet.create({
|
||||
},
|
||||
});
|
||||
|
||||
export const InfoPDF = ({ headerIcon, footerLogo }: { headerIcon?: string; footerLogo?: string }) => {
|
||||
export const InfoPDF = ({ headerIcon, footerLogo, pricing }: { headerIcon?: string; footerLogo?: string; pricing?: any }) => {
|
||||
const companyData = {
|
||||
name: "Marc Mintel",
|
||||
address1: "Georg-Meistermann-Straße 7",
|
||||
@@ -153,6 +154,12 @@ export const InfoPDF = ({ headerIcon, footerLogo }: { headerIcon?: string; foote
|
||||
<PDFText style={[styles.textRegular, { fontSize: FONT_SIZES.SMALL, textAlign: 'center', color: COLORS.TEXT_LIGHT }]}>
|
||||
Marc Mintel — Digital Architect & Senior Software Developer
|
||||
</PDFText>
|
||||
|
||||
{pricing && (
|
||||
<PDFView break>
|
||||
<TransparenzModule pricing={pricing} />
|
||||
</PDFView>
|
||||
)}
|
||||
</PDFView>
|
||||
);
|
||||
|
||||
|
||||
@@ -525,13 +525,13 @@ export const FoldingMarks = () => (
|
||||
export const Footer = ({
|
||||
logo,
|
||||
companyData,
|
||||
_bankData,
|
||||
bankData,
|
||||
showDetails = true,
|
||||
showPageNumber = true,
|
||||
}: {
|
||||
logo?: string;
|
||||
companyData: any;
|
||||
_bankData?: any;
|
||||
bankData?: any;
|
||||
showDetails?: boolean;
|
||||
showPageNumber?: boolean;
|
||||
}) => (
|
||||
|
||||
@@ -48,7 +48,7 @@ export const SimpleLayout: React.FC<SimpleLayoutProps> = ({
|
||||
<Footer
|
||||
logo={footerLogo}
|
||||
companyData={companyData}
|
||||
_bankData={bankData}
|
||||
bankData={bankData}
|
||||
showDetails={showDetails}
|
||||
showPageNumber={showPageNumber}
|
||||
/>
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import { DocumentTitle, COLORS, FONT_SIZES } from "../SharedUI";
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
section: { marginBottom: 32 },
|
||||
section: { paddingBottom: 16 },
|
||||
intro: {
|
||||
fontSize: FONT_SIZES.BODY,
|
||||
color: COLORS.TEXT_DIM,
|
||||
|
||||
@@ -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