import type { ModuleId } from '@/shared/types/app';
import type { DirectorRiskArea } from '@/business/director-dashboard/types';
import { Button } from '@/components/ui/button';
import {
  directorNavigateIcon,
  directorRiskIcon,
  directorRiskSeverityClasses,
} from '@/components/director-dashboard/directorDashboardViewConfig';

interface DirectorRiskListProps {
  readonly risks: readonly DirectorRiskArea[];
  readonly onOpenModule: (module: ModuleId) => void;
}

export function DirectorRiskList({
  risks,
  onOpenModule,
}: DirectorRiskListProps) {
  const RiskIcon = directorRiskIcon;
  const NavigateIcon = directorNavigateIcon;

  return (
    <div className="bg-white rounded-2xl border border-violet-100 shadow-sm p-5">
      <h3 className="font-semibold text-gray-800 mb-4 flex items-center gap-2">
        <RiskIcon size={18} className="text-amber-500" />
        Risk Areas
      </h3>
      <div className="space-y-3">
        {risks.map((risk) => (
          <Button
            key={`${risk.module}-${risk.issue}`}
            type="button"
            onClick={() => onOpenModule(risk.module)}
            className={`w-full h-auto text-left p-4 rounded-xl border ${directorRiskSeverityClasses[risk.severity]} flex items-center justify-between hover:shadow-sm transition-all`}
          >
            <div className="flex items-center gap-3">
              <span className={`px-2 py-1 rounded-lg text-[10px] font-bold uppercase ${directorRiskSeverityClasses[risk.severity]}`}>
                {risk.severity}
              </span>
              <p className="text-sm font-medium text-gray-700">{risk.issue}</p>
            </div>
            <NavigateIcon size={14} className="text-gray-400" />
          </Button>
        ))}
      </div>
    </div>
  );
}
