major refactor of the dashboard and react-openapi integration #1
@@ -17,6 +17,9 @@ export interface ChartDataPoint extends _ChartDataPoint {
|
||||
export interface ChartData {
|
||||
weekly?: Record<string, ChartDataPoint[]>;
|
||||
monthly?: Record<string, ChartDataPoint[]>;
|
||||
// yearly?: Record<string, ChartDataPoint[]>;
|
||||
// fyly?: Record<string, ChartDataPoint[]>;
|
||||
// full?: Record<string, ChartDataPoint[]>;
|
||||
}
|
||||
|
||||
export interface HistoryChartProps {
|
||||
|
||||
@@ -28,6 +28,7 @@ export default function HistoryChart(props: HistoryChartProps) {
|
||||
: 1;
|
||||
|
||||
const visibleCountMap = { daily: 7, weekly: 6, monthly: 4 };
|
||||
// const visibleCountMap = { daily: 7, weekly: 6, monthly: 4, yearly: 4, fyly: 4, full: 4 };
|
||||
const visibleCount = visibleCountMap[activeDataKey];
|
||||
|
||||
const total = currentData.length;
|
||||
|
||||
@@ -13,6 +13,7 @@ export const configuration: DashboardConfig = {
|
||||
dataKey: "chartData",
|
||||
settings: {
|
||||
tabs: ["Weekly", "Monthly"],
|
||||
// tabs: ["Weekly", "Monthly", "Yearly", "Financial Year", "All Time"],
|
||||
},
|
||||
style: {
|
||||
size: 12,
|
||||
|
||||
@@ -47,7 +47,7 @@ const sumBucket = (bucket: ReportBucket, flow: "expenses" | "incomes") =>
|
||||
0
|
||||
);
|
||||
|
||||
const toLabel = (start: string, end: string, type: "weekly" | "monthly") => {
|
||||
const toLabel = (start: string, end: string, type: "weekly" | "monthly" | "yearly" | "fyly" | "full") => {
|
||||
const s = new Date(start);
|
||||
const e = new Date(end);
|
||||
|
||||
@@ -68,7 +68,7 @@ const getWeekOfMonth = (date: Date) => {
|
||||
const findCompareBucket = (
|
||||
current: ReportBucket,
|
||||
buckets: ReportBucket[],
|
||||
type: "weekly" | "monthly"
|
||||
type: "weekly" | "monthly" | "yearly" | "fyly" | "full",
|
||||
): ReportBucket | undefined => {
|
||||
const start = new Date(current.start);
|
||||
|
||||
@@ -105,7 +105,7 @@ const findCompareBucket = (
|
||||
|
||||
const toPoints = (
|
||||
buckets: ReportBucket[],
|
||||
type: "weekly" | "monthly",
|
||||
type: "weekly" | "monthly" | "yearly" | "fyly" | "full",
|
||||
flow: "expenses" | "incomes"
|
||||
): ChartDataPoint[] => {
|
||||
return buckets.map((b) => {
|
||||
@@ -143,6 +143,21 @@ export function mapReportToDashboard(
|
||||
rolling: toPoints(monthly, "monthly", flow),
|
||||
calendar: toPoints(monthly, "monthly", flow),
|
||||
},
|
||||
|
||||
// yearly: {
|
||||
// rolling: toPoints(yearly, "yearly", flow),
|
||||
// calendar: toPoints(yearly, "yearly", flow),
|
||||
// },
|
||||
//
|
||||
// fyly: {
|
||||
// rolling: toPoints(fyly, "fyly", flow),
|
||||
// calendar: toPoints(fyly, "fyly", flow),
|
||||
// },
|
||||
//
|
||||
// full: {
|
||||
// rolling: toPoints(full, "full", flow),
|
||||
// calendar: toPoints(full, "full", flow),
|
||||
// },
|
||||
};
|
||||
|
||||
const totalAmount = weekly.reduce(
|
||||
|
||||
Reference in New Issue
Block a user