import React from "react"; import { Text, View, Image, StyleSheet } from "@react-pdf/renderer"; import numbro from "numbro"; const DisplayCustomerInformation = ({ billingDetails } = {}) => { return ( {[ `Client: ${billingDetails.legalName || "NC"}`, billingDetails.billingAddress, // `${billingDetails.zipCode}, ${billingDetails.city}, ${billingDetails.countryCode}`, `TVA: ${billingDetails.taxIdentificationNumber || "NC"}`, `SIREN: ${billingDetails.SIREN || "NC"}`, ] .filter(Boolean) .map((line, index) => ( {line} ))} ); }; const RenderCompanyLogo = ({ logoBase64 } = {}) => { return ( ); }; const RenderTermsOfSale = () => { return { title: "Conditions générales de vente", content: {"ICI TES CGV"}, }; }; const RenderCompanyInformation = ({ company }) => { return { title: "Informations du prestataire", content: ( {`${company?.name}, ${company?.address}, ${company?.postalCode || "-"}, ${company?.city || "-"},\nSIRET: ${company?.identifier}, RCS: ${company?.city} ${company?.RCS}, TVA: ${company?.taxIdentifier || "-"}.\nPour toute question, vous pourrez nous contacter au ${company?.phoneNumber} ou à l'adresse ${company?.supportEmail}.`} ), }; }; const SignatureForm = () => { return { title: "Signature du client", content: ( <> Fait à {"{{Ville de signature;font_size=12}}"}, le {" {{Date;type=datenow;font_size=12}}"} Nom et prénom du signataire:{" "} {"{{Nom et Prénom du signataire;font_size=12}}"} Fonction du signataire: {"{{Fonction du signataire;font_size=12}}"} Téléphone: {"{{type=phone;required=true;font_size=12}}"} Signature: {"{{Sign;type=signature;width=200;height=50}}"} ), }; }; const formatPrice = ({ amount = 0, average = false }) => `${numbro(amount || 0).format({ spaceSeparated: true, thousandSeparated: true, average, mantissa: average ? 1 : 2, })} €`; const Styles = StyleSheet.create({ body: { padding: 40, fontFamily: "Helvetica", fontSize: 12, lineHeight: 1.5, color: "#000", }, section: { marginBottom: 30 }, sectionTitle: { fontSize: 14, opacity: 0.5, marginBottom: 5 }, textParagraph: { marginBottom: 5 }, headerRow: { flexDirection: "row", justifyContent: "space-between", }, leftColumn: { width: "50%", textAlign: "left" }, rightColumn: { width: "50%", textAlign: "right" }, table: { marginBottom: 20 }, tableRow: { flexDirection: "row", justifyContent: "space-between", paddingVertical: 10, borderBottomWidth: 1, borderBottomColor: "#ccc", }, tableColHeaderLeft: { width: "70%", fontWeight: "bold", textAlign: "left" }, tableColHeaderRight: { width: "30%", fontWeight: "bold", textAlign: "right" }, tableColLeft: { width: "70%", textAlign: "left" }, tableColRight: { width: "30%", textAlign: "right" }, summaryRow: { flexDirection: "row", justifyContent: "flex-end", marginTop: 10, }, summaryLabel: { width: "70%", textAlign: "right", paddingRight: 10, fontWeight: "bold", }, summaryValue: { width: "30%", textAlign: "right" }, signatureBox: { width: 200, height: 50, borderWidth: 1, borderStyle: "solid", }, }); export { Styles, formatPrice, DisplayCustomerInformation, RenderTermsOfSale, RenderCompanyLogo, RenderCompanyInformation, SignatureForm, };