mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { ActivityItem } from '@/components/admin/ActivityFeed';
|
|
import { useDashboardStats, useRecentActivity } from '@/hooks/api/useAdminAPI.ts';
|
|
|
|
export const useAdminDashboard = () => {
|
|
const { data: dashboardStats, isLoading, error } = useDashboardStats();
|
|
|
|
// Ensure stats always has valid numbers
|
|
const stats = {
|
|
total: dashboardStats?.totalOrganizations ?? 0,
|
|
verified: dashboardStats?.verifiedOrganizations ?? 0,
|
|
connections: dashboardStats?.activeConnections ?? 0,
|
|
newLast30Days: dashboardStats?.newThisMonth ?? 0,
|
|
};
|
|
|
|
// Activity feed
|
|
const { data: recentActivityData } = useRecentActivity();
|
|
const recentActivity: ActivityItem[] = (recentActivityData || []).map((it: any) => ({
|
|
id: it.id,
|
|
type: (it.type as any) || 'other',
|
|
action: it.description,
|
|
timestamp: new Date(it.timestamp),
|
|
}));
|
|
|
|
// Quick actions data from API
|
|
const quickActions = {
|
|
pendingVerifications: dashboardStats?.pendingVerifications ?? 0,
|
|
pendingTranslations: dashboardStats?.pendingTranslations ?? 0,
|
|
systemAlerts: dashboardStats?.systemAlerts ?? 0,
|
|
};
|
|
|
|
return {
|
|
stats,
|
|
recentActivity,
|
|
quickActions,
|
|
isLoading,
|
|
error,
|
|
};
|
|
};
|