Implement dynamic header and table color functionality

This commit is contained in:
Srinath 2026-03-04 16:32:45 +05:30
parent 47745687ee
commit 7245aa95b4
1 changed files with 200 additions and 80 deletions

View File

@ -30,6 +30,16 @@ import {
GlobalprintCredit,
GlobalprintTax,
GlobalSelectedPrintHeaderColor,
GlobalSelectedPrintHeaderFontColor,
GlobalSelectedTableHeaderColor,
GlobalSelectedTableHeaderFontColor,
GlobalSelectedTableBodyFontColor,
GlobalSelectedTableBodyColor,
GlobalRowType,
GlobalSelectedFooterColor,
GlobalSelectedFooterFontColor,
GlobalSelectedNetAmountColor,
GlobalSelectedNetAmountFontColor,
} from '../../../../Features/ThemeChange/ThemeChange';
import {
GlobalUpiIDprint,
@ -105,6 +115,22 @@ const PrintStyle11 = ({
const GlobalLogo = useSelector(GlobalprintLogo);
const GlobalCredit = useSelector(GlobalprintCredit);
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];
@ -333,7 +359,51 @@ const PrintStyle11 = ({
? 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 ? (
@ -391,8 +461,8 @@ const PrintStyle11 = ({
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
''
) : (
<div>
<div className="PrintStyle11-print">
<div style={{ ...headerStyle }}>
<div className="PrintStyle11-print" style={{ ...headerStyle }}>
{GlobalLogo && GlobaldummyData ? (
<img
className="PrintStyle2-BrandImage"
@ -531,25 +601,25 @@ const PrintStyle11 = ({
<tr>
{GlobaldummyData
? GlobalSlNo && (
<th style={{ width: '10px' }}>S.N</th>
<th style={{ ...tableHeaderStyle, width: '10px' }}>S.N</th>
)
: SLNO && <th style={{ width: '10px' }}>S.N</th>}
: SLNO && <th style={{ ...tableHeaderStyle, width: '10px' }}>S.N</th>}
{GlobaldummyData
? GlobalItem && (
<th style={{ width: '10px' }}>Item</th>
<th style={{ ...tableHeaderStyle, width: '10px' }}>Item</th>
)
: Item && <th style={{ width: '10px' }}>Item</th>}
: Item && <th style={{ ...tableHeaderStyle, width: '10px' }}>Item</th>}
{GlobaldummyData
? GlobalQuantity && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Qty
</th>
)
: Quantity && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
{' '}
{WeightasKg ? 'Qty/Kg' : 'Qty'}
@ -558,14 +628,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalHsnCode && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
HSN
</th>
)
: HsnCode && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
HSN
</th>
@ -573,14 +643,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalMRP && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
MRP
</th>
)
: MRP && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
MRP
</th>
@ -588,14 +658,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalDiscount && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Dis{' '}
</th>
)
: Discount && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Dis{' '}
</th>
@ -603,7 +673,7 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalTax && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Tax %{' '}
</th>
@ -611,7 +681,7 @@ const PrintStyle11 = ({
: Tax &&
table2Data?.OrderType !== 'E' && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Tax %{' '}
</th>
@ -619,14 +689,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalRate && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Rate
</th>
)
: Rate && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Rate
</th>
@ -634,14 +704,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalAmount && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Amt
</th>
)
: Amount && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Amt
</th>
@ -651,7 +721,18 @@ const PrintStyle11 = ({
<tbody>
{dataChunk?.map((item, index) => {
return (
<tr key={index}>
<tr key={index}
style={
index % 2 !== 1 && rowtypeStyle === "even"
? {
...tableBodyStyle
}
: index % 2 === 1 && rowtypeStyle === "odd"
? {
...tableBodyStyle
}
: {}
}>
{GlobaldummyData
? GlobalSlNo && <td>{index + 1}</td>
: SLNO && (
@ -856,25 +937,25 @@ const PrintStyle11 = ({
<tr>
{GlobaldummyData
? GlobalSlNo && (
<th style={{ width: '10px' }}>S.N</th>
<th style={{...tableHeaderStyle, width: '10px' }}>S.N</th>
)
: SLNO && <th style={{ width: '10px' }}>S.N</th>}
: SLNO && <th style={{...tableHeaderStyle, width: '10px' }}>S.N</th>}
{GlobaldummyData
? GlobalItem && (
<th style={{ width: '10px' }}>Item</th>
<th style={{...tableHeaderStyle, width: '10px' }}>Item</th>
)
: Item && <th style={{ width: '10px' }}>Item</th>}
: Item && <th style={{...tableHeaderStyle, width: '10px' }}>Item</th>}
{GlobaldummyData
? GlobalQuantity && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Qty
</th>
)
: Quantity && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
{' '}
{WeightasKg ? 'Qty/Kg' : 'Qty'}
@ -883,14 +964,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalHsnCode && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
HSN
</th>
)
: HsnCode && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
HSN
</th>
@ -898,14 +979,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalMRP && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
MRP
</th>
)
: MRP && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
MRP
</th>
@ -913,14 +994,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalDiscount && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Dis{' '}
</th>
)
: Discount && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Dis{' '}
</th>
@ -928,7 +1009,7 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalTax && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Tax %{' '}
</th>
@ -936,7 +1017,7 @@ const PrintStyle11 = ({
: Tax &&
table2Data?.OrderType !== 'E' && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Tax %{' '}
</th>
@ -944,14 +1025,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalRate && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Rate
</th>
)
: Rate && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Rate
</th>
@ -959,14 +1040,14 @@ const PrintStyle11 = ({
{GlobaldummyData
? GlobalAmount && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Amt
</th>
)
: Amount && (
<th
style={{ width: '10px', textAlign: 'right' }}
style={{...tableHeaderStyle, width: '10px', textAlign: 'right' }}
>
Amt
</th>
@ -976,7 +1057,18 @@ const PrintStyle11 = ({
<tbody>
{dataChunk?.map((item, index) => {
return (
<tr key={index}>
<tr key={index}
style={
index % 2 !== 1 && rowtypeStyle === "even"
? {
...tableBodyStyle
}
: index % 2 === 1 && rowtypeStyle === "odd"
? {
...tableBodyStyle
}
: {}
}>
{GlobaldummyData
? GlobalSlNo && <td>{index + 1}</td>
: SLNO && (
@ -1191,6 +1283,7 @@ const PrintStyle11 = ({
textAlign: 'right',
fontWeight: '600',
fontSize: '18px',
...netAmountStyle
}}
>
Amount :
@ -1859,6 +1952,7 @@ const PrintStyle11 = ({
pageBreakBefore: 'avoid',
pageBreakInside: 'avoid',
minHeight: 'auto',
...footerColorStyle
}}
>
{GlobaldummyData
@ -2161,6 +2255,7 @@ const PrintStyle11 = ({
textAlign: 'right',
fontWeight: '600',
fontSize: '18px',
...netAmountStyle
}}
>
Amount :
@ -2812,6 +2907,7 @@ const PrintStyle11 = ({
pageBreakBefore: 'avoid',
pageBreakInside: 'avoid',
minHeight: 'auto',
...footerColorStyle
}}
>
{GlobaldummyData
@ -3016,8 +3112,8 @@ const PrintStyle11 = ({
{!estimatePrintHeader && table2Data?.OrderType === 'E' ? (
''
) : (
<div>
<div className="PrintStyle11-print">
<div style={{ ...headerStyle }}>
<div className="PrintStyle11-print" style={{ ...headerStyle }} >
{GlobalLogo && GlobaldummyData ? (
<img
className="PrintStyle2-BrandImage"
@ -3155,87 +3251,87 @@ const PrintStyle11 = ({
<thead>
<tr>
{GlobaldummyData
? GlobalSlNo && <th style={{ width: '10px' }}>S.N</th>
: SLNO && <th style={{ width: '10px' }}>S.N</th>}
? GlobalSlNo && <th style={{ ...tableHeaderStyle, width: '10px' }}>S.N</th>
: SLNO && <th style={{ ...tableHeaderStyle, width: '10px' }}>S.N</th>}
{GlobaldummyData
? GlobalItem && <th style={{ width: '10px' }}>Item</th>
: Item && <th style={{ width: '10px' }}>Item</th>}
? GlobalItem && <th style={{ ...tableHeaderStyle, width: '10px' }}>Item</th>
: Item && <th style={{ ...tableHeaderStyle, width: '10px' }}>Item</th>}
{GlobaldummyData
? GlobalQuantity && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Qty
</th>
)
: Quantity && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
{' '}
{WeightasKg ? 'Qty/Kg' : 'Qty'}
</th>
)}
{GlobaldummyData
? GlobalHsnCode && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
HSN
</th>
)
: HsnCode && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
HSN
</th>
)}
{GlobaldummyData
? GlobalMRP && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
MRP
</th>
)
: MRP && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
MRP
</th>
)}
{GlobaldummyData
? GlobalDiscount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Dis{' '}
</th>
)
: Discount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Dis{' '}
</th>
)}
{GlobaldummyData
? GlobalTax && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Tax %{' '}
</th>
)
: Tax &&
table2Data?.OrderType !== 'E' && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Tax %{' '}
</th>
)}
{GlobaldummyData
? GlobalRate && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Rate
</th>
)
: Rate && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Rate
</th>
)}
{GlobaldummyData
? GlobalAmount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Amt
</th>
)
: Amount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Amt
</th>
)}
@ -3245,7 +3341,18 @@ const PrintStyle11 = ({
{(GlobaldummyData ? products : TakeawayData)?.map(
(item, index) => {
return (
<tr key={index}>
<tr key={index}
style={
index % 2 !== 1 && rowtypeStyle === "even"
? {
...tableBodyStyle
}
: index % 2 === 1 && rowtypeStyle === "odd"
? {
...tableBodyStyle
}
: {}
}>
{GlobaldummyData
? GlobalSlNo && <td>{index + 1}</td>
: SLNO && <td>{index + 1}</td>}
@ -3466,87 +3573,87 @@ const PrintStyle11 = ({
<thead>
<tr>
{GlobaldummyData
? GlobalSlNo && <th style={{ width: '10px' }}>S.N</th>
: SLNO && <th style={{ width: '10px' }}>S.N</th>}
? GlobalSlNo && <th style={{ ...tableHeaderStyle, width: '10px' }}>S.N</th>
: SLNO && <th style={{ ...tableHeaderStyle, width: '10px' }}>S.N</th>}
{GlobaldummyData
? GlobalItem && <th style={{ width: '10px' }}>Item</th>
: Item && <th style={{ width: '10px' }}>Item</th>}
? GlobalItem && <th style={{ ...tableHeaderStyle, width: '10px' }}>Item</th>
: Item && <th style={{ ...tableHeaderStyle, width: '10px' }}>Item</th>}
{GlobaldummyData
? GlobalQuantity && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Qty
</th>
)
: Quantity && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
{' '}
{WeightasKg ? 'Qty/Kg' : 'Qty'}
</th>
)}
{GlobaldummyData
? GlobalHsnCode && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
HSN
</th>
)
: HsnCode && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
HSN
</th>
)}
{GlobaldummyData
? GlobalMRP && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
MRP
</th>
)
: MRP && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
MRP
</th>
)}
{GlobaldummyData
? GlobalDiscount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Dis{' '}
</th>
)
: Discount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Dis{' '}
</th>
)}
{GlobaldummyData
? GlobalTax && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Tax %{' '}
</th>
)
: Tax &&
table2Data?.OrderType !== 'E' && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Tax %{' '}
</th>
)}
{GlobaldummyData
? GlobalRate && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Rate
</th>
)
: Rate && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Rate
</th>
)}
{GlobaldummyData
? GlobalAmount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Amt
</th>
)
: Amount && (
<th style={{ width: '10px', textAlign: 'right' }}>
<th style={{ ...tableHeaderStyle, width: '10px', textAlign: 'right' }}>
Amt
</th>
)}
@ -3556,7 +3663,18 @@ const PrintStyle11 = ({
{(GlobaldummyData ? products : DineInData)?.map(
(item, index) => {
return (
<tr key={index}>
<tr key={index}
style={
index % 2 !== 1 && rowtypeStyle === "even"
? {
...tableBodyStyle
}
: index % 2 === 1 && rowtypeStyle === "odd"
? {
...tableBodyStyle
}
: {}
}>
{GlobaldummyData
? GlobalSlNo && <td>{index + 1}</td>
: SLNO && <td>{index + 1}</td>}
@ -3752,6 +3870,7 @@ const PrintStyle11 = ({
textAlign: 'right',
fontWeight: '600',
fontSize: '18px',
...netAmountStyle
}}
>
Amount :
@ -4323,6 +4442,7 @@ const PrintStyle11 = ({
pageBreakBefore: 'avoid',
pageBreakInside: 'avoid',
minHeight: 'auto',
...footerColorStyle
}}
>
{GlobaldummyData