major refactor of the dashboard and react-openapi integration #1

Merged
aetos merged 44 commits from period-selection into main 2026-05-07 11:00:54 +00:00
Showing only changes of commit 04b72d5843 - Show all commits

View File

@@ -70,6 +70,35 @@ function mergeBuckets(
); );
} }
function attachComparison(
points: ChartDataPoint[],
key: "weekly" | "monthly" | "yearly" | "fyly"
): ChartDataPoint[] {
const getCompareIndex = (i: number) => {
if (key === "weekly") return i - 4;
if (key === "monthly") return i - 12;
if (key === "yearly") return i - 1;
if (key === "fyly") return i - 1;
return -1;
};
return points.map((p, i) => {
const ci = getCompareIndex(i);
return {
...p,
compare:
ci >= 0 && points[ci]
? {
id: points[ci].id,
label: points[ci].label,
amount: points[ci].amount
}
: undefined
};
});
}
function buildChartData( function buildChartData(
reportData: HistoryChartProps["reportData"], reportData: HistoryChartProps["reportData"],
key: "weekly" | "monthly" | "yearly" | "fyly", key: "weekly" | "monthly" | "yearly" | "fyly",
@@ -86,17 +115,7 @@ function buildChartData(
})); }));
if (comparison) { if (comparison) {
points = points.map((p, i) => ({ points = attachComparison(points, key);
...p,
compare:
i > 0
? {
id: points[i - 1].id,
label: points[i - 1].label,
amount: points[i - 1].amount
}
: undefined
}));
} }
return points; return points;