mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:45:23 +02:00
feat: restrict data to Amazon customers only (DE/FR/ES/IT/UK/SC)
This commit is contained in:
@@ -151,6 +151,14 @@ 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'];
|
||||
|
||||
const isAllowedCustomer = (customer: string): boolean => {
|
||||
if (!customer) return false;
|
||||
const normCustomer = customer.trim().toLowerCase();
|
||||
return ALLOWED_CUSTOMERS.some(allowed => allowed.toLowerCase() === normCustomer);
|
||||
};
|
||||
|
||||
// --- SALES / SELL OUT MAPPING ---
|
||||
|
||||
@@ -216,8 +224,8 @@ export const processCSV = (fileOrContent: File | string): Promise<SalesRecord[]>
|
||||
const data: SalesRecord[] = results.data.map((row: any, index: number) => {
|
||||
return mapRowToRecord(row, index);
|
||||
})
|
||||
// Relaxed filtering: Only exclude rows with absolutely no year info even after backfill
|
||||
.filter((r: SalesRecord) => r.year > 0);
|
||||
// Filter: Valid Year AND Allowed Customer
|
||||
.filter((r: SalesRecord) => r.year > 0 && isAllowedCustomer(r.customer));
|
||||
|
||||
resolve(data);
|
||||
} catch (err) {
|
||||
@@ -240,8 +248,8 @@ export const processExcel = async (file: File): Promise<SalesRecord[]> => {
|
||||
const data: SalesRecord[] = jsonData.map((row: any, index: number) => {
|
||||
return mapRowToRecord(row, index);
|
||||
})
|
||||
// Relaxed filtering
|
||||
.filter((r: SalesRecord) => r.year > 0);
|
||||
// Filter: Valid Year AND Allowed Customer
|
||||
.filter((r: SalesRecord) => r.year > 0 && isAllowedCustomer(r.customer));
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user