From 83fe92d412923521bce5e8c2561265a088ca624b Mon Sep 17 00:00:00 2001 From: Srinath Date: Tue, 3 Mar 2026 19:59:06 +0530 Subject: [PATCH] Implement dynamic header and table color functionality --- .../PurchasePrintTemplate/PurPrintStyleA5.jsx | 331 +++++++++++------- 1 file changed, 206 insertions(+), 125 deletions(-) diff --git a/src/Pages/PurchaseQuotation/PurchasePrintTemplate/PurPrintStyleA5.jsx b/src/Pages/PurchaseQuotation/PurchasePrintTemplate/PurPrintStyleA5.jsx index 9f184f6..97e6aea 100644 --- a/src/Pages/PurchaseQuotation/PurchasePrintTemplate/PurPrintStyleA5.jsx +++ b/src/Pages/PurchaseQuotation/PurchasePrintTemplate/PurPrintStyleA5.jsx @@ -10,7 +10,21 @@ import { printDiv } from "../../../Services/Others"; // import HpyImg from "../../../Images/happyemoji.png" import '../../../Styles/BookingScreen/PrintTemplates/A4/PrintA4Style11.scss' import { useSelector } from 'react-redux'; -import { GloabalFieldDetails, GlobalBillName, Globalnotes, GlobalprintAmount, GlobalprintDiscount, GlobalprintHsnCode, GlobalprintItem, GlobalprintMRP, GlobalprintQrcodet, GlobalprintQuantity, GlobalprintRate, GlobalprintSignature, GlobalprintSlNo, GlobalprinttermsAndConditions, GlobalPritdummyData, GlobalSignatureImage, GlobalthemeFormat } from '../../../Features/ThemeChange/ThemeChange'; +import { + Globalnotes, GlobalprintRate, GlobalprintSignature, GlobalprinttermsAndConditions, GlobalSignatureImage, GlobalthemeFormat, + GlobalSelectedPrintHeaderColor, + GlobalSelectedPrintHeaderFontColor, + GlobalSelectedTableHeaderColor, + GlobalSelectedTableHeaderFontColor, + GlobalSelectedTableBodyColor, + GlobalSelectedTableBodyFontColor, + GlobalRowType, + GlobalSelectedFooterColor, + GlobalSelectedFooterFontColor, + GlobalSelectedNetAmountColor, + GlobalSelectedNetAmountFontColor, + GlobalPritdummyData, +} from '../../../Features/ThemeChange/ThemeChange'; import signature from "../../../Images/signatureimage.jpg" import QRCode from 'react-qr-code'; import { isMobile } from 'react-device-detect'; @@ -21,13 +35,24 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t const GlobalSignature = useSelector(GlobalprintSignature); const GlobaltermsAndConditions = useSelector(GlobalprinttermsAndConditions); // const FieldDetails = useSelector(GloabalFieldDetails); - const FieldDetails = printDatas?.FieldDetails?.reduce((acc, item) => { - acc[item.ConfigName] = true; - return acc; - }, {}); + const FieldDetails = printDatas?.FieldDetails?.reduce((acc, item) => { + acc[item.ConfigName] = true; + return acc; + }, {}); const GlobalIsnotes = useSelector(Globalnotes); const GlobalSignatureImages = useSelector(GlobalSignatureImage); - console.log(FieldDetails, "FieldDetails") + const GlobaldummyData = useSelector(GlobalPritdummyData); + const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor); + const SelectedHeaderFontColor = useSelector(GlobalSelectedPrintHeaderFontColor); + const SelectedTableHeaderColor = useSelector(GlobalSelectedTableHeaderColor); + const SelectedTableHeaderFontColor = useSelector(GlobalSelectedTableHeaderFontColor); + const SelectedTableBodyColor = useSelector(GlobalSelectedTableBodyColor); + const SelectedTableBodyFontColor = useSelector(GlobalSelectedTableBodyFontColor); + const SelectedRowType = useSelector(GlobalRowType); + const SelectedTableFooterColor = useSelector(GlobalSelectedFooterColor); + const SelectedTableFooterFontColor = useSelector(GlobalSelectedFooterFontColor); + const SelectedNetAmountColor = useSelector(GlobalSelectedNetAmountColor); + const SelectedNetAmountFontColor = useSelector(GlobalSelectedNetAmountFontColor); const SLNO = FieldDetails?.["Sl.No"]; const Item = FieldDetails?.["Item"]; const MRP = FieldDetails?.["MRP"]; @@ -40,6 +65,12 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t const Signature = FieldDetails?.["signature"]; const TermsnAdCondition = FieldDetails?.["terms&conditions"]; const isNotes = FieldDetails?.["Notes"]; + 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 currentDate = new Date(); console.log(FieldDetails, "FieldDetails") @@ -88,7 +119,51 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t } const lastChunkRows = paginatedChunks.length > 0 ? paginatedChunks[paginatedChunks.length - 1].length : 0; const shouldFooterBeOnNewPage = lastChunkRows > 6; + const headerStyle = { + backgroundColor: GlobaldummyData + ? SelectedHeaderColor + : headerColor?.background, + color: GlobaldummyData + ? SelectedHeaderFontColor + : headerColor?.font, + } + const tableHeaderStyle = { + backgroundColor: GlobaldummyData + ? SelectedTableHeaderColor + : tableHeaderColor?.background, + + color: GlobaldummyData + ? SelectedTableHeaderFontColor + : tableHeaderColor?.font, + } + const tableBodyStyle = { + backgroundColor: GlobaldummyData + ? SelectedTableBodyColor + : tableBodyColor?.background, + color: GlobaldummyData + ? SelectedTableBodyFontColor + : tableBodyColor?.font, + } + const rowtypeStyle = GlobaldummyData ? SelectedRowType : tableBodyColor?.rowType; + const footerColorStyle = { + backgroundColor: GlobaldummyData + ? SelectedTableFooterColor + : footerColor?.background, + + color: GlobaldummyData + ? SelectedTableFooterFontColor + : footerColor?.font, + } + const netAmountStyle = { + backgroundColor: GlobaldummyData + ? SelectedNetAmountColor + : netAmtColor?.background, + + color: GlobaldummyData + ? SelectedNetAmountFontColor + : netAmtColor?.font, + } return (
{paginatedChunks.map((dataChunk, chunkIndex) => ( -
+
-
+
{/* Logo Image */} - {/* {base64Image && ( -
- Brand Logo -
- )} */} + {base64Image && ( +
+ Brand Logo +
+ )} {/* Store Info */}
- {table2Data?.[0]?.BranchName} + {table2Data?.[0]?.BranchName}
{/* Address */} @@ -157,7 +232,7 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t return
{parts}
; })}
- Mobile: +91 {table2Data?.customerMobile} + Mobile: +91 {table2Data?.customerMobile}
{/* Order Type */} @@ -167,19 +242,6 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t
- - {/*
-
- {table2Data?.OrderType === "E" - ? "Estimate" - : (GlobaldummyData - ? "Cash" - : PaymentStatusSuccess?.length === 1 - ? PaymentStatusSuccess?.[0]?.PaymentTypeName - : "") + table2Data?.OrderId && "Cash: " + extractLastNumberOrderId(table2Data?.OrderId, table2Data?.FYStatus)} {GlobaldummyData && "685"} -
-
*/} -
@@ -211,7 +273,7 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t
- +
@@ -229,21 +291,21 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t - {SLNO == true && } - {Item == true && } + {SLNO == true && } + {Item == true && } {HsnCode == true && ( - + )} {Quantity == true && ( - + )} - {MRP == true && } - {Rate == true && } + {MRP == true && } + {Rate == true && } {Discount == true && ( - + )} {Amount == true && ( - )} @@ -252,7 +314,18 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t {dataChunk?.map((item, index) => ( - + {SLNO == true && (
S.NoItemS.NoItemHSNHSNQtyQtyMRPRateMRPRateDis Dis + Amt
{chunkIndex * chunkSize + index + 1} @@ -357,7 +430,7 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t {/*
{GlobaldummyData ? "1066" : Number(table2Data?.NetAmount).toFixed(2)}
*/} -
Amount :{Number(dataSource?.[0]?.NetAmt).toFixed(2)}
+
Amount :{Number(dataSource?.[0]?.NetAmt).toFixed(2)}
@@ -428,33 +501,36 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t
{Date1}
- {Notestext && ( -
-

{Notestext}

-
+
+ {Notestext && ( +
+

{Notestext}

+
+
+ )} + + +
+ {(TermsnAdCondition == true && TermsAndConditions?.length > 0) && ( +
+

+ Terms & Conditions +

+
    + {TermsAndConditions?.map(item => (
  1. {item?.TermsandConditions}
  2. ))} +
+
+ )} + {Signature == true && ( +
+

Signature

+ +
+ )} +
- )} - - -
- {(TermsnAdCondition == true && TermsAndConditions?.length > 0) && ( -
-

- Terms & Conditions -

-
    - {TermsAndConditions?.map(item => (
  1. {item?.TermsandConditions}
  2. ))} -
-
- )} - {Signature == true && ( -
-

Signature

- -
- )} -
+
}
@@ -509,7 +585,7 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t {/*
{GlobaldummyData ? "1066" : Number(table2Data?.NetAmount).toFixed(2)}
*/}
-
Amount :{Number(dataSource?.[0]?.NetAmt).toFixed(2)}
+
Amount :{Number(dataSource?.[0]?.NetAmt).toFixed(2)}
@@ -580,32 +656,34 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t
{Date1}
- {Notestext && ( -
-

{Notestext}

-
+
+ {Notestext && ( +
+

{Notestext}

+
+
+ )} + + +
+ {(TermsnAdCondition == true && TermsAndConditions?.length > 0) && ( +
+

+ Terms & Conditions +

+
    + {TermsAndConditions?.map(item => (
  1. {item?.TermsandConditions}
  2. ))} +
+
+ )} + {Signature == true && ( +
+

Signature

+ +
+ )} +
- )} - - -
- {(TermsnAdCondition == true && TermsAndConditions?.length > 0) && ( -
-

- Terms & Conditions -

-
    - {TermsAndConditions?.map(item => (
  1. {item?.TermsandConditions}
  2. ))} -
-
- )} - {Signature == true && ( -
-

Signature

- -
- )} -
)} @@ -648,7 +726,7 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t {/*
{GlobaldummyData ? "1066" : Number(table2Data?.NetAmount).toFixed(2)}
*/}
-
Amount :{Number(table2Data?.NetAmount).toFixed(2)}
+
Amount :{Number(table2Data?.NetAmount).toFixed(2)}
@@ -719,33 +797,36 @@ const PurPrintStyleA5 = ({ index, ExtraChargeTotal, UpiId, Date1, base64Image, t
{Date1}
- {Notestext && ( -
-

{Notestext}

-
+
+ {Notestext && ( +
+

{Notestext}

+
+
+ )} + + +
+ {(TermsnAdCondition == true && TermsAndConditions?.length > 0) && ( +
+

+ Terms & Conditions +

+
    + {TermsAndConditions?.map(item => (
  1. {item?.TermsandConditions}
  2. ))} +
+
+ )} + {Signature == true && ( +
+

Signature

+ +
+ )} +
- )} - - -
- {(TermsnAdCondition == true && TermsAndConditions?.length > 0) && ( -
-

- Terms & Conditions -

-
    - {TermsAndConditions?.map(item => (
  1. {item?.TermsandConditions}
  2. ))} -
-
- )} - {Signature == true && ( -
-

Signature

- -
- )} -
+
)}