diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index ddd3a00..69321dd 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -4,6 +4,7 @@ import withMintelConfig from "@mintel/next-config"; const nextConfig = { reactStrictMode: true, output: 'standalone', + transpilePackages: ["@mintel/pdf"], async rewrites() { const umamiUrl = process.env.UMAMI_API_ENDPOINT || diff --git a/apps/web/package.json b/apps/web/package.json index afb96e6..7d9f368 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -31,6 +31,7 @@ "typecheck": "tsc --noEmit" }, "dependencies": { + "@mintel/pdf": "link:../../../at-mintel/packages/pdf-library", "@react-pdf/renderer": "^4.3.2", "@remotion/bundler": "^4.0.414", "@remotion/cli": "^4.0.414", diff --git a/apps/web/scripts/ai-estimate.ts b/apps/web/scripts/ai-estimate.ts index b7b9a46..3e31d93 100644 --- a/apps/web/scripts/ai-estimate.ts +++ b/apps/web/scripts/ai-estimate.ts @@ -7,8 +7,8 @@ import { execSync } from "node:child_process"; import axios from "axios"; import { FileCacheAdapter } from "../src/utils/cache/file-adapter.js"; -import { initialState, PRICING } from "../src/logic/pricing/constants.js"; -import { calculateTotals } from "../src/logic/pricing/calculator.js"; +import { initialState, PRICING } from "@mintel/pdf"; +import { calculateTotals } from "@mintel/pdf"; async function main() { const OPENROUTER_KEY = process.env.OPENROUTER_KEY; diff --git a/apps/web/scripts/generate-estimate.ts b/apps/web/scripts/generate-estimate.ts index 65dabb2..c9cf332 100644 --- a/apps/web/scripts/generate-estimate.ts +++ b/apps/web/scripts/generate-estimate.ts @@ -4,9 +4,8 @@ import * as readline from "node:readline/promises"; import { fileURLToPath } from "node:url"; import { createElement } from "react"; import { renderToFile } from "@react-pdf/renderer"; -import { calculateTotals } from "../src/logic/pricing/calculator.js"; +import { calculateTotals, initialState, PRICING } from "@mintel/pdf"; import { CombinedQuotePDF } from "../src/components/CombinedQuotePDF.js"; -import { initialState, PRICING } from "../src/logic/pricing/constants.js"; import { getTechDetails, getPrinciples, diff --git a/apps/web/src/components/AgbsPDF.tsx b/apps/web/src/components/AgbsPDF.tsx index 66a1561..3f18e18 100644 --- a/apps/web/src/components/AgbsPDF.tsx +++ b/apps/web/src/components/AgbsPDF.tsx @@ -13,8 +13,8 @@ import { Footer, FoldingMarks, DocumentTitle, -} from "./pdf/SharedUI"; -import { SimpleLayout } from "./pdf/SimpleLayout"; + SimpleLayout, +} from "@mintel/pdf"; const localStyles = PDFStyleSheet.create({ sectionContainer: { diff --git a/apps/web/src/components/CombinedQuotePDF.tsx b/apps/web/src/components/CombinedQuotePDF.tsx index 5e0bf44..7eb9d5c 100644 --- a/apps/web/src/components/CombinedQuotePDF.tsx +++ b/apps/web/src/components/CombinedQuotePDF.tsx @@ -2,10 +2,12 @@ import * as React from "react"; import { Document as PDFDocument } from "@react-pdf/renderer"; -import { EstimationPDF } from "./EstimationPDF"; -import { AgbsPDF } from "./AgbsPDF"; -import { ClosingModule } from "./pdf/modules/CommonModules"; -import { SimpleLayout } from "./pdf/SimpleLayout"; +import { + EstimationPDF, + AgbsPDF, + ClosingModule, + SimpleLayout, +} from "@mintel/pdf"; interface CombinedProps { estimationProps: any; diff --git a/apps/web/src/components/ContactForm.tsx b/apps/web/src/components/ContactForm.tsx index 12d94a8..d7ba925 100644 --- a/apps/web/src/components/ContactForm.tsx +++ b/apps/web/src/components/ContactForm.tsx @@ -17,7 +17,7 @@ import * as confetti from "canvas-confetti"; import { FormState, Step } from "./ContactForm/types"; import { PRICING, initialState } from "./ContactForm/constants"; -import { calculateTotals } from "../logic/pricing/calculator"; +import { calculateTotals } from "@mintel/pdf"; import { PriceCalculation } from "./ContactForm/components/PriceCalculation"; import { ShareModal } from "./ShareModal"; diff --git a/apps/web/src/components/ContactForm/components/PriceCalculation.tsx b/apps/web/src/components/ContactForm/components/PriceCalculation.tsx index f947775..1c438ae 100644 --- a/apps/web/src/components/ContactForm/components/PriceCalculation.tsx +++ b/apps/web/src/components/ContactForm/components/PriceCalculation.tsx @@ -49,7 +49,7 @@ export function PriceCalculation({ setPdfLoading(true); try { - const { EstimationPDF } = await import("../../EstimationPDF"); + const { EstimationPDF } = await import("@mintel/pdf"); const doc = ( logicCalculatePositions(state as any, pricing); +export const calculatePositions = (state: FormState, pricing: any) => + logicCalculatePositions(state as any, pricing); diff --git a/apps/web/src/components/EstimationPDF.tsx b/apps/web/src/components/EstimationPDF.tsx deleted file mode 100644 index 0f2d70f..0000000 --- a/apps/web/src/components/EstimationPDF.tsx +++ /dev/null @@ -1,157 +0,0 @@ -"use client"; - -import * as React from "react"; -import { calculatePositions } from "../logic/pricing"; -import { Page as PDFPage } from "@react-pdf/renderer"; -import { pdfStyles } from "./pdf/SharedUI"; -import { DINLayout } from "./pdf/DINLayout"; -import { SimpleLayout } from "./pdf/SimpleLayout"; - -// Modules -import { FrontPageModule } from "./pdf/modules/FrontPageModule"; -import { BriefingModule } from "./pdf/modules/BriefingModule"; -import { SitemapModule } from "./pdf/modules/SitemapModule"; -import { EstimationModule } from "./pdf/modules/EstimationModule"; -import { - TransparenzModule, - techPageModule as TechPageModule, - MaintenanceModule, - StandardsModule, -} from "./pdf/modules/CommonModules"; -import { AboutModule, CrossSellModule } from "./pdf/modules/BrandingModules"; - -interface PDFProps { - state: any; - totalPrice: number; - monthlyPrice: number; - totalPagesCount: number; - pricing: any; - mode?: "estimation" | "full"; - headerIcon?: string; - footerLogo?: string; - techDetails?: { t: string; d: string }[]; - principles?: { t: string; d: string }[]; - maintenanceDetails?: { t: string; d: string }[]; - standardsDetails?: { t: string; d: string }[]; -} - -export const EstimationPDF = ({ - state, - totalPrice, - pricing, - mode = "full", - headerIcon, - footerLogo, - techDetails, - principles, - maintenanceDetails, - standardsDetails, - ...props -}: 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 = { - state, - date, - icon: headerIcon, - footerLogo, - companyData, - bankData, - }; - - if (mode === "estimation") { - return ( - - - - ); - } - - // Full Portfolio Mode - let pageCounter = 1; - const getPageNum = () => (pageCounter++).toString().padStart(2, "0"); - - return ( - <> - - - - - - - - - {state.sitemap && state.sitemap.length > 0 && ( - - - - )} - - - - - - - - - - {standardsDetails && standardsDetails.length > 0 && ( - - - - )} - - {techDetails && techDetails.length > 0 && ( - - - - )} - - {maintenanceDetails && maintenanceDetails.length > 0 && ( - - - - )} - - - - - - - - - - ); -}; diff --git a/apps/web/src/components/pdf/DINLayout.tsx b/apps/web/src/components/pdf/DINLayout.tsx deleted file mode 100644 index 751aaad..0000000 --- a/apps/web/src/components/pdf/DINLayout.tsx +++ /dev/null @@ -1,55 +0,0 @@ -'use client'; - -import * as React from 'react'; -import { Page as PDFPage } from '@react-pdf/renderer'; -import { FoldingMarks, Header, Footer, pdfStyles } from './SharedUI'; - -interface DINLayoutProps { - children: React.ReactNode; - sender?: string; - recipient?: { - title: string; - subtitle?: string; - address?: string; - phone?: string; - email?: string; - taxId?: string; - }; - icon?: string; - footerLogo?: string; - companyData: any; - bankData: any; - showAddress?: boolean; - showFooterDetails?: boolean; -} - -export const DINLayout = ({ - children, - sender, - recipient, - icon, - footerLogo, - companyData, - bankData, - showAddress = true, - showFooterDetails = true -}: DINLayoutProps) => { - return ( - - -
- {children} -