feat: add stats page for admin
This commit is contained in:
@@ -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 || [];
|
||||
|
||||
Reference in New Issue
Block a user