Implement dynamic header and table color functionality

This commit is contained in:
Srinath 2026-03-04 16:31:29 +05:30
parent d9b2fbcbf9
commit 4a27698a59
1 changed files with 210 additions and 88 deletions

View File

@ -26,6 +26,16 @@ import {
GlobalprintCredit,
GlobalprintTax,
GlobalSelectedPrintHeaderColor,
GlobalSelectedPrintHeaderFontColor,
GlobalSelectedTableHeaderColor,
GlobalSelectedTableHeaderFontColor,
GlobalSelectedTableBodyFontColor,
GlobalSelectedTableBodyColor,
GlobalRowType,
GlobalSelectedFooterColor,
GlobalSelectedFooterFontColor,
GlobalSelectedNetAmountColor,
GlobalSelectedNetAmountFontColor,
} from '../../../../Features/ThemeChange/ThemeChange';
import Logo from '../../../../Images/Logo.jpg';
import {
@ -100,6 +110,22 @@ const PrintStyle7 = ({
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 UomPrint = SettingData?.[0]?.SettingDtlDetails?.filter(
(i) => i.SettingIdName === 'PrintUom'
)?.[0];
@ -349,7 +375,51 @@ const PrintStyle7 = ({
? paginatedChunks[paginatedChunks.length - 1].length
: 0;
const shouldFooterBeOnNewPage = lastChunkRows > (PageSize == 'A5' ? 5 : 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 ? (
@ -408,7 +478,7 @@ const PrintStyle7 = ({
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
''
) : (
<div className="PrintStyle7-print">
<div className="PrintStyle7-print" style={{...headerStyle}}>
{/* <div style={{ fontSize: '16px', fontWeight: '600' }}> {GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}</div> */}
<div
style={{
@ -437,7 +507,6 @@ const PrintStyle7 = ({
style={{
fontSize: '16px',
fontWeight: '600',
color: SelectedHeaderColor,
}}
>
{' '}
@ -575,63 +644,64 @@ const PrintStyle7 = ({
<tr>
{GlobaldummyData
? GlobalSlNo && (
<th style={{ width: '10px' }}>S</th>
<th style={{...tableHeaderStyle, width: '10px' }}>S</th>
)
: SLNO == true && (
<th style={{ width: '10px' }}>S</th>
<th style={{...tableHeaderStyle, width: '10px' }}>S</th>
)}
{GlobaldummyData
? GlobalItem && <th>Item</th>
: Item == true && <th>Item</th>}
? GlobalItem && <th style={{...tableHeaderStyle,}}>Item</th>
: Item == true && <th style={{...tableHeaderStyle,}}>Item</th>}
{GlobaldummyData
? GlobalHsnCode && (
<th style={{ width: '10px' }}>HSN</th>
<th style={{...tableHeaderStyle, width: '10px' }}>HSN</th>
)
: HsnCode == true && (
<th style={{ width: '10px' }}>HSN</th>
<th style={{...tableHeaderStyle, width: '10px' }}>HSN</th>
)}
{GlobaldummyData
? GlobalQuantity && (
<th style={{ width: '10px' }}>Qty</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Qty</th>
)
: Quantity == true && (
<th style={{ width: '10px' }}>
<th style={{...tableHeaderStyle, width: '10px' }}>
{WeightasKg ? 'Qty/Kg' : 'Qty'}
</th>
)}
{GlobaldummyData
? GlobalMRP && (
<th style={{ width: '10px' }}>MRP</th>
<th style={{...tableHeaderStyle, width: '10px' }}>MRP</th>
)
: MRP == true && (
<th style={{ width: '10px' }}>MRP</th>
<th style={{...tableHeaderStyle, width: '10px' }}>MRP</th>
)}
{GlobaldummyData
? GlobalRate && (
<th style={{ width: '10px' }}>Rate</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Rate</th>
)
: Rate == true && (
<th style={{ width: '10px' }}>Rate</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Rate</th>
)}
{GlobaldummyData
? GlobalDiscount && (
<th style={{ width: '10px' }}>Dis </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Dis </th>
)
: Discount == true && (
<th style={{ width: '10px' }}>Dis </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Dis </th>
)}
{GlobaldummyData
? GlobalTax && (
<th style={{ width: '10px' }}>Tax % </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Tax % </th>
)
: Tax &&
table2Data?.OrderType !== 'E' && (
<th style={{ width: '10px' }}>Tax % </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Tax % </th>
)}
{GlobaldummyData
? GlobalAmount && (
<th
style={{
...tableHeaderStyle,
width: '10px',
textAlign: 'right',
}}
@ -642,6 +712,7 @@ const PrintStyle7 = ({
: Amount == true && (
<th
style={{
...tableHeaderStyle,
width: '10px',
textAlign: 'right',
}}
@ -653,7 +724,18 @@ const PrintStyle7 = ({
</thead>
<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' }}>
@ -836,63 +918,64 @@ const PrintStyle7 = ({
<tr>
{GlobaldummyData
? GlobalSlNo && (
<th style={{ width: '10px' }}>S.No</th>
<th style={{...tableHeaderStyle, width: '10px' }}>S.No</th>
)
: SLNO == true && (
<th style={{ width: '10px' }}>S.NO</th>
<th style={{...tableHeaderStyle, width: '10px' }}>S.NO</th>
)}
{GlobaldummyData
? GlobalItem && <th>Item</th>
: Item == true && <th>Item</th>}
? GlobalItem && <th style={{...tableHeaderStyle,}}>Item</th>
: Item == true && <th style={{...tableHeaderStyle,}}>Item</th>}
{GlobaldummyData
? GlobalHsnCode && (
<th style={{ width: '10px' }}>HSN</th>
<th style={{...tableHeaderStyle, width: '10px' }}>HSN</th>
)
: HsnCode == true && (
<th style={{ width: '10px' }}>HSN</th>
<th style={{...tableHeaderStyle, width: '10px' }}>HSN</th>
)}
{GlobaldummyData
? GlobalQuantity && (
<th style={{ width: '10px' }}>Qty</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Qty</th>
)
: Quantity == true && (
<th style={{ width: '10px' }}>
<th style={{ ...tableHeaderStyle,width: '10px' }}>
{WeightasKg ? 'Qty/Kg' : 'Qty'}
</th>
)}
{GlobaldummyData
? GlobalMRP && (
<th style={{ width: '10px' }}>MRP</th>
<th style={{...tableHeaderStyle, width: '10px' }}>MRP</th>
)
: MRP == true && (
<th style={{ width: '10px' }}>MRP</th>
<th style={{...tableHeaderStyle, width: '10px' }}>MRP</th>
)}
{GlobaldummyData
? GlobalRate && (
<th style={{ width: '10px' }}>Rate</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Rate</th>
)
: Rate == true && (
<th style={{ width: '10px' }}>Rate</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Rate</th>
)}
{GlobaldummyData
? GlobalDiscount && (
<th style={{ width: '10px' }}>Dis </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Dis </th>
)
: Discount == true && (
<th style={{ width: '10px' }}>Dis </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Dis </th>
)}
{GlobaldummyData
? GlobalTax && (
<th style={{ width: '10px' }}>Tax % </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Tax % </th>
)
: Tax &&
table2Data?.OrderType !== 'E' && (
<th style={{ width: '10px' }}>Tax % </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Tax % </th>
)}
{GlobaldummyData
? GlobalAmount && (
<th
style={{
...tableHeaderStyle,
width: '10px',
textAlign: 'right',
}}
@ -903,6 +986,7 @@ const PrintStyle7 = ({
: Amount == true && (
<th
style={{
...tableHeaderStyle,
width: '10px',
textAlign: 'right',
}}
@ -914,7 +998,18 @@ const PrintStyle7 = ({
</thead>
<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' }}>
@ -1436,6 +1531,7 @@ const PrintStyle7 = ({
justifyContent: 'center',
fontSize: '16px',
fontWeight: '600',
...netAmountStyle
}}
>
Amount :
@ -1771,6 +1867,7 @@ const PrintStyle7 = ({
pageBreakBefore: 'avoid',
pageBreakInside: 'avoid',
minHeight: 'auto',
...footerColorStyle
}}
>
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
@ -2343,6 +2440,7 @@ const PrintStyle7 = ({
justifyContent: 'center',
fontSize: '16px',
fontWeight: '600',
...netAmountStyle
}}
>
Amount :
@ -2676,6 +2774,7 @@ const PrintStyle7 = ({
pageBreakBefore: 'avoid',
pageBreakInside: 'avoid',
minHeight: 'auto',
...footerColorStyle
}}
>
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
@ -2885,7 +2984,7 @@ const PrintStyle7 = ({
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
''
) : (
<div className="PrintStyle7-print">
<div className="PrintStyle7-print" style={{...headerStyle}}>
<div
style={{
display: 'flex',
@ -2913,7 +3012,6 @@ const PrintStyle7 = ({
style={{
fontSize: '16px',
fontWeight: '600',
color: SelectedHeaderColor,
}}
>
{' '}
@ -3052,58 +3150,58 @@ const PrintStyle7 = ({
<thead>
<tr>
{GlobaldummyData
? GlobalSlNo && <th style={{ width: '10%' }}>S.No</th>
? GlobalSlNo && <th style={{...tableHeaderStyle, width: '10%' }}>S.No</th>
: SLNO == true && (
<th style={{ width: '10px' }}>S.No</th>
<th style={{...tableHeaderStyle, width: '10px' }}>S.No</th>
)}
{GlobaldummyData
? GlobalItem && (
<th style={{ width: '30%', textAlign: 'left' }}>
<th style={{...tableHeaderStyle, width: '30%', textAlign: 'left' }}>
Item
</th>
)
: Item == true && <th>Item</th>}
: Item == true && <th style={{...tableHeaderStyle}}>Item</th>}
{GlobaldummyData
? GlobalHsnCode && <th style={{}}>HSN</th>
? GlobalHsnCode && <th style={{...tableHeaderStyle}}>HSN</th>
: HsnCode == true && (
<th style={{ width: '10px' }}>HSN</th>
<th style={{...tableHeaderStyle, width: '10px' }}>HSN</th>
)}
{GlobaldummyData
? GlobalQuantity && <th style={{}}>Qty</th>
? GlobalQuantity && <th style={{...tableHeaderStyle}}>Qty</th>
: Quantity == true && (
<th style={{ width: '10px' }}>
<th style={{...tableHeaderStyle, width: '10px' }}>
{WeightasKg ? 'Qty/Kg' : 'Qty'}
</th>
)}
{GlobaldummyData
? GlobalMRP && <th style={{}}>MRP</th>
? GlobalMRP && <th style={{...tableHeaderStyle}}>MRP</th>
: MRP == true && (
<th style={{ width: '10px' }}>MRP</th>
<th style={{...tableHeaderStyle, width: '10px' }}>MRP</th>
)}
{GlobaldummyData
? GlobalRate && <th style={{}}>Rate</th>
? GlobalRate && <th style={{...tableHeaderStyle}}>Rate</th>
: Rate == true && (
<th style={{ width: '10px' }}>Rate</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Rate</th>
)}
{GlobaldummyData
? GlobalDiscount && <th style={{}}>Dis </th>
? GlobalDiscount && <th style={{...tableHeaderStyle,}}>Dis </th>
: Discount == true && (
<th style={{ width: '10px' }}>Dis </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Dis </th>
)}
{GlobaldummyData
? GlobalTax && (
<th style={{ width: '10px' }}>Tax % </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Tax % </th>
)
: Tax &&
table2Data?.OrderType !== 'E' && (
<th style={{ width: '10px' }}>Tax % </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Tax % </th>
)}
{GlobaldummyData
? GlobalAmount && (
<th style={{ textAlign: 'right' }}>Amt</th>
<th style={{...tableHeaderStyle, textAlign: 'right' }}>Amt</th>
)
: Amount == true && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Amt
</th>
)}
@ -3112,7 +3210,18 @@ const PrintStyle7 = ({
<tbody>
{(GlobaldummyData ? products : TakeawayData)?.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' }}>
@ -3293,64 +3402,64 @@ const PrintStyle7 = ({
<thead>
<tr>
{GlobaldummyData
? GlobalSlNo && <th style={{ width: '10px' }}>S</th>
? GlobalSlNo && <th style={{...tableHeaderStyle, width: '10px' }}>S</th>
: SLNO == true && (
<th style={{ width: '10px' }}>S</th>
<th style={{...tableHeaderStyle, width: '10px' }}>S</th>
)}
{GlobaldummyData
? GlobalItem && <th>Item</th>
: Item == true && <th>Item</th>}
? GlobalItem && <th style={{...tableHeaderStyle}}>Item</th>
: Item == true && <th style={{...tableHeaderStyle}}>Item</th>}
{GlobaldummyData
? GlobalHsnCode && (
<th style={{ width: '10px' }}>HSN</th>
<th style={{...tableHeaderStyle, width: '10px' }}>HSN</th>
)
: HsnCode == true && (
<th style={{ width: '10px' }}>HSN</th>
<th style={{...tableHeaderStyle, width: '10px' }}>HSN</th>
)}
{GlobaldummyData
? GlobalQuantity && (
<th style={{ width: '10px' }}>Qty</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Qty</th>
)
: Quantity == true && (
<th style={{ width: '10px' }}>
<th style={{...tableHeaderStyle, width: '10px' }}>
{WeightasKg ? 'Qty/Kg' : 'Qty'}
</th>
)}
{GlobaldummyData
? GlobalMRP && <th style={{ width: '10px' }}>MRP</th>
? GlobalMRP && <th style={{...tableHeaderStyle, width: '10px' }}>MRP</th>
: MRP == true && (
<th style={{ width: '10px' }}>MRP</th>
<th style={{...tableHeaderStyle, width: '10px' }}>MRP</th>
)}
{GlobaldummyData
? GlobalRate && (
<th style={{ width: '10px' }}>Rate</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Rate</th>
)
: Rate == true && (
<th style={{ width: '10px' }}>Rate</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Rate</th>
)}
{GlobaldummyData
? GlobalDiscount && (
<th style={{ width: '10px' }}>Dis </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Dis </th>
)
: Discount == true && (
<th style={{ width: '10px' }}>Dis </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Dis </th>
)}
{GlobaldummyData
? GlobalTax && (
<th style={{ width: '10px' }}>Tax % </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Tax % </th>
)
: Tax &&
table2Data?.OrderType !== 'E' && (
<th style={{ width: '10px' }}>Tax % </th>
<th style={{...tableHeaderStyle, width: '10px' }}>Tax % </th>
)}
{GlobaldummyData
? GlobalAmount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Amt
</th>
)
: Amount == true && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Amt
</th>
)}
@ -3359,7 +3468,18 @@ const PrintStyle7 = ({
<tbody>
{(GlobaldummyData ? products : DineInData)?.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' }}>
@ -3848,6 +3968,7 @@ const PrintStyle7 = ({
justifyContent: 'center',
fontSize: '16px',
fontWeight: '600',
...netAmountStyle
}}
>
Amount :
@ -4162,6 +4283,7 @@ const PrintStyle7 = ({
pageBreakBefore: 'avoid',
pageBreakInside: 'avoid',
minHeight: 'auto',
...footerColorStyle
}}
>
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (