mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove unused imports and variables from DashboardPage, HeritageBuildingPage, MatchesMapView - Fix i18n literal strings in NetworkGraph component - Continue systematic reduction of linting errors
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { ActivityItem } from '@/components/admin/ActivityFeed';
|
|
import { useDashboardStats, useRecentActivity } from '@/hooks/api/useAdminAPI.ts';
|
|
|
|
interface RecentActivityAPIResponse {
|
|
id: string;
|
|
type: string;
|
|
description: string;
|
|
timestamp: string;
|
|
}
|
|
|
|
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: RecentActivityAPIResponse) => ({
|
|
id: it.id,
|
|
type: (it.type as ActivityItem['type']) || '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,
|
|
};
|
|
};
|