feat: Integrate PapaParse for CSV handling

Adds papaparse as a dependency and updates the data processing service to use it for more robust CSV file parsing. This replaces manual CSV parsing logic with a dedicated library, improving reliability and handling of various CSV formats.

Also renames the `MoversIcon` to `TrendingIcon` to better reflect its usage in indicating trending performance metrics.
This commit is contained in:
Christian
2025-12-11 14:03:33 +01:00
parent 9ba63ab8f8
commit 31eed97ec4
14 changed files with 1311 additions and 1333 deletions
+51 -8
View File
@@ -1,5 +1,4 @@
export interface SalesRecord {
id: string;
customer: string;
@@ -25,7 +24,7 @@ export interface FilterState {
title: string[]; // Added Title filter
}
export interface LineGrowthMetric { // Renamed from GrowthMetric
export interface GrowthMetric {
line: string;
currentYearSellOut: number;
previousYearSellOut: number;
@@ -38,23 +37,23 @@ export interface LineGrowthMetric { // Renamed from GrowthMetric
unitsGrowthPercentage: number;
}
export type LineGrowthMetric = GrowthMetric;
export interface ItemGrowthMetric {
sku: string;
asin: string;
title: string;
line: string; // Keep line for context
line: string;
currentYearSellOut: number;
previousYearSellOut: number;
sellOutGrowthValue: number;
sellOutGrowthPercentage: number;
currentYearUnits: number;
previousYearUnits: number;
unitsGrowthValue: number;
unitsGrowthPercentage: number;
}
export interface SeasonalityPoint {
name: string; // "Jan", "Feb", etc.
[year: string]: number | string; // Dynamic keys for years: "2023": 500, "2024": 600
@@ -75,8 +74,8 @@ export interface AggregatedData {
seasonality: SeasonalityPoint[];
seasonalityUnits: SeasonalityPoint[];
availableYears: string[];
topMovers: LineGrowthMetric[]; // Now uses LineGrowthMetric
bottomMovers: LineGrowthMetric[]; // Now uses LineGrowthMetric
topMovers: GrowthMetric[];
bottomMovers: GrowthMetric[];
comparisonPeriods: { current: string; previous: string };
topLinesSplit: YearlySplitData[];
byCustomerSplit: YearlySplitData[];
@@ -124,4 +123,48 @@ export interface ComparisonTimeSeriesPoint {
week: number;
name: string; // "W1", "W2", etc.
[key: string]: number | string; // Dynamic keys like "2023_sellOut", "2024_units"
}
}
export interface AdsRecord {
country: string;
month: string;
asin: string;
cost: number;
clicks: number;
impressions: number;
attributedSales30d: number;
attributedUnits30d: number;
}
export interface CombinedKPIs {
id: string;
marketplace: string;
month: string;
year: number;
asin: string;
title: string;
line: string;
sku: string;
salesTotal: number;
unitsTotal: number;
salesAds: number;
unitsAds: number;
cost: number;
clicks: number;
impressions: number;
salesOrganic: number;
unitsOrganic: number;
paidSalesShare: number;
organicSalesShare: number;
acos: number;
tacos: number;
roas: number;
ctr: number;
cpc: number;
cvrUnits: number;
}