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