diff --git a/react-openapi/index.ts b/react-openapi/index.ts new file mode 100644 index 0000000..c9dd6a5 --- /dev/null +++ b/react-openapi/index.ts @@ -0,0 +1,4 @@ +export { default as Admin } from "./Admin"; +export { api, auth, initializeApiClients } from "./api/client"; +export { getAppConfig } from "./config"; +export type { AppConfig, ResourceConfig, ResourceField } from "./types/config"; diff --git a/src/Dashboard.tsx b/src/Dashboard.tsx new file mode 100644 index 0000000..c32e87f --- /dev/null +++ b/src/Dashboard.tsx @@ -0,0 +1,140 @@ +import * as React from "react"; +import { Box, Container, Grid, Typography, Avatar } from "@mui/material"; +import LatestItemsList, { LatestItem } from "./components/LatestItemsList"; +import ProgressCard from "./components/ProgressCard"; +import HistoryChart from "./components/HistoryChart"; +import ShoppingBagIcon from "@mui/icons-material/ShoppingBag"; +import SubscriptionsIcon from "@mui/icons-material/Subscriptions"; +import RestaurantIcon from "@mui/icons-material/Restaurant"; +import FoodBankIcon from "@mui/icons-material/FoodBank"; + +const mockLatestItems: LatestItem[] = [ + { + id: 1, + icon: , + iconBgColor: "#e8f5e9", + title: "Grocery Shopping", + subtitle: "Buy some grocery", + amount: "Rs 3000", + timeAgo: "3 days ago", + }, + { + id: 2, + icon: , + iconBgColor: "#f3e5f5", + title: "Subscription", + subtitle: "Netflix monthly", + amount: "Rs 800", + timeAgo: "5 days ago", + }, + { + id: 3, + icon: , + iconBgColor: "#ffebee", + title: "Food", + subtitle: "Buy a chinese noodles", + amount: "Rs 1000", + timeAgo: "6 days ago", + }, + { + id: 4, + icon: , + iconBgColor: "#fff8e1", + title: "Food Club", + subtitle: "Buy a chinese noodles", + amount: "Rs 1000", + timeAgo: "6 days ago", + }, +]; + +const mockChartData = { + today: [ + { id: "6am", amount: 100 }, + { id: "9am", amount: 500 }, + { id: "12pm", amount: 200 }, + { id: "3pm", amount: 1000, highlighted: true }, + { id: "6pm", amount: 600 }, + { id: "9pm", amount: 300 }, + ], + week: [ + { id: "Mon", amount: 1500 }, + { id: "Tue", amount: 1000 }, + { id: "Wed", amount: 2000 }, + { id: "Thu", amount: 500, highlighted: true }, + { id: "Fri", amount: 3000 }, + { id: "Sat", amount: 4500 }, + { id: "Sun", amount: 2000 }, + ], + month: [ + { id: "Week 1", amount: 10000 }, + { id: "Week 2", amount: 5000 }, + { id: "Week 3", amount: 12000, highlighted: true }, + { id: "Week 4", amount: 8000 }, + ], + year: [ + { id: "Q1", amount: 50000 }, + { id: "Q2", amount: 45000 }, + { id: "Q3", amount: 60000, highlighted: true }, + { id: "Q4", amount: 48000 }, + ], +}; + +export default function Dashboard() { + return ( + + + {/* Left Column */} + + {/* User Greeting */} + + + + Hello Ananya + Good Morning + + + + + + + {}} + /> + + + + {/* Right Column */} + + + Statistics + + + + + + + + + + + ); +} diff --git a/src/Header.tsx b/src/Header.tsx index c7c8875..8fbbdfb 100644 --- a/src/Header.tsx +++ b/src/Header.tsx @@ -99,6 +99,13 @@ export default function Header({ mr: 2, }} > + + )} + + + {/* List */} + + {items.map((item, index) => ( + + + + {item.icon} + + + + + {item.title} + + } + secondary={ + + {item.subtitle} + + } + /> + + + + {item.amount} + + + {item.timeAgo} + + + + ))} + + + ); +} diff --git a/src/components/ProgressCard.tsx b/src/components/ProgressCard.tsx new file mode 100644 index 0000000..74c66d3 --- /dev/null +++ b/src/components/ProgressCard.tsx @@ -0,0 +1,80 @@ +import * as React from "react"; +import { Box, Typography, Paper, LinearProgress, linearProgressClasses } from "@mui/material"; + +export interface ProgressCardProps { + header: string; + summary?: string; + progressAmount: number; + totalAmount: number; + colorTheme?: "primary" | "secondary" | "error" | "info" | "success" | "warning"; +} + +export default function ProgressCard({ + header, + summary, + progressAmount, + totalAmount, + colorTheme = "info", +}: ProgressCardProps) { + const percentage = Math.min(100, Math.max(0, (progressAmount / totalAmount) * 100)) || 0; + + const displaySummary = summary ?? `Rs ${progressAmount} / Rs ${totalAmount}`; + + const parts = displaySummary.split('/'); + const prefixAmount = parts[0]?.trim() || ''; + const suffixString = parts.length > 1 ? `/ ${parts.slice(1).join('/').trim()}` : ''; + + return ( + + colorTheme === "info" + ? "linear-gradient(135deg, #0284c7 0%, #06b6d4 100%)" + : `linear-gradient(135deg, ${theme.palette[colorTheme].main} 0%, ${theme.palette[colorTheme].light} 100%)`, + color: "#fff", + display: "flex", + flexDirection: "column", + alignItems: "center", + justifyContent: "center", + position: 'relative', + overflow: 'hidden', + boxShadow: (theme) => `0 12px 24px -10px ${theme.palette.mode === 'dark' ? '#000' : theme.palette[colorTheme].main}`, + }} + > + + {header} + + + + {prefixAmount}{" "} + {suffixString && ( + + {suffixString} + + )} + + + + + + + ); +} diff --git a/src/main.jsx b/src/main.jsx index fae4cae..c1c76f8 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -11,6 +11,7 @@ import { Toolbar } from "@mui/material"; import Home from './Home'; +import Dashboard from './Dashboard'; import { Admin, initializeApiClients } from '../react-openapi'; import { configuration, profileConfiguration } from './openapi-config'; import { Buffer } from 'buffer'; @@ -35,6 +36,7 @@ initializeApiClients(API_BASE, AUTH_BASE); const routerMapping = [ { path: "/", component: Home, headerTitle: "Home" }, { path: "/home", component: Home, headerTitle: "Home" }, + { path: "/dashboard", component: Dashboard, headerTitle: "Dashboard" }, { path: "/admin/*", component: Admin, headerTitle: "Admin" }, ];