feat: optimize Weekly Sales performance and implement Pan-EU default filter

- Implemented pagination and local search in WeeklyGrid to handle large datasets.
- Refactored Weekly Sales tab to show units and ad spend per SKU.
- Added default Pan-EU country filter (DE, FR, IT, ES) when no country is selected.
This commit is contained in:
Christian Vidal Wolf
2026-01-21 16:28:56 +01:00
parent e93da747a3
commit e2e5314b55
2 changed files with 166 additions and 85 deletions
+8 -7
View File
@@ -152,7 +152,8 @@ const getColumnValue = (row: any, aliases: string[]): string => {
return '';
};
// Allowed Customers Whitelist
const ALLOWED_CUSTOMERS = ['Amazon DE', 'Amazon FR', 'Amazon ES', 'Amazon IT', 'Amazon UK', 'Amazon SC'];
export const PAN_EU_COUNTRIES = ['Amazon DE', 'Amazon IT', 'Amazon FR', 'Amazon ES'];
const ALLOWED_CUSTOMERS = [...PAN_EU_COUNTRIES, 'Amazon UK', 'Amazon SC'];
const isAllowedCustomer = (customer: string): boolean => {
if (!customer) return false;
@@ -550,8 +551,9 @@ export const mergeSalesAndAdsData = (salesData: SalesRecord[], adsData: AdsRecor
export const filterAdsData = (adsData: AdsRecord[], filters: FilterState): AdsRecord[] => {
return adsData.filter(ad => {
// Country/Customer match (ads use 'country', sales use 'customer')
const countryMatch = filters.customer.length === 0 ||
filters.customer.some(c => c.toUpperCase() === ad.country.toUpperCase());
const countryMatch = filters.customer.length === 0
? PAN_EU_COUNTRIES.some(c => c.toUpperCase() === ad.country.toUpperCase())
: filters.customer.some(c => c.toUpperCase() === ad.country.toUpperCase());
// Year match
const yearMatch = filters.year.length === 0 ||
@@ -576,7 +578,9 @@ export const filterData = (data: SalesRecord[], filters: FilterState): SalesReco
const pureMonth = recordMonth.split('-')[0]; // "Apr"
// 2. Filter Checks
const customerMatch = filters.customer.length === 0 || filters.customer.includes(item.customer);
const customerMatch = filters.customer.length === 0
? PAN_EU_COUNTRIES.includes(item.customer)
: filters.customer.includes(item.customer);
const yearMatch = filters.year.length === 0 || filters.year.includes(item.year.toString());
// Check match against pure month ("Apr") OR full month ("Apr-23") just in case filters evolve
@@ -998,9 +1002,6 @@ export const applyPanEUGrouping = (
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)) {