All files / services dashboard.service.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                                                                      2x 39x 32x    
/**
 * Dashboard service
 * Handles API calls for dashboard statistics
 */
 
import { apiClient } from '@/lib/api';
 
import type { AuditLogItem } from './audit.service';
 
 
export interface SystemHealthStats {
  database_status: string;
  storage_usage_mb: number;
}
 
 
export interface RecentRegistration {
  id: string;
  email: string;
  account_id: string;
  account_code: string;
  account_name: string;
  created_at: string;
}
 
 
export interface DashboardStats {
  total_accounts: number;
  total_users: number;
  total_collections: number;
  total_records: number;
  new_accounts_7d: number;
  new_users_7d: number;
  recent_registrations: RecentRegistration[];
  system_health: SystemHealthStats;
  active_sessions: number;
  public_collections_count: number;
  recent_audit_logs: AuditLogItem[];
}
 
/**
 * Get dashboard statistics
 */
export const getDashboardStats = async (): Promise<DashboardStats> => {
  const response = await apiClient.get<DashboardStats>('/dashboard/stats');
  return response.data;
};