mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 17:35: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 '';
|
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 ---
|
// --- 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) => {
|
const data: SalesRecord[] = results.data.map((row: any, index: number) => {
|
||||||
return mapRowToRecord(row, index);
|
return mapRowToRecord(row, index);
|
||||||
})
|
})
|
||||||
// Relaxed filtering: Only exclude rows with absolutely no year info even after backfill
|
// Filter: Valid Year AND Allowed Customer
|
||||||
.filter((r: SalesRecord) => r.year > 0);
|
.filter((r: SalesRecord) => r.year > 0 && isAllowedCustomer(r.customer));
|
||||||
|
|
||||||
resolve(data);
|
resolve(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -240,8 +248,8 @@ export const processExcel = async (file: File): Promise<SalesRecord[]> => {
|
|||||||
const data: SalesRecord[] = jsonData.map((row: any, index: number) => {
|
const data: SalesRecord[] = jsonData.map((row: any, index: number) => {
|
||||||
return mapRowToRecord(row, index);
|
return mapRowToRecord(row, index);
|
||||||
})
|
})
|
||||||
// Relaxed filtering
|
// Filter: Valid Year AND Allowed Customer
|
||||||
.filter((r: SalesRecord) => r.year > 0);
|
.filter((r: SalesRecord) => r.year > 0 && isAllowedCustomer(r.customer));
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user