mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 12:25:22 +02:00
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:
@@ -3,11 +3,12 @@ import {
|
||||
LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer
|
||||
} from 'recharts';
|
||||
import { SalesRecord, PivotRow } from '../types';
|
||||
import { pivotSalesData, generateCSV, aggregateForTimeSeries, aggregateForComparisonTimeSeries } from '../services/dataProcessor';
|
||||
import { pivotSalesData, generateCSV, aggregateForTimeSeries, aggregateForComparisonTimeSeries, applyPanEUGrouping } from '../services/dataProcessor';
|
||||
import { DownloadIcon, FunnelIcon, CloseIcon, ChartIcon } from './Icons';
|
||||
|
||||
interface DataGridProps {
|
||||
data: SalesRecord[];
|
||||
hasCustomerFilter: boolean;
|
||||
}
|
||||
|
||||
type SortConfig = {
|
||||
@@ -224,7 +225,7 @@ const ExpandableChartCard: React.FC<{ title: string; children: React.ReactNode;
|
||||
};
|
||||
|
||||
|
||||
const DataGrid: React.FC<DataGridProps> = ({ data }) => {
|
||||
const DataGrid: React.FC<DataGridProps> = ({ data, hasCustomerFilter }) => {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [sortConfig, setSortConfig] = useState<SortConfig>({ key: null, direction: 'desc' });
|
||||
const [showChart, setShowChart] = useState(true);
|
||||
@@ -248,8 +249,11 @@ const DataGrid: React.FC<DataGridProps> = ({ data }) => {
|
||||
|
||||
// Transform flat data into Pivot structure
|
||||
const { rows: pivotRows, years } = useMemo(() => {
|
||||
return pivotSalesData(data, effectiveDimensions);
|
||||
}, [data, effectiveDimensions]);
|
||||
// Apply Pan-EU grouping when no customer filter is applied
|
||||
const processedData = applyPanEUGrouping(data, hasCustomerFilter);
|
||||
|
||||
return pivotSalesData(processedData, effectiveDimensions);
|
||||
}, [data, effectiveDimensions, hasCustomerFilter]);
|
||||
|
||||
// Data for the time series chart, supporting single and multi-year comparison
|
||||
const { chartData, uniqueYears, isComparisonView, chartTitle } = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user