fix: resolve DataGrid product rendering failure by updating isRealSale to support CombinedKPIs and ignoring non-flat columns in filterData

This commit is contained in:
Christian Vidal Wolf
2026-04-30 10:38:46 +02:00
parent a75fd32a05
commit 4fbe7570a9
+5 -1
View File
@@ -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;