"use client";

import * as React from "react";
import { Document as PDFDocument } from "@react-pdf/renderer";
import { EstimationPDF } from "./EstimationPDF.js";
import { AgbsPDF } from "./AgbsPDF.js";
import { SimpleLayout } from "./pdf/SimpleLayout.js";
import { ClosingModule } from "./pdf/modules/CommonModules.js";

interface CombinedProps {
  estimationProps: any;
  showAgbs?: boolean;
  techDetails?: any[];
  principles?: any[];
  maintenanceDetails?: any[];
  standardsDetails?: any[];
}

export const CombinedQuotePDF = ({
  estimationProps,
  showAgbs = true,
  techDetails,
  principles,
  maintenanceDetails,
  standardsDetails,
  mode = "full",
}: CombinedProps & { mode?: "estimation" | "full" }) => {
  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 bankData = {
    name: "N26",
    bic: "NTSBDEB1XXX",
    iban: "DE50 1001 1001 2620 4328 65",
  };

  const layoutProps = {
    date,
    icon: estimationProps.headerIcon,
    footerLogo: estimationProps.footerLogo,
    companyData,
    bankData,
  };

  return (
    <PDFDocument
      title={`Mintel - ${estimationProps.state.companyName || estimationProps.state.name}`}
    >
      <EstimationPDF
        {...estimationProps}
        mode={mode}
        techDetails={techDetails}
        principles={principles}
        maintenanceDetails={maintenanceDetails}
        standardsDetails={standardsDetails}
      />
      {showAgbs && (
        <AgbsPDF
          mode={mode}
          headerIcon={estimationProps.headerIcon}
          footerLogo={estimationProps.footerLogo}
        />
      )}
      <SimpleLayout {...layoutProps} pageNumber="END" showPageNumber={false}>
        <ClosingModule />
      </SimpleLayout>
    </PDFDocument>
  );
};
