Implement dynamic header and table color functionality
This commit is contained in:
parent
122260c95b
commit
d5d23e837f
|
|
@ -27,7 +27,17 @@ import {
|
||||||
GlobalprintCashierName,
|
GlobalprintCashierName,
|
||||||
GlobalprintLogo,
|
GlobalprintLogo,
|
||||||
GlobalprintTax,
|
GlobalprintTax,
|
||||||
GlobalSelectedPrintHeaderColor,
|
GlobalSelectedPrintHeaderColor,
|
||||||
|
GlobalSelectedPrintHeaderFontColor,
|
||||||
|
GlobalSelectedTableHeaderColor,
|
||||||
|
GlobalSelectedTableHeaderFontColor,
|
||||||
|
GlobalSelectedTableBodyFontColor,
|
||||||
|
GlobalSelectedTableBodyColor,
|
||||||
|
GlobalRowType,
|
||||||
|
GlobalSelectedFooterColor,
|
||||||
|
GlobalSelectedFooterFontColor,
|
||||||
|
GlobalSelectedNetAmountColor,
|
||||||
|
GlobalSelectedNetAmountFontColor,
|
||||||
} from '../../../../Features/ThemeChange/ThemeChange';
|
} from '../../../../Features/ThemeChange/ThemeChange';
|
||||||
import '../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.scss';
|
import '../../../../Styles/BookingScreen/PrintTemplates/ThermalPrinter/PrintStyle1.scss';
|
||||||
import QRCode from 'react-qr-code';
|
import QRCode from 'react-qr-code';
|
||||||
|
|
@ -110,8 +120,23 @@ const InvoiceTemplate = ({
|
||||||
)?.SettingValue === 'Y';
|
)?.SettingValue === 'Y';
|
||||||
const keysLength = Object.keys(table2Data ?? {}).length;
|
const keysLength = Object.keys(table2Data ?? {}).length;
|
||||||
console.log(GlobalDiscount, Discount, 'Discount');
|
console.log(GlobalDiscount, Discount, 'Discount');
|
||||||
|
const SelectedHeaderColor = useSelector(GlobalSelectedPrintHeaderColor);
|
||||||
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;
|
||||||
|
|
||||||
let BankDetails = table2Data?.BankDetails;
|
let BankDetails = table2Data?.BankDetails;
|
||||||
let TermsAndConditions = printDatas?.TermsandConditions;
|
let TermsAndConditions = printDatas?.TermsandConditions;
|
||||||
|
|
@ -491,6 +516,51 @@ const InvoiceTemplate = ({
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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 (
|
||||||
<>
|
<>
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -882,7 +952,7 @@ const InvoiceTemplate = ({
|
||||||
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
|
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
|
||||||
''
|
''
|
||||||
) : (
|
) : (
|
||||||
<div className="header-section">
|
<div className="header-section" style={{...headerStyle}}>
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
style={{ display: 'flex', alignItems: 'center' }}
|
style={{ display: 'flex', alignItems: 'center' }}
|
||||||
|
|
@ -1090,7 +1160,7 @@ const InvoiceTemplate = ({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="table-header">
|
<tr className="table-header" style={{...tableHeaderStyle}}>
|
||||||
{GlobaldummyData
|
{GlobaldummyData
|
||||||
? GlobalSlNo && (
|
? GlobalSlNo && (
|
||||||
<th className="table-header-cell">S.No</th>
|
<th className="table-header-cell">S.No</th>
|
||||||
|
|
@ -1238,7 +1308,18 @@ const InvoiceTemplate = ({
|
||||||
<tbody>
|
<tbody>
|
||||||
{((GlobaldummyData ? products : dataChunk) || []).map(
|
{((GlobaldummyData ? products : dataChunk) || []).map(
|
||||||
(item, idx) => (
|
(item, idx) => (
|
||||||
<tr key={idx} className="table-row">
|
<tr key={idx} className="table-row"
|
||||||
|
style={
|
||||||
|
idx % 2 !== 1 && rowtypeStyle === "even"
|
||||||
|
? {
|
||||||
|
...tableBodyStyle
|
||||||
|
}
|
||||||
|
: idx % 2 === 1 && rowtypeStyle === "odd"
|
||||||
|
? {
|
||||||
|
...tableBodyStyle
|
||||||
|
}
|
||||||
|
: {}
|
||||||
|
}>
|
||||||
{GlobaldummyData
|
{GlobaldummyData
|
||||||
? GlobalSlNo && (
|
? GlobalSlNo && (
|
||||||
<td
|
<td
|
||||||
|
|
@ -1562,13 +1643,14 @@ const InvoiceTemplate = ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
justifyContent: 'flex-start',
|
justifyContent: 'flex-start',
|
||||||
width: '95%',
|
width: '100%',
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
fontSize: '10px',
|
fontSize: '10px',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
alignItems: 'flex-end',
|
alignItems: 'flex-end',
|
||||||
gap: '2px',
|
gap: '2px',
|
||||||
marginBottom: '0.5rem',
|
marginBottom: '0.5rem',
|
||||||
|
...netAmountStyle
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div style={{ display: 'flex' }}>
|
<div style={{ display: 'flex' }}>
|
||||||
|
|
@ -1906,7 +1988,7 @@ const InvoiceTemplate = ({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Footer */}
|
{/* Footer */}
|
||||||
<div className="footer-grid">
|
<div className="footer-grid" style={{...footerColorStyle}}>
|
||||||
<div className="footer-left">
|
<div className="footer-left">
|
||||||
{BankDetails?.length > 0 && (
|
{BankDetails?.length > 0 && (
|
||||||
<>
|
<>
|
||||||
|
|
@ -2168,11 +2250,14 @@ const InvoiceTemplate = ({
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'flex-end',
|
alignItems: 'flex-end',
|
||||||
justifyContent: 'space-around',
|
justifyContent: 'space-around',
|
||||||
width: '95%',
|
width: '100%',
|
||||||
|
padding: '0 10px',
|
||||||
|
padding: '0 10px',
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
fontSize: '10px',
|
fontSize: '10px',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
gap: '2px',
|
gap: '2px',
|
||||||
|
...netAmountStyle
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div style={{ display: 'flex' }}>
|
<div style={{ display: 'flex' }}>
|
||||||
|
|
@ -2466,7 +2551,7 @@ const InvoiceTemplate = ({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Footer */}
|
{/* Footer */}
|
||||||
<div className="footer-grid">
|
<div className="footer-grid" style={{...footerColorStyle}}>
|
||||||
<div className="footer-left">
|
<div className="footer-left">
|
||||||
{BankDetails?.length > 0 && (
|
{BankDetails?.length > 0 && (
|
||||||
<>
|
<>
|
||||||
|
|
@ -2688,7 +2773,7 @@ const InvoiceTemplate = ({
|
||||||
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
|
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
|
||||||
''
|
''
|
||||||
) : (
|
) : (
|
||||||
<div className="header-section">
|
<div className="header-section" style={{...headerStyle}}>
|
||||||
<div>
|
<div>
|
||||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
||||||
{GlobalLogo && GlobaldummyData && (
|
{GlobalLogo && GlobaldummyData && (
|
||||||
|
|
@ -2719,14 +2804,11 @@ const InvoiceTemplate = ({
|
||||||
) : null}
|
) : null}
|
||||||
<h1
|
<h1
|
||||||
className="company-name"
|
className="company-name"
|
||||||
style={{
|
|
||||||
color: SelectedHeaderColor,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{GlobaldummyData ? 'Company Name' : companyName}
|
{GlobaldummyData ? 'Company Name' : companyName}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<p>{companyAddress}</p>
|
<p>{GlobaldummyData ? 'Hosur Dharga tamil Nadu 653105' : companyAddress}</p>
|
||||||
{(companyPhone || GlobaldummyData) && (
|
{(companyPhone || GlobaldummyData) && (
|
||||||
<div>
|
<div>
|
||||||
Phone: {GlobaldummyData ? '999999XXXX' : companyPhone}
|
Phone: {GlobaldummyData ? '999999XXXX' : companyPhone}
|
||||||
|
|
@ -2854,7 +2936,7 @@ const InvoiceTemplate = ({
|
||||||
style={{ borderTop: '1px solid black' }}
|
style={{ borderTop: '1px solid black' }}
|
||||||
>
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="table-header">
|
<tr className="table-header" style={{...tableHeaderStyle}}>
|
||||||
{GlobaldummyData
|
{GlobaldummyData
|
||||||
? GlobalSlNo && (
|
? GlobalSlNo && (
|
||||||
<th className="table-header-cell">S.No</th>
|
<th className="table-header-cell">S.No</th>
|
||||||
|
|
@ -2964,7 +3046,18 @@ const InvoiceTemplate = ({
|
||||||
<tbody>
|
<tbody>
|
||||||
{((GlobaldummyData ? products : productsData) || []).map(
|
{((GlobaldummyData ? products : productsData) || []).map(
|
||||||
(item, idx) => (
|
(item, idx) => (
|
||||||
<tr key={idx} className="table-row">
|
<tr key={idx} className="table-row"
|
||||||
|
style={
|
||||||
|
idx % 2 !== 1 && rowtypeStyle === "even"
|
||||||
|
? {
|
||||||
|
...tableBodyStyle
|
||||||
|
}
|
||||||
|
: idx % 2 === 1 && rowtypeStyle === "odd"
|
||||||
|
? {
|
||||||
|
...tableBodyStyle
|
||||||
|
}
|
||||||
|
: {}
|
||||||
|
}>
|
||||||
{GlobaldummyData
|
{GlobaldummyData
|
||||||
? GlobalSlNo && (
|
? GlobalSlNo && (
|
||||||
<td
|
<td
|
||||||
|
|
@ -3185,11 +3278,13 @@ const InvoiceTemplate = ({
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'flex-start',
|
alignItems: 'flex-start',
|
||||||
justifyContent: 'space-around',
|
justifyContent: 'space-around',
|
||||||
width: '95%',
|
width: '100%',
|
||||||
|
padding: '0 10px',
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
fontSize: '10px',
|
fontSize: '10px',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
gap: '2px',
|
gap: '2px',
|
||||||
|
...netAmountStyle
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
@ -3444,7 +3539,7 @@ const InvoiceTemplate = ({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Footer */}
|
{/* Footer */}
|
||||||
<div className="footer-grid">
|
<div className="footer-grid" style={{...footerColorStyle}}>
|
||||||
<div className="footer-left">
|
<div className="footer-left">
|
||||||
{(BankDetails?.length > 0 || GlobaldummyData) && (
|
{(BankDetails?.length > 0 || GlobaldummyData) && (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue