From 89ad8e376e6afdc738435fddd43ee6cf67e9b30e Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Sat, 25 Apr 2026 12:41:05 +0530 Subject: [PATCH] Progress Cards for Top Payees --- react-openapi/hooks/useResource.ts | 1 + src/Dashboard.tsx | 27 ++++++++++++++++++- .../ProgressCard/ProgressCard.models.ts | 1 + src/components/ProgressCard/ProgressCard.tsx | 3 ++- .../ProgressCard/ProgressCard.view.tsx | 25 ++++++++++------- src/components/ProgressCard/index.ts | 4 +-- src/features/dashboard/useDashboardData.ts | 10 ++++--- src/features/report/report.mapper.ts | 6 ++++- 8 files changed, 59 insertions(+), 18 deletions(-) diff --git a/react-openapi/hooks/useResource.ts b/react-openapi/hooks/useResource.ts index a3db964..8934129 100644 --- a/react-openapi/hooks/useResource.ts +++ b/react-openapi/hooks/useResource.ts @@ -16,6 +16,7 @@ export function useResource(config: ResourceConfig | undefined) { queryKey: [name, "list", params], queryFn: async () => { if (!endpoint) return { data: [], total: 0 }; + console.log('params:', params); // @ts-ignore const res = await api.get(endpoint, { params }); const total = res.headers ? parseInt(res.headers['x-total-count'] || res.headers['X-Total-Count']) : undefined; diff --git a/src/Dashboard.tsx b/src/Dashboard.tsx index 6afd4fd..0397633 100644 --- a/src/Dashboard.tsx +++ b/src/Dashboard.tsx @@ -6,11 +6,13 @@ import { CircularProgress, Alert, ToggleButton, - ToggleButtonGroup + ToggleButtonGroup, + Typography } from "@mui/material"; import LatestItems from "./components/LatestItems"; import HistoryChart from "./components/HistoryChart"; +import ProgressCard from "./components/ProgressCard"; import { useDashboardData } from "./features/dashboard"; @@ -107,6 +109,29 @@ export default function Dashboard() { colorScheme={colors} /> + + {data.topPayees && data.topPayees.length > 0 && ( + + + + Top {mode === "expense" ? "Payees" : "Payors"} + + + + {data.topPayees.map((payee: any) => ( + + + + ))} + + + )} ); } diff --git a/src/components/ProgressCard/ProgressCard.view.tsx b/src/components/ProgressCard/ProgressCard.view.tsx index 94454e8..0e6a0a7 100644 --- a/src/components/ProgressCard/ProgressCard.view.tsx +++ b/src/components/ProgressCard/ProgressCard.view.tsx @@ -20,14 +20,15 @@ export default function ProgressCardView({ percentage, prefixAmount, suffixString, + compact = false, }: ViewProps) { return ( colorTheme === "info" ? "linear-gradient(135deg, #0284c7 0%, #06b6d4 100%)" @@ -35,28 +36,32 @@ export default function ProgressCardView({ color: "#fff", display: "flex", flexDirection: "column", - alignItems: "center", + alignItems: compact ? "flex-start" : "center", justifyContent: "center", position: "relative", overflow: "hidden", boxShadow: (theme) => - `0 12px 24px -10px ${ + `0 ${compact ? 6 : 12}px ${compact ? 12 : 24}px -10px ${ theme.palette.mode === "dark" ? "#000" : theme.palette[colorTheme].main }`, }} > - + {header} - + {prefixAmount}{" "} {suffixString && ( {suffixString} @@ -64,12 +69,12 @@ export default function ProgressCardView({ )} - + = {}; - for (const b of weekly) { + const sourceForPayees = (payeeBuckets && payeeBuckets.length > 0) ? payeeBuckets : weekly; + + for (const b of sourceForPayees) { for (const g of b.groups) { const key = g.group_key || "Unknown"; const amt = g?.[flow]?.sum || 0; @@ -84,6 +87,7 @@ export function mapReportToDashboard( } const topPayees = Object.entries(payeeMap) + // .filter(([name]) => name !== "Unknown") .map(([payeeName, amount]) => ({ payeeName, amount })) .sort((a, b) => b.amount - a.amount) .slice(0, 5);