From cace8e092e22207b9d31f24968a79966dac3d799 Mon Sep 17 00:00:00 2001 From: Srinath Date: Thu, 5 Mar 2026 12:09:58 +0530 Subject: [PATCH] Implement dynamic header and table color functionality --- .../PrintTemplates/PrintStyleDCToInvoice8.jsx | 67 +++++++++++++++---- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice8.jsx b/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice8.jsx index df615aa..6b02227 100644 --- a/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice8.jsx +++ b/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice8.jsx @@ -1,6 +1,6 @@ import { useMemo } from "react"; import { useSelector } from "react-redux"; -import { GloabalFieldDetails } from "../../../Features/ThemeChange/ThemeChange"; // Fix typo if needed +import { GloabalDCtoInvoiceFieldDetails, GloabalFieldDetails } from "../../../Features/ThemeChange/ThemeChange"; // Fix typo if needed import { dateFormatChange1 } from "../../../Services/Others"; const PrintStyleDCToInvoice8 = ({ invoiceData, preference, printDatas }) => { @@ -18,7 +18,7 @@ const PrintStyleDCToInvoice8 = ({ invoiceData, preference, printDatas }) => { VehicleNo } = invoiceData; - const fieldDetails = useSelector(GloabalFieldDetails); + const fieldDetails = useSelector(GloabalDCtoInvoiceFieldDetails); const signature = fieldDetails?.["signature"]; const termsAndConditions = fieldDetails?.["terms&conditions"]; const termsAndConditionsData = printDatas?.TermsandConditions; @@ -52,9 +52,36 @@ const PrintStyleDCToInvoice8 = ({ invoiceData, preference, printDatas }) => { height: pageSize === "A5" ? "170mm" : "98vh", maxHeight: "98vh" }); + let printColors = printDatas?.PrintColors; + const headerColor = printColors?.find(obj => obj.headerColor)?.headerColor; + const tableHeaderColor = printColors?.find(obj => obj.tableHeaderColor)?.tableHeaderColor; + const tableBodyColor = printColors?.find(obj => obj.tableBodyColor)?.tableBodyColor; + const footerColor = printColors?.find(obj => obj.footerColor)?.footerColor; + const netAmtColor = printColors?.find(obj => obj.netAmtColor)?.netAmtColor; + const headerStyle = { + backgroundColor: headerColor?.background, + color: headerColor?.font, + } + const tableHeaderStyle = { + backgroundColor: tableHeaderColor?.background, + color: tableHeaderColor?.font, + } + const tableBodyStyle = { + backgroundColor: tableBodyColor?.background, + color: tableBodyColor?.font, + } + const rowtypeStyle = tableBodyColor?.rowType; + const footerColorStyle = { + backgroundColor: footerColor?.background, + color: footerColor?.font, + } + const netAmountStyle = { + backgroundColor: netAmtColor?.background, + color: netAmtColor?.font, + } const renderFooter = () => ( -
+
{(notesText || termsAndConditions || signature || printGreeting?.SettingValue === "Y") && ( <> {notesText &&

{notesText}

} @@ -92,6 +119,7 @@ const PrintStyleDCToInvoice8 = ({ invoiceData, preference, printDatas }) => { DCNo={DCNo} InvoiceDate={InvoiceDate} VehicleNo={VehicleNo} + headerStyle={headerStyle} /> ); @@ -110,7 +138,7 @@ const PrintStyleDCToInvoice8 = ({ invoiceData, preference, printDatas }) => { >
{(chunkIndex === 0 || formatTheme) && } - + {isLastPage && ( <>
@@ -118,6 +146,7 @@ const PrintStyleDCToInvoice8 = ({ invoiceData, preference, printDatas }) => { TotalAmount={TotalAmount} TaxAmount={TaxAmount} GrandTotal={GrandTotal} + netAmountStyle={netAmountStyle} />
{ ) : (
- +

@@ -155,8 +185,8 @@ export default PrintStyleDCToInvoice8; // COMPONENTS -const Header = ({ branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo }) => ( -
+const Header = ({ branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo,headerStyle }) => ( +
{branch?.CompName}
{branch?.Address1}-{branch?.City}-{branch?.Zip}
@@ -177,7 +207,7 @@ const Header = ({ branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo }) => (
); -const ProductTable = ({ data }) => { +const ProductTable = ({ data,tableHeaderStyle,tableBodyStyle,rowtypeStyle }) => { const columns = [ { label: "S.No", key: "sno", width: "5%", align: 'center' }, { label: "Product", key: "ProdName", width: "35%", align: 'center' }, @@ -189,9 +219,9 @@ const ProductTable = ({ data }) => { ]; return ( - +
- + {columns.map(col => ( ))} @@ -199,7 +229,18 @@ const ProductTable = ({ data }) => { {data.map((prod, index) => ( - + @@ -214,8 +255,8 @@ const ProductTable = ({ data }) => { ); }; -const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( -
+const Summary = ({ TotalAmount, TaxAmount, GrandTotal,netAmountStyle }) => ( +
Subtotal
:
{col.label}
{index + 1} {prod.ProdName} {prod.ProdVariantName}