Implement dynamic header and table color functionality
This commit is contained in:
parent
4ca848b955
commit
b659bec211
|
|
@ -4,6 +4,17 @@ import {
|
|||
GlobalPritdummyData,
|
||||
changeReprintDataFound,
|
||||
GlobalprinttermsAndConditions,
|
||||
GlobalSelectedPrintHeaderColor,
|
||||
GlobalSelectedPrintHeaderFontColor,
|
||||
GlobalSelectedTableHeaderColor,
|
||||
GlobalSelectedTableHeaderFontColor,
|
||||
GlobalSelectedTableBodyColor,
|
||||
GlobalSelectedTableBodyFontColor,
|
||||
GlobalRowType,
|
||||
GlobalSelectedFooterColor,
|
||||
GlobalSelectedFooterFontColor,
|
||||
GlobalSelectedNetAmountColor,
|
||||
GlobalSelectedNetAmountFontColor,
|
||||
} from '../../../Features/ThemeChange/ThemeChange'
|
||||
import '../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle5.scss'
|
||||
import { extractLastNumber } from "../../../Services/Others";
|
||||
|
|
@ -33,6 +44,17 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
|
||||
const GlobaldummyData = useSelector(GlobalPritdummyData);
|
||||
const GlobaltermsAndConditions = useSelector(GlobalprinttermsAndConditions);
|
||||
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);
|
||||
|
||||
|
||||
let TermsAndConditions = printDatas?.TermsandConditions
|
||||
|
|
@ -61,10 +83,12 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
const TakeawayData = table2Data?.[0]?.ProductDetails
|
||||
console.log(TakeawayData, "TakeawayData", table2Data)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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;
|
||||
let TotalOfferAmount = 0;
|
||||
|
||||
// Calculate SalesWiseOffers total amount
|
||||
|
|
@ -82,7 +106,51 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
}
|
||||
const lastChunkRows = paginatedChunks.length > 0 ? paginatedChunks[paginatedChunks.length - 1].length : 0;
|
||||
const shouldFooterBeOnNewPage = lastChunkRows > (PageSize == "A5" ? 2 : 10);
|
||||
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 (
|
||||
<>
|
||||
{FormatTheme ?
|
||||
|
|
@ -92,7 +160,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
|
||||
{/* <div className="header" style={{ position: "fixed", top: 0, width: "100%" }}> */}
|
||||
<div className="header" style={{ position: isMobile ? GlobaldummyData ? "absolute" : "fixed" : "", top: 0, width: "100%" }}>
|
||||
<div className="PrintStyle5-Head">
|
||||
<div className="PrintStyle5-Head" style={{...headerStyle}}>
|
||||
<div>
|
||||
<div style={{ fontSize: 'clamp(2rem, 2.5vw, 2rem)', fontWeight: '600' }}>{table2Data?.[0]?.BrName}</div>
|
||||
|
||||
|
|
@ -104,9 +172,8 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
</div>
|
||||
<div style={{ fontSize: "14px", fontWeight: '600' }}> Mobile :{GlobaldummyData ? '1234567890' : table2Data?.[0]?.BrMobile} </div>
|
||||
{<div style={{ textTransform: 'uppercase' }}>{BillName} </div>}
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
|
||||
<div style={{ display: "flex", justifyContent: "space-between", fontSize: "14px", fontWeight: '600' }}>
|
||||
|
|
@ -121,7 +188,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
<div style={{ marginTop: GlobaldummyData ? "9rem" : "0rem" }} className="print-body">
|
||||
{(TakeawayData?.length > 0 || GlobaldummyData) &&
|
||||
<>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", fontWeight: '600', fontSize: 'clamp(1rem, 2.5vw, 1.2rem)', width: '100%', gap: '0.5rem' }}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", fontWeight: '600', fontSize: 'clamp(1rem, 2.5vw, 1.2rem)', width: '100%', gap: '0.5rem', ...tableHeaderStyle }}>
|
||||
{GlobaldummyData ? GlobalSlNo && <div style={{ width: '100%', textAlign: 'center' }}>S.No</div> : SLNO && <div style={{ width: '100%', textAlign: 'center' }}>S.No</div>}
|
||||
{GlobaldummyData ? (GlobalItem || GlobalQuantity) &&
|
||||
<div style={{ width: '300%', textAlign: 'center' }} > {GlobaldummyData ? GlobalItem && 'ITEM /DES /' : 'ITEM /DES /'} {GlobaldummyData ? GlobalQuantity && 'QTY' : 'QTY'} </div> :
|
||||
|
|
@ -136,7 +203,8 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
<hr className="hrline" />
|
||||
|
||||
{dataChunk?.map((item, index) => (
|
||||
<div key={index} className="PrintStyle5-print-prddtls" style={{ display: "flex", justifyContent: "space-between", fontSize: 'clamp(1rem, 2.5vw, 1.2rem)', fontWeight: '600', width: '100%', gap: '0.5rem' }}>
|
||||
<div key={index} className="PrintStyle5-print-prddtls" style={{ ...(rowtypeStyle === (index % 2 === 0 ? "even" : "odd")? tableBodyStyle
|
||||
: {}),display: "flex", justifyContent: "space-between", fontSize: 'clamp(1rem, 2.5vw, 1.2rem)', fontWeight: '600', width: '100%', gap: '0.5rem' }}>
|
||||
{SLNO && <div style={{ width: '100%', textAlign: 'center' }}>{chunkIndex * chunkSize + index + 1}</div>}
|
||||
{
|
||||
GlobaldummyData ? (GlobalItem || GlobalQuantity) &&
|
||||
|
|
@ -331,7 +399,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
|
||||
<hr className="hrline" />
|
||||
|
||||
<div className="align-style" style={{ fontWeight: '600', fontSize: '19px' }}> <div>Amount </div> <div> : </div> <div>{GlobaldummyData ? '1,066' : Number(table2Data?.[0]?.NetAmount).toFixed(2)}</div> </div>
|
||||
<div className="align-style" style={{...netAmountStyle, fontWeight: '600', fontSize: '19px' }}> <div>Amount </div> <div> : </div> <div>{GlobaldummyData ? '1,066' : Number(table2Data?.[0]?.NetAmount).toFixed(2)}</div> </div>
|
||||
|
||||
<hr className="hrline" />
|
||||
{/*
|
||||
|
|
@ -379,6 +447,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
pageBreakBefore: "avoid",
|
||||
pageBreakInside: "avoid",
|
||||
minHeight: "auto",
|
||||
...footerColorStyle
|
||||
}}
|
||||
>
|
||||
{GlobaldummyData ? GlobalIsnotes &&
|
||||
|
|
@ -590,7 +659,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
|
||||
<hr className="hrline" />
|
||||
|
||||
<div className="align-style" style={{ fontWeight: '600', fontSize: '19px' }}> <div>Amount </div> <div> : </div> <div>{GlobaldummyData ? '1,066' : Number(table2Data?.NetAmount).toFixed(2)}</div> </div>
|
||||
<div className="align-style" style={{...netAmountStyle, fontWeight: '600', fontSize: '19px' }}> <div>Amount </div> <div> : </div> <div>{GlobaldummyData ? '1,066' : Number(table2Data?.NetAmount).toFixed(2)}</div> </div>
|
||||
|
||||
<hr className="hrline" />
|
||||
|
||||
|
|
@ -634,6 +703,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
pageBreakBefore: "avoid",
|
||||
pageBreakInside: "avoid",
|
||||
minHeight: "auto",
|
||||
...footerColorStyle
|
||||
}}
|
||||
>
|
||||
{
|
||||
|
|
@ -681,7 +751,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
:
|
||||
<div className="PrintStyle5-MasterDiv" id={`SQPrintStyle5`} style={{ fontFamily: "'Courier New', Courier, monospace" }} >
|
||||
|
||||
<div className="PrintStyle5-Head">
|
||||
<div className="PrintStyle5-Head" style={{...headerStyle}}>
|
||||
<div>
|
||||
<div style={{ fontSize: 'clamp(2rem, 2.5vw, 2rem)', fontWeight: '600' }}>{table2Data?.[0]?.BrName}</div>
|
||||
|
||||
|
|
@ -692,15 +762,9 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
</div>
|
||||
<div style={{ fontSize: "14px", fontWeight: '600' }}> Mobile :{GlobaldummyData ? '1234567890' : table2Data?.[0]?.BrMobile} </div>
|
||||
{<div style={{ textTransform: 'uppercase' }}>{BillName}</div>}
|
||||
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<hr />
|
||||
<div className="PrintStyle5-print-table">
|
||||
|
||||
|
||||
<div style={{ display: "flex", justifyContent: "space-between", fontSize: "14px", fontWeight: '600' }}>
|
||||
{" "}
|
||||
<div> {GlobaldummyData ? formattedDate : Date1} </div>{" "}
|
||||
|
|
@ -710,7 +774,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
<hr />
|
||||
{(TakeawayData?.length > 0) &&
|
||||
<>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", fontWeight: '600', fontSize: 'clamp(1rem, 2.5vw, 1.2rem)', width: '100%', gap: '0.5rem' }}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", fontWeight: '600', fontSize: 'clamp(1rem, 2.5vw, 1.2rem)', width: '100%', gap: '0.5rem', ...tableHeaderStyle }}>
|
||||
{
|
||||
SLNO && <div style={{ width: '100%', textAlign: 'center' }}>S.No</div>}
|
||||
{
|
||||
|
|
@ -727,7 +791,8 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
<hr className="hrline" />
|
||||
|
||||
{(TakeawayData)?.map((item, index) => (
|
||||
<div key={index} className="PrintStyle5-print-prddtls" style={{ display: "flex", justifyContent: "space-between", fontSize: 'clamp(1rem, 2.5vw, 1.2rem)', fontWeight: '600', width: '100%', gap: '0.5rem' }}>
|
||||
<div key={index} className="PrintStyle5-print-prddtls" style={{ ...(rowtypeStyle === (index % 2 === 0 ? "even" : "odd")? tableBodyStyle
|
||||
: {}), display: "flex", justifyContent: "space-between", fontSize: 'clamp(1rem, 2.5vw, 1.2rem)', fontWeight: '600', width: '100%', gap: '0.5rem' }}>
|
||||
{SLNO && <div style={{ width: '100%', textAlign: 'center' }}>{index + 1}</div>}
|
||||
{
|
||||
|
||||
|
|
@ -907,7 +972,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
|
||||
<hr className="hrline" />
|
||||
|
||||
<div className="align-style" style={{ fontWeight: '600', fontSize: '19px' }}> <div>Amount </div> <div> : </div> <div>{GlobaldummyData ? '1,066' : Number(table2Data?.[0]?.NetAmount).toFixed(2)}</div> </div>
|
||||
<div className="align-style" style={{...netAmountStyle, fontWeight: '600', fontSize: '19px' }}> <div>Amount </div> <div> : </div> <div>{GlobaldummyData ? '1,066' : Number(table2Data?.[0]?.NetAmount).toFixed(2)}</div> </div>
|
||||
|
||||
<hr className="hrline" />
|
||||
{/*
|
||||
|
|
@ -964,6 +1029,7 @@ const PurPrintStyle5 = ({ index, ExtraChargeTotal, totalQuantityFilter, Date1, C
|
|||
pageBreakBefore: "avoid",
|
||||
pageBreakInside: "avoid",
|
||||
minHeight: "auto",
|
||||
...footerColorStyle
|
||||
}}
|
||||
>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue