feat: Implement Pan-EU grouping in Grid tab

- Added applyPanEUGrouping() helper function in dataProcessor.ts
- Groups Amazon DE/IT/FR/ES as 'Pan-EU' when no customer filter applied
- Shows individual countries when specific filter is selected
- Updated DataGrid to accept hasCustomerFilter prop
- Updated App.tsx to pass filter state to DataGrid
- Keeps Amazon UK and Amazon SC separate
- Verified with browser testing: grouping works correctly
This commit is contained in:
Christian Vidal Wolf
2026-01-20 12:59:35 +01:00
parent 98aba3e36b
commit 67951bcac8
3 changed files with 39 additions and 5 deletions
+30
View File
@@ -924,6 +924,36 @@ export const aggregateData = (data: SalesRecord[]): AggregatedData => {
};
};
/**
* Groups Pan-EU countries (Amazon DE, IT, FR, ES) into a single "Pan-EU" customer
* when no customer filter is applied. This provides a consolidated view of European
* markets while keeping UK and SC separate.
*
* @param data - Array of sales records
* @param hasCustomerFilter - Whether a customer filter is currently applied
* @returns Processed data with Pan-EU grouping applied if appropriate
*/
export const applyPanEUGrouping = (
data: SalesRecord[],
hasCustomerFilter: boolean
): SalesRecord[] => {
// If customer filter is applied, don't group - show selected countries as-is
if (hasCustomerFilter) {
return data;
}
// Define Pan-EU countries
const PAN_EU_COUNTRIES = ['Amazon DE', 'Amazon IT', 'Amazon FR', 'Amazon ES'];
// Replace Pan-EU country names with "Pan-EU" for grouping
return data.map(record => {
if (PAN_EU_COUNTRIES.includes(record.customer)) {
return { ...record, customer: 'Pan-EU' };
}
return record;
});
};
export const getUniqueValues = (data: SalesRecord[], field: keyof SalesRecord): string[] => {
const values = new Set(data.map(item => String(item[field])));
return Array.from(values).sort();