diff --git a/frontend/src/app/[locale]/admin/page.tsx b/frontend/src/app/[locale]/admin/page.tsx index e18ac9d..11a7ee4 100644 --- a/frontend/src/app/[locale]/admin/page.tsx +++ b/frontend/src/app/[locale]/admin/page.tsx @@ -19,7 +19,11 @@ import { useQuery } from '@tanstack/react-query'; import { getAdminStats } from '@/lib/api/admin'; export default function AdminPage() { - const { data: stats, isLoading, error } = useQuery({ + const { + data: stats, + isLoading, + error, + } = useQuery({ queryKey: ['admin', 'stats'], queryFn: async () => { const response = await getAdminStats(); diff --git a/frontend/src/lib/api/admin.ts b/frontend/src/lib/api/admin.ts index 52b52ab..01a2c3a 100644 --- a/frontend/src/lib/api/admin.ts +++ b/frontend/src/lib/api/admin.ts @@ -2,44 +2,51 @@ import { apiClient } from './client'; import type { Options } from './generated/sdk.gen'; export interface UserGrowthData { - date: string; - total_users: number; - active_users: number; + date: string; + total_users: number; + active_users: number; } export interface OrgDistributionData { - name: string; - value: number; + name: string; + value: number; } export interface UserStatusData { - name: string; - value: number; + name: string; + value: number; } export interface AdminStatsResponse { - user_growth: UserGrowthData[]; - organization_distribution: OrgDistributionData[]; - user_status: UserStatusData[]; + user_growth: UserGrowthData[]; + organization_distribution: OrgDistributionData[]; + user_status: UserStatusData[]; } +export type AdminStatsData = { + body?: never; + path?: never; + query?: never; + url: '/api/v1/admin/stats'; +}; + /** * Admin: Get Dashboard Stats * * Get aggregated statistics for the admin dashboard (admin only) */ export const getAdminStats = ( - options?: Options + options?: Options ) => { - return (options?.client ?? apiClient).get({ - responseType: 'json', - security: [ - { - scheme: 'bearer', - type: 'http', - }, - ], - url: '/api/v1/admin/stats', - ...options, - }); + return (options?.client ?? apiClient).get({ + responseType: 'json', + security: [ + { + scheme: 'bearer', + type: 'http', + }, + ], + url: '/api/v1/admin/stats', + ...options, + }); }; diff --git a/frontend/tests/components/charts/OrganizationDistributionChart.test.tsx b/frontend/tests/components/charts/OrganizationDistributionChart.test.tsx index a9afbd8..01ed556 100644 --- a/frontend/tests/components/charts/OrganizationDistributionChart.test.tsx +++ b/frontend/tests/components/charts/OrganizationDistributionChart.test.tsx @@ -19,9 +19,9 @@ jest.mock('recharts', () => { describe('OrganizationDistributionChart', () => { const mockData: OrganizationDistributionData[] = [ - { name: 'Engineering', members: 45, activeMembers: 42 }, - { name: 'Marketing', members: 28, activeMembers: 25 }, - { name: 'Sales', members: 35, activeMembers: 33 }, + { name: 'Engineering', value: 45 }, + { name: 'Marketing', value: 28 }, + { name: 'Sales', value: 35 }, ]; it('renders chart card with title and description', () => { diff --git a/frontend/tests/components/charts/UserGrowthChart.test.tsx b/frontend/tests/components/charts/UserGrowthChart.test.tsx index d49765d..ee10532 100644 --- a/frontend/tests/components/charts/UserGrowthChart.test.tsx +++ b/frontend/tests/components/charts/UserGrowthChart.test.tsx @@ -19,9 +19,9 @@ jest.mock('recharts', () => { describe('UserGrowthChart', () => { const mockData: UserGrowthData[] = [ - { date: 'Jan 1', totalUsers: 100, activeUsers: 80 }, - { date: 'Jan 2', totalUsers: 105, activeUsers: 85 }, - { date: 'Jan 3', totalUsers: 110, activeUsers: 90 }, + { date: 'Jan 1', total_users: 100, active_users: 80 }, + { date: 'Jan 2', total_users: 105, active_users: 85 }, + { date: 'Jan 3', total_users: 110, active_users: 90 }, ]; it('renders chart card with title and description', () => {