From 658b2b345fbfc5e1c2dc5c3d113cbc3d3cd230c3 Mon Sep 17 00:00:00 2001 From: Srinath Date: Thu, 5 Mar 2026 12:12:12 +0530 Subject: [PATCH] Implement dynamic header and table color functionality --- .../PrintStyleDCToInvoice12.jsx | 66 +++++++++++++++---- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice12.jsx b/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice12.jsx index 8c348b2..1b110a2 100644 --- a/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice12.jsx +++ b/src/Pages/DeliveryChallanToInvoice/PrintTemplates/PrintStyleDCToInvoice12.jsx @@ -1,6 +1,6 @@ import { useMemo } from "react"; import { useSelector } from "react-redux"; -import { GloabalFieldDetails } from "../../../Features/ThemeChange/ThemeChange"; +import { GloabalDCtoInvoiceFieldDetails, GloabalFieldDetails } from "../../../Features/ThemeChange/ThemeChange"; import { dateFormatChange1 } from "../../../Services/Others"; const PrintStyleDCToInvoice12 = ({ invoiceData, preference, printDatas }) => { @@ -18,7 +18,7 @@ const PrintStyleDCToInvoice12 = ({ 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; @@ -45,6 +45,33 @@ const PrintStyleDCToInvoice12 = ({ invoiceData, preference, printDatas }) => { const lastChunkRows = paginatedChunks.at(-1)?.length || 0; const shouldFooterBeOnNewPage = lastChunkRows > (pageSize === "A5" ? 5 : 10); + 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 getPageStyle = (isFinalFooterPage) => ({ display: "flex", @@ -55,7 +82,7 @@ const PrintStyleDCToInvoice12 = ({ invoiceData, preference, printDatas }) => { }); const renderFooter = () => ( -
+
{(notesText || termsAndConditions || signature || printGreeting?.SettingValue === "Y") && ( <> {notesText &&

{notesText}

} @@ -99,6 +126,7 @@ const PrintStyleDCToInvoice12 = ({ invoiceData, preference, printDatas }) => { DCNo={DCNo} InvoiceDate={InvoiceDate} VehicleNo={VehicleNo} + headerStyle={headerStyle} /> ); @@ -117,7 +145,7 @@ const PrintStyleDCToInvoice12 = ({ invoiceData, preference, printDatas }) => { >
{(chunkIndex === 0 || formatTheme) && } - + {isLastPage && ( <>
@@ -125,6 +153,7 @@ const PrintStyleDCToInvoice12 = ({ invoiceData, preference, printDatas }) => { TotalAmount={TotalAmount} TaxAmount={TaxAmount} GrandTotal={GrandTotal} + netAmountStyle={netAmountStyle} />
@@ -138,12 +167,13 @@ const PrintStyleDCToInvoice12 = ({ invoiceData, preference, printDatas }) => { ) : (
- +

{renderFooter()} @@ -157,8 +187,8 @@ export default PrintStyleDCToInvoice12; // COMPONENTS -const Header = ({ CustMobile, CustName, logo, branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo }) => ( -
+const Header = ({ CustMobile, CustName, logo, branch, InvoiceNo, DCNo, InvoiceDate, VehicleNo,headerStyle }) => ( +
{branch?.CompName}
@@ -184,7 +214,7 @@ const Header = ({ CustMobile, CustName, logo, branch, InvoiceNo, DCNo, InvoiceDa
); -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' }, @@ -196,9 +226,9 @@ const ProductTable = ({ data }) => { ]; return ( - +
- + {columns.map(col => ( ))} @@ -206,7 +236,17 @@ const ProductTable = ({ data }) => { {data.map((prod, index) => ( - + @@ -221,8 +261,8 @@ const ProductTable = ({ data }) => { ); }; -const Summary = ({ TotalAmount, TaxAmount, GrandTotal }) => ( -
+const Summary = ({ TotalAmount, TaxAmount, GrandTotal ,netAmountStyle}) => ( +
Subtotal
{col.label}
{index + 1} {prod.ProdName} {prod.ProdVariantName}