Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 6s
Build & Deploy / 🧪 QA (push) Failing after 3m8s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
135 lines
3.0 KiB
TypeScript
135 lines
3.0 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import {
|
|
Page as PDFPage,
|
|
Document as PDFDocument,
|
|
Image as PDFImage,
|
|
StyleSheet,
|
|
View as PDFView,
|
|
Text as PDFText,
|
|
} from "@react-pdf/renderer";
|
|
import {
|
|
FrontPageModule,
|
|
SitemapModule,
|
|
EstimationModule,
|
|
TransparenzModule,
|
|
ClosingModule,
|
|
SimpleLayout,
|
|
pdfStyles,
|
|
calculatePositions,
|
|
} from "@mintel/pdf";
|
|
|
|
// Local styles for QR Code overlay
|
|
const styles = StyleSheet.create({
|
|
qrContainer: {
|
|
position: "absolute",
|
|
bottom: 40,
|
|
right: 40,
|
|
width: 60,
|
|
height: 60,
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
},
|
|
qrImage: {
|
|
width: "100%",
|
|
height: "100%",
|
|
},
|
|
qrLabel: {
|
|
fontSize: 8,
|
|
color: "#94a3b8", // slate-400
|
|
marginTop: 4,
|
|
textAlign: "center",
|
|
},
|
|
});
|
|
|
|
interface PDFProps {
|
|
state: any;
|
|
totalPrice: number;
|
|
monthlyPrice?: number;
|
|
totalPagesCount?: number;
|
|
pricing: any;
|
|
headerIcon?: string;
|
|
footerLogo?: string;
|
|
qrCodeData?: string;
|
|
}
|
|
|
|
export const LocalEstimationPDF = ({
|
|
state,
|
|
totalPrice,
|
|
pricing,
|
|
headerIcon,
|
|
footerLogo,
|
|
qrCodeData,
|
|
}: PDFProps) => {
|
|
const date = new Date().toLocaleDateString("de-DE", {
|
|
year: "numeric",
|
|
month: "long",
|
|
day: "numeric",
|
|
});
|
|
|
|
const positions = calculatePositions(state, pricing);
|
|
|
|
const companyData = {
|
|
name: "Marc Mintel",
|
|
address1: "Georg-Meistermann-Straße 7",
|
|
address2: "54586 Schüller",
|
|
ustId: "DE367588065",
|
|
};
|
|
|
|
const bankData = {
|
|
name: "N26",
|
|
bic: "NTSBDEB1XXX",
|
|
iban: "DE50 1001 1001 2620 4328 65",
|
|
};
|
|
|
|
const commonProps = {
|
|
headerIcon: headerIcon,
|
|
footerLogo,
|
|
companyData,
|
|
bankData,
|
|
};
|
|
|
|
let pageCounter = 1;
|
|
const getPageNum = () => (pageCounter++).toString().padStart(2, "0");
|
|
|
|
return (
|
|
<PDFDocument title={`Angebot - ${state.companyName || "Projekt"}`}>
|
|
<PDFPage size="A4" style={pdfStyles.titlePage}>
|
|
<FrontPageModule state={state} headerIcon={headerIcon} date={date} />
|
|
{qrCodeData && (
|
|
<PDFView style={styles.qrContainer}>
|
|
<PDFImage src={qrCodeData} style={styles.qrImage} />
|
|
<PDFText style={styles.qrLabel}>Scan me</PDFText>
|
|
</PDFView>
|
|
)}
|
|
</PDFPage>
|
|
|
|
{/* BriefingModule Page REMOVED as per user request ("die zweite seite ist leer, weg damit") */}
|
|
|
|
{state.sitemap && state.sitemap.length > 0 && (
|
|
<SimpleLayout {...commonProps} showPageNumber={false}>
|
|
<SitemapModule state={state} />
|
|
</SimpleLayout>
|
|
)}
|
|
|
|
<SimpleLayout {...commonProps} showPageNumber={false}>
|
|
<EstimationModule
|
|
state={state}
|
|
positions={positions}
|
|
totalPrice={totalPrice}
|
|
date={date}
|
|
/>
|
|
</SimpleLayout>
|
|
|
|
<SimpleLayout {...commonProps} showPageNumber={false}>
|
|
<TransparenzModule pricing={pricing} />
|
|
</SimpleLayout>
|
|
|
|
<SimpleLayout {...commonProps} showPageNumber={false}>
|
|
<ClosingModule />
|
|
</SimpleLayout>
|
|
</PDFDocument>
|
|
);
|
|
};
|