import { useDashboardRole } from '../../hooks/useDashboardRole';
import { usePermission } from '../../hooks/usePermission';
import { Result } from 'antd';
import { DoctorDashboard } from './StatisticsDashboard/DoctorDashboard';
import { NurseDashboard } from './StatisticsDashboard/NurseDashboard';
import { AdminDashboard } from './StatisticsDashboard/AdminDashboard';
import { OperatorDashboard } from './StatisticsDashboard/OperatorDashboard';

const DASHBOARD_MAP: Record<string, React.FC> = {
  doctor: DoctorDashboard,
  health_manager: NurseDashboard,
  nurse: NurseDashboard,
  admin: AdminDashboard,
  operator: OperatorDashboard,
};

export default function StatisticsDashboard() {
  const { hasPermission } = usePermission('health.dashboard.manage');
  const role = useDashboardRole();

  if (!hasPermission) {
    return <Result status="403" title="权限不足" subTitle="您没有访问统计面板的权限" />;
  }

  const DashboardComponent = DASHBOARD_MAP[role];
  return <DashboardComponent />;
}
