Implement dynamic header and table color functionality

This commit is contained in:
Srinath 2026-03-04 16:33:38 +05:30
parent ec17811122
commit 122260c95b
1 changed files with 441 additions and 331 deletions

View File

@ -32,6 +32,17 @@ import {
GlobalPritdummyData, GlobalPritdummyData,
GlobalSignatureImage, GlobalSignatureImage,
GlobalthemeFormat, GlobalthemeFormat,
GlobalSelectedPrintHeaderColor,
GlobalSelectedPrintHeaderFontColor,
GlobalSelectedTableHeaderColor,
GlobalSelectedTableHeaderFontColor,
GlobalSelectedTableBodyFontColor,
GlobalSelectedTableBodyColor,
GlobalRowType,
GlobalSelectedFooterColor,
GlobalSelectedFooterFontColor,
GlobalSelectedNetAmountColor,
GlobalSelectedNetAmountFontColor,
} from '../../../../Features/ThemeChange/ThemeChange'; } from '../../../../Features/ThemeChange/ThemeChange';
import signature from '../../../../Images/signatureimage.jpg'; import signature from '../../../../Images/signatureimage.jpg';
import Logo from '../../../../Images/Logo.jpg'; import Logo from '../../../../Images/Logo.jpg';
@ -102,6 +113,23 @@ const PrintA5Style11 = ({
const GlobalLogo = useSelector(GlobalprintLogo); const GlobalLogo = useSelector(GlobalprintLogo);
const GlobalCredit = useSelector(GlobalprintCredit); const GlobalCredit = useSelector(GlobalprintCredit);
const SettingData = useSelector(PreferenceData); const SettingData = useSelector(PreferenceData);
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 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 estimatePrintHeader = const estimatePrintHeader =
SettingData?.[0]?.SettingDtlDetails?.find( SettingData?.[0]?.SettingDtlDetails?.find(
(setting) => (setting) =>
@ -276,6 +304,51 @@ const PrintA5Style11 = ({
: 0; : 0;
const shouldFooterBeOnNewPage = lastChunkRows > 6; 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 ( return (
<div <div
style={{ style={{
@ -314,6 +387,7 @@ const PrintA5Style11 = ({
justifyContent: 'space-between', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
textAlign: 'left', textAlign: 'left',
...headerStyle
}} }}
> >
<div <div
@ -450,7 +524,7 @@ const PrintA5Style11 = ({
padding: '0rem 1rem', padding: '0rem 1rem',
fontSize: 'clamp(0.7rem, 2.5vw, 0.8rem)', fontSize: 'clamp(0.7rem, 2.5vw, 0.8rem)',
flexDirection: 'column', flexDirection: 'column',
textAlign:'left' textAlign: 'left'
}} }}
> >
{' '} {' '}
@ -508,6 +582,7 @@ const PrintA5Style11 = ({
style={{ style={{
background: '#373B44', background: '#373B44',
color: '#fff', color: '#fff',
...tableHeaderStyle,
}} }}
> >
{GlobaldummyData {GlobaldummyData
@ -688,7 +763,18 @@ const PrintA5Style11 = ({
<tbody> <tbody>
{dataChunk?.map((item, index) => ( {dataChunk?.map((item, index) => (
<tr key={index}> <tr key={index}
style={
index % 2 !== 1 && rowtypeStyle === "even"
? {
...tableBodyStyle
}
: index % 2 === 1 && rowtypeStyle === "odd"
? {
...tableBodyStyle
}
: {}
}>
{GlobaldummyData {GlobaldummyData
? GlobalSlNo && ( ? GlobalSlNo && (
<td style={{ textAlign: 'center' }}> <td style={{ textAlign: 'center' }}>
@ -931,7 +1017,8 @@ const PrintA5Style11 = ({
fontSize: '25px', fontSize: '25px',
fontWeight: '600', fontWeight: '600',
padding: '10px', padding: '10px',
backgroundColor: '#fdc716', // backgroundColor: '#fdc716',
...netAmountStyle,
textAlign: 'center', textAlign: 'center',
}} }}
> >
@ -1249,187 +1336,189 @@ const PrintA5Style11 = ({
>{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div> >{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div>
)} )}
{GlobaldummyData <div style={{ ...footerColorStyle }}>
? GlobalIsnotes && (
<div>
<p style={{ padding: '0rem 1rem' }}>
Notes : 10 days Return policy
</p>
<hr className="PrintA4Style11-print-dottline" />
</div>
)
: Notestext && (
<div>
<p
style={{
padding: '0rem 1rem',
textAlign: 'center',
}}
>
{Notestext}
</p>
<hr className="PrintA4Style11-print-dottline" />
</div>
)}
<div
style={{
display: 'flex',
width: '90%',
padding: '0 1rem',
justifyContent: GlobaltermsAndConditions
? 'space-between'
: 'flex-end',
alignItems: 'center',
}}
>
{GlobaldummyData {GlobaldummyData
? GlobaltermsAndConditions && ( ? GlobalIsnotes && (
<div <div>
style={{ <p style={{ padding: '0rem 1rem' }}>
margin: '8px 0', Notes : 10 days Return policy
padding: '8px',
fontFamily: 'sans-serif',
width: '100%',
}}
>
<p
style={{
fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}}
>
Terms & Conditions
</p> </p>
<ol
style={{ <hr className="PrintA4Style11-print-dottline" />
fontSize: '12px',
paddingLeft: '18px',
margin: 0,
lineHeight: '1',
}}
>
<li>
Once goods are sold, they are
not exchangeable or refundable.
</li>
<li>
Please check the product before
leaving the counter.
</li>
</ol>
</div> </div>
) )
: TermsnAdCondition == true && : Notestext && (
TermsAndConditions?.length > 0 && ( <div>
<div
style={{
margin: '8px 0',
fontFamily: 'sans-serif',
width: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-start',
}}
>
<p <p
style={{ style={{
fontSize: '13px', padding: '0rem 1rem',
fontWeight: 'bold', textAlign: 'center',
marginBottom: '6px',
}} }}
> >
Terms & Conditions {Notestext}
</p> </p>
<ol
style={{ <hr className="PrintA4Style11-print-dottline" />
fontSize: '12px',
paddingLeft: '18px',
margin: 0,
lineHeight: '1',
}}
>
{TermsAndConditions?.map(
(item) => (
<li
style={{
textAlign: 'start',
}}
>
{item?.TermsandConditions}
</li>
)
)}
{/* <li>Please check the product before leaving the counter.</li> */}
</ol>
</div> </div>
)} )}
{GlobaldummyData <div
? GlobalSignature && ( style={{
<div display: 'flex',
style={{ width: '90%',
display: 'flex', padding: '0 1rem',
flexDirection: 'column', justifyContent: GlobaltermsAndConditions
alignItems: 'flex-end', ? 'space-between'
paddingBottom: '1rem', : 'flex-end',
}} alignItems: 'center',
> }}
<p >
{GlobaldummyData
? GlobaltermsAndConditions && (
<div
style={{ style={{
fontSize: '13px', margin: '8px 0',
fontWeight: 'bold', padding: '8px',
marginBottom: '6px', fontFamily: 'sans-serif',
width: '100%',
}} }}
> >
Signature <p
</p> style={{
<img fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}}
>
Terms & Conditions
</p>
<ol
style={{
fontSize: '12px',
paddingLeft: '18px',
margin: 0,
lineHeight: '1',
}}
>
<li>
Once goods are sold, they are
not exchangeable or refundable.
</li>
<li>
Please check the product before
leaving the counter.
</li>
</ol>
</div>
)
: TermsnAdCondition == true &&
TermsAndConditions?.length > 0 && (
<div
style={{ style={{
width: '70px', margin: '8px 0',
height: '40px', fontFamily: 'sans-serif',
}} width: '100%',
src={ display: 'flex',
GlobalSignatureImages flexDirection: 'column',
? GlobalSignatureImages alignItems: 'flex-start',
: signature
}
alt=""
/>
</div>
)
: Signature == true && (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
marginTop: '1rem',
paddingBottom: '1rem',
}}
>
<p
style={{
fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}} }}
> >
Signature <p
</p> style={{
<img fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}}
>
Terms & Conditions
</p>
<ol
style={{
fontSize: '12px',
paddingLeft: '18px',
margin: 0,
lineHeight: '1',
}}
>
{TermsAndConditions?.map(
(item) => (
<li
style={{
textAlign: 'start',
}}
>
{item?.TermsandConditions}
</li>
)
)}
{/* <li>Please check the product before leaving the counter.</li> */}
</ol>
</div>
)}
{GlobaldummyData
? GlobalSignature && (
<div
style={{ style={{
width: '100px', display: 'flex',
height: '60px', flexDirection: 'column',
alignItems: 'flex-end',
paddingBottom: '1rem',
}} }}
src={SignatureImg} >
alt="" <p
/> style={{
</div> fontSize: '13px',
)} fontWeight: 'bold',
marginBottom: '6px',
}}
>
Signature
</p>
<img
style={{
width: '70px',
height: '40px',
}}
src={
GlobalSignatureImages
? GlobalSignatureImages
: signature
}
alt=""
/>
</div>
)
: Signature == true && (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
marginTop: '1rem',
paddingBottom: '1rem',
}}
>
<p
style={{
fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}}
>
Signature
</p>
<img
style={{
width: '100px',
height: '60px',
}}
src={SignatureImg}
alt=""
/>
</div>
)}
</div>
</div> </div>
</div> </div>
)} )}
@ -1494,6 +1583,7 @@ const PrintA5Style11 = ({
style={{ style={{
background: '#373B44', background: '#373B44',
color: '#fff', color: '#fff',
...tableHeaderStyle
}} }}
> >
{GlobaldummyData {GlobaldummyData
@ -1674,7 +1764,18 @@ const PrintA5Style11 = ({
<tbody> <tbody>
{dataChunk?.map((item, index) => ( {dataChunk?.map((item, index) => (
<tr key={index}> <tr key={index}
style={
index % 2 !== 1 && rowtypeStyle === "even"
? {
...tableBodyStyle
}
: index % 2 === 1 && rowtypeStyle === "odd"
? {
...tableBodyStyle
}
: {}
}>
{GlobaldummyData {GlobaldummyData
? GlobalSlNo && ( ? GlobalSlNo && (
<td style={{ textAlign: 'center' }}> <td style={{ textAlign: 'center' }}>
@ -1893,7 +1994,8 @@ const PrintA5Style11 = ({
fontSize: '25px', fontSize: '25px',
fontWeight: '600', fontWeight: '600',
padding: '10px', padding: '10px',
backgroundColor: '#fdc716', // backgroundColor: '#fdc716',
...netAmountStyle,
textAlign: 'center', textAlign: 'center',
}} }}
> >
@ -2209,187 +2311,189 @@ const PrintA5Style11 = ({
>{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div> >{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div>
)} )}
{GlobaldummyData <div style={{ ...footerColorStyle }}>
? GlobalIsnotes && (
<div>
<p style={{ padding: '0rem 1rem' }}>
Notes : 10 days Return policy
</p>
<hr className="PrintA4Style11-print-dottline" />
</div>
)
: Notestext && (
<div>
<p
style={{
padding: '0rem 1rem',
textAlign: 'center',
}}
>
{Notestext}
</p>
<hr className="PrintA4Style11-print-dottline" />
</div>
)}
<div
style={{
display: 'flex',
width: '90%',
padding: '0 1rem',
justifyContent: GlobaltermsAndConditions
? 'space-between'
: 'flex-end',
alignItems: 'center',
}}
>
{GlobaldummyData {GlobaldummyData
? GlobaltermsAndConditions && ( ? GlobalIsnotes && (
<div <div>
style={{ <p style={{ padding: '0rem 1rem' }}>
margin: '8px 0', Notes : 10 days Return policy
padding: '8px',
fontFamily: 'sans-serif',
width: '100%',
}}
>
<p
style={{
fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}}
>
Terms & Conditions
</p> </p>
<ol
style={{ <hr className="PrintA4Style11-print-dottline" />
fontSize: '12px',
paddingLeft: '18px',
margin: 0,
lineHeight: '1',
}}
>
<li>
Once goods are sold, they are
not exchangeable or refundable.
</li>
<li>
Please check the product before
leaving the counter.
</li>
</ol>
</div> </div>
) )
: TermsnAdCondition == true && : Notestext && (
TermsAndConditions?.length > 0 && ( <div>
<div
style={{
margin: '8px 0',
fontFamily: 'sans-serif',
width: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-start',
}}
>
<p <p
style={{ style={{
fontSize: '13px', padding: '0rem 1rem',
fontWeight: 'bold', textAlign: 'center',
marginBottom: '6px',
}} }}
> >
Terms & Conditions {Notestext}
</p> </p>
<ol
style={{ <hr className="PrintA4Style11-print-dottline" />
fontSize: '12px',
paddingLeft: '18px',
margin: 0,
lineHeight: '1',
}}
>
{TermsAndConditions?.map(
(item) => (
<li
style={{
textAlign: 'start',
}}
>
{item?.TermsandConditions}
</li>
)
)}
{/* <li>Please check the product before leaving the counter.</li> */}
</ol>
</div> </div>
)} )}
{GlobaldummyData <div
? GlobalSignature && ( style={{
<div display: 'flex',
style={{ width: '90%',
display: 'flex', padding: '0 1rem',
flexDirection: 'column', justifyContent: GlobaltermsAndConditions
alignItems: 'flex-end', ? 'space-between'
paddingBottom: '1rem', : 'flex-end',
}} alignItems: 'center',
> }}
<p >
{GlobaldummyData
? GlobaltermsAndConditions && (
<div
style={{ style={{
fontSize: '13px', margin: '8px 0',
fontWeight: 'bold', padding: '8px',
marginBottom: '6px', fontFamily: 'sans-serif',
width: '100%',
}} }}
> >
Signature <p
</p> style={{
<img fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}}
>
Terms & Conditions
</p>
<ol
style={{
fontSize: '12px',
paddingLeft: '18px',
margin: 0,
lineHeight: '1',
}}
>
<li>
Once goods are sold, they are
not exchangeable or refundable.
</li>
<li>
Please check the product before
leaving the counter.
</li>
</ol>
</div>
)
: TermsnAdCondition == true &&
TermsAndConditions?.length > 0 && (
<div
style={{ style={{
width: '70px', margin: '8px 0',
height: '40px', fontFamily: 'sans-serif',
}} width: '100%',
src={ display: 'flex',
GlobalSignatureImages flexDirection: 'column',
? GlobalSignatureImages alignItems: 'flex-start',
: signature
}
alt=""
/>
</div>
)
: Signature == true && (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
marginTop: '1rem',
paddingBottom: '1rem',
}}
>
<p
style={{
fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}} }}
> >
Signature <p
</p> style={{
<img fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}}
>
Terms & Conditions
</p>
<ol
style={{
fontSize: '12px',
paddingLeft: '18px',
margin: 0,
lineHeight: '1',
}}
>
{TermsAndConditions?.map(
(item) => (
<li
style={{
textAlign: 'start',
}}
>
{item?.TermsandConditions}
</li>
)
)}
{/* <li>Please check the product before leaving the counter.</li> */}
</ol>
</div>
)}
{GlobaldummyData
? GlobalSignature && (
<div
style={{ style={{
width: '100px', display: 'flex',
height: '60px', flexDirection: 'column',
alignItems: 'flex-end',
paddingBottom: '1rem',
}} }}
src={SignatureImg} >
alt="" <p
/> style={{
</div> fontSize: '13px',
)} fontWeight: 'bold',
marginBottom: '6px',
}}
>
Signature
</p>
<img
style={{
width: '70px',
height: '40px',
}}
src={
GlobalSignatureImages
? GlobalSignatureImages
: signature
}
alt=""
/>
</div>
)
: Signature == true && (
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
marginTop: '1rem',
paddingBottom: '1rem',
}}
>
<p
style={{
fontSize: '13px',
fontWeight: 'bold',
marginBottom: '6px',
}}
>
Signature
</p>
<img
style={{
width: '100px',
height: '60px',
}}
src={SignatureImg}
alt=""
/>
</div>
)}
</div>
</div> </div>
</div> </div>
)} )}
@ -2488,7 +2592,8 @@ const PrintA5Style11 = ({
fontSize: '25px', fontSize: '25px',
fontWeight: '600', fontWeight: '600',
padding: '10px', padding: '10px',
backgroundColor: '#fdc716', // backgroundColor: '#fdc716',
...netAmountStyle,
textAlign: 'center', textAlign: 'center',
}} }}
> >
@ -2824,7 +2929,8 @@ const PrintA5Style11 = ({
>{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div> >{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div>
)} )}
{GlobaldummyData <div style={{...footerColorStyle}}>
{GlobaldummyData
? GlobalIsnotes && ( ? GlobalIsnotes && (
<div> <div>
<p style={{ padding: '0rem 1rem' }}> <p style={{ padding: '0rem 1rem' }}>
@ -2995,6 +3101,7 @@ const PrintA5Style11 = ({
)} )}
</div> </div>
</div> </div>
</div>
)} )}
</div> </div>
))} ))}
@ -3077,7 +3184,8 @@ const PrintA5Style11 = ({
fontSize: '25px', fontSize: '25px',
fontWeight: '600', fontWeight: '600',
padding: '10px', padding: '10px',
backgroundColor: '#fdc716', // backgroundColor: '#fdc716',
...netAmountStyle,
textAlign: 'center', textAlign: 'center',
}} }}
> >
@ -3407,7 +3515,8 @@ const PrintA5Style11 = ({
>{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div> >{`*** Membership ${table2Data?.NetAmount === 0 ? 'Free Hours' : 'Discount'} Utilized - ${MembershipApplied?.Detail?.[0]?.MembershipName} ***`}</div>
)} )}
{GlobaldummyData <div style={{...footerColorStyle}}>
{GlobaldummyData
? GlobalIsnotes && ( ? GlobalIsnotes && (
<div> <div>
<p style={{ padding: '0rem 1rem' }}> <p style={{ padding: '0rem 1rem' }}>
@ -3572,6 +3681,7 @@ const PrintA5Style11 = ({
)} )}
</div> </div>
</div> </div>
</div>
</div> </div>
)} )}
</div> </div>