feat: add stats page for admin

This commit is contained in:
2026-05-10 15:39:26 +02:00
parent a081fd3b4d
commit 3c16ca015d
6 changed files with 527 additions and 0 deletions
+24
View File
@@ -53,6 +53,30 @@ export const logoutAdmin = async (): Promise<void> => {
}
};
// ── Types stats ──────────────────────────────────────────────────────────────
export interface StatsSummary {
total_orders: number;
total_revenue: number;
peak_weekday: string;
top_product: string;
avg_per_day: number;
}
export interface WeekdayStat { weekday: string; count: number; }
export interface DayStat { day: string; label: string; count: number; }
export interface ProductStat { product_id: number; name: string; quantity: number; order_count: number; revenue: number; }
export interface AdminStats {
summary: StatsSummary;
by_weekday: WeekdayStat[];
by_day_30: DayStat[];
top_products: ProductStat[];
}
export const getAdminStats = async (): Promise<AdminStats> => {
const { data } = await apiClient.get(`${V2}/admin/protected/stats`);
return data;
};
export const getAllClients = async (): Promise<ClientResponse[]> => {
const { data } = await apiClient.get(`${V2}/admin/protected/all/clients`);
return data.clients || [];