mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 11:45:23 +02:00
fix: resolve DataGrid product rendering failure by updating isRealSale to support CombinedKPIs and ignoring non-flat columns in filterData
This commit is contained in:
@@ -346,7 +346,9 @@ export const isRealSale = (record: any): boolean => {
|
|||||||
|
|
||||||
// 3. Units check: Real sales must have units.
|
// 3. Units check: Real sales must have units.
|
||||||
// Records with 0 units or negative units (unless it's a return, but usually returns have an ASIN)
|
// Records with 0 units or negative units (unless it's a return, but usually returns have an ASIN)
|
||||||
if (!record.units || record.units <= 0) return false;
|
// Supports both SalesRecord (units) and CombinedKPIs (unitsTotal)
|
||||||
|
const units = record.units !== undefined ? record.units : record.unitsTotal;
|
||||||
|
if (units === undefined || units <= 0) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -1163,6 +1165,7 @@ export const filterData = (
|
|||||||
// Apply selected values filter
|
// Apply selected values filter
|
||||||
if (condition.selectedValues && condition.selectedValues.length > 0) {
|
if (condition.selectedValues && condition.selectedValues.length > 0) {
|
||||||
result = result.filter(r => {
|
result = result.filter(r => {
|
||||||
|
if (!((key as string) in r)) return true; // Skip if key not in flat record
|
||||||
const val = String((r as any)[key] || '');
|
const val = String((r as any)[key] || '');
|
||||||
return condition.selectedValues?.includes(val);
|
return condition.selectedValues?.includes(val);
|
||||||
});
|
});
|
||||||
@@ -1174,6 +1177,7 @@ export const filterData = (
|
|||||||
const lowerValue = value.toLowerCase();
|
const lowerValue = value.toLowerCase();
|
||||||
|
|
||||||
result = result.filter(r => {
|
result = result.filter(r => {
|
||||||
|
if (!((key as string) in r)) return true; // Skip if key not in flat record
|
||||||
const rowVal = String((r as any)[key] || '').toLowerCase();
|
const rowVal = String((r as any)[key] || '').toLowerCase();
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case 'equals': return rowVal === lowerValue;
|
case 'equals': return rowVal === lowerValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user