// src/pages/AdminStatsPage.tsx import React, { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { getApplicationStats, AppStats } from '../services/apiClient'; import { logger } from '../services/logger'; import { LoadingSpinner } from '../components/LoadingSpinner'; import { ChartBarIcon } from '../components/icons/ChartBarIcon'; import { UsersIcon } from '../components/icons/UsersIcon'; import { DocumentDuplicateIcon } from '../components/icons/DocumentDuplicateIcon'; import { BuildingStorefrontIcon } from '../components/icons/BuildingStorefrontIcon'; import { BellAlertIcon } from '../components/icons/BellAlertIcon'; const StatCard: React.FC<{ title: string; value: number | string; icon: React.ReactNode }> = ({ title, value, icon }) => (
{icon}

{title}

{value}

); export const AdminStatsPage: React.FC = () => { const [stats, setStats] = useState(null); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchStats = async () => { setIsLoading(true); setError(null); try { const data = await getApplicationStats(); setStats(data); } catch (err) { const errorMessage = err instanceof Error ? err.message : 'An unknown error occurred.'; logger.error('Failed to fetch application stats', { error: err }); setError(errorMessage); } finally { setIsLoading(false); } }; fetchStats(); }, []); return (
← Back to Admin Dashboard

Application Statistics

A high-level overview of key application metrics.

{isLoading &&
} {error &&
{error}
} {stats && !isLoading && !error && (
} /> } /> } /> } /> } />
)}
); };