major refactor of the dashboard and react-openapi integration #1
@@ -8,11 +8,12 @@ type DecoratedPeriod = ReportPeriod & {
|
||||
label: string;
|
||||
};
|
||||
|
||||
const TAB_TO_KEY: Record<string, "weekly" | "monthly" | "yearly" | "fyly"> = {
|
||||
const TAB_TO_KEY: Record<string, "weekly" | "monthly" | "yearly" | "fyly" | "full"> = {
|
||||
Weekly: "weekly",
|
||||
Monthly: "monthly",
|
||||
Yearly: "yearly",
|
||||
FYLY: "fyly"
|
||||
'Financial Year': "fyly",
|
||||
'All Time': "full"
|
||||
};
|
||||
|
||||
function getAmount(p: ReportPeriod, mode: "expense" | "income") {
|
||||
@@ -39,7 +40,7 @@ function mergeMetric(a: any, b: any) {
|
||||
|
||||
function mergeBuckets(
|
||||
buckets: any[],
|
||||
key: "weekly" | "monthly" | "yearly" | "fyly"
|
||||
key: "weekly" | "monthly" | "yearly" | "fyly" | "full"
|
||||
): DecoratedPeriod[] {
|
||||
const map = new Map<string, DecoratedPeriod>();
|
||||
|
||||
@@ -72,7 +73,7 @@ function mergeBuckets(
|
||||
|
||||
function attachComparison(
|
||||
points: ChartDataPoint[],
|
||||
key: "weekly" | "monthly" | "yearly" | "fyly"
|
||||
key: "weekly" | "monthly" | "yearly" | "fyly" | "full"
|
||||
): ChartDataPoint[] {
|
||||
const getCompareIndex = (i: number) => {
|
||||
if (key === "weekly") return i - 4;
|
||||
@@ -101,7 +102,7 @@ function attachComparison(
|
||||
|
||||
function buildChartData(
|
||||
reportData: HistoryChartProps["reportData"],
|
||||
key: "weekly" | "monthly" | "yearly" | "fyly",
|
||||
key: "weekly" | "monthly" | "yearly" | "fyly" | "full",
|
||||
mode: "expense" | "income",
|
||||
comparison: boolean
|
||||
): ChartDataPoint[] {
|
||||
@@ -157,7 +158,8 @@ export default function HistoryChart(props: HistoryChartProps) {
|
||||
weekly: 6,
|
||||
monthly: 4,
|
||||
yearly: 4,
|
||||
fyly: 4
|
||||
fyly: 4,
|
||||
full: 4,
|
||||
};
|
||||
|
||||
const visibleCount = visibleCountMap[activeDataKey] ?? 4;
|
||||
|
||||
@@ -67,6 +67,7 @@ export interface ReportBucket {
|
||||
monthly?: ReportPeriod[];
|
||||
yearly?: ReportPeriod[];
|
||||
fyly?: ReportPeriod[];
|
||||
full?: ReportPeriod[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ export interface ReportBucket {
|
||||
// -----------------------------
|
||||
|
||||
export interface ReportData {
|
||||
periods: ("weekly" | "monthly" | "yearly" | "fyly")[];
|
||||
periods: ("weekly" | "monthly" | "yearly" | "fyly" | "full")[];
|
||||
|
||||
rolling: boolean;
|
||||
report_date?: string;
|
||||
|
||||
Reference in New Issue
Block a user