feat(api): add stats chart endpoint for admin access with time series data
feat(dayjs): integrate dayjs for date handling and formatting across the application refactor(routes): update date handling in id-tags, transactions, users, and dashboard routes to use dayjs style(globals): improve CSS variable definitions for better readability and consistency deps: add dayjs as a dependency for date manipulation
This commit is contained in:
@@ -154,9 +154,21 @@ export type PaginatedTransactions = {
|
||||
|
||||
// ── API functions ──────────────────────────────────────────────────────────
|
||||
|
||||
export type ChartRange = "30d" | "7d" | "24h";
|
||||
|
||||
export type ChartDataPoint = {
|
||||
bucket: string;
|
||||
energyKwh: number;
|
||||
revenue: number;
|
||||
transactions: number;
|
||||
utilizationPct: number;
|
||||
};
|
||||
|
||||
export const api = {
|
||||
stats: {
|
||||
get: () => apiFetch<Stats | UserStats>("/api/stats"),
|
||||
chart: (range: ChartRange) =>
|
||||
apiFetch<ChartDataPoint[]>(`/api/stats/chart?range=${range}`),
|
||||
},
|
||||
chargePoints: {
|
||||
list: () => apiFetch<ChargePoint[]>("/api/charge-points"),
|
||||
|
||||
8
apps/web/lib/dayjs.ts
Normal file
8
apps/web/lib/dayjs.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import dayjs from "dayjs";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import "dayjs/locale/zh-cn";
|
||||
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.locale("zh-cn");
|
||||
|
||||
export default dayjs;
|
||||
Reference in New Issue
Block a user