From efc63ca398a1bafca864bc84dbf35fdeed4192e6 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Thu, 22 Oct 2026 15:58:22 +0200 Subject: [PATCH] Fixed error with compliance page --- .../projects/ProjectComplianceModal.tsx | 56 +++++++------------ .../src/pages/ExecutiveDashboard.tsx | 28 +++++----- PostFundManagement.ConsoleUI/src/types.ts | 3 + 3 files changed, 38 insertions(+), 49 deletions(-) diff --git a/PostFundManagement.ConsoleUI/src/components/projects/ProjectComplianceModal.tsx b/PostFundManagement.ConsoleUI/src/components/projects/ProjectComplianceModal.tsx index cf846fd..19fdefc 100644 --- a/PostFundManagement.ConsoleUI/src/components/projects/ProjectComplianceModal.tsx +++ b/PostFundManagement.ConsoleUI/src/components/projects/ProjectComplianceModal.tsx @@ -5,22 +5,15 @@ import { ShieldAlert, AlertTriangle, Users, - CheckCircle2, - TrendingUp, Target, - Clock, Coins, - AlertCircle, - Sparkles, + CheckCircle2, } from 'lucide-react'; import { Modal } from '../ui/Modal'; -import { HelpTooltip } from '../ui/HelpTooltip'; import { ComplianceStatusBadge } from '../ui/StatusBadge'; import { Project, Programme, - ComplianceItem, - Beneficiary, Outcome, ComplianceStatus, ApprovalStatus, @@ -38,8 +31,6 @@ import { formatDate, formatZAR, getRiskScoreColor, - getIndustrySectorLabel, - getProjectTypeLabel, } from '../../lib/formatters'; interface ProjectComplianceModalProps { @@ -94,8 +85,6 @@ export const ProjectComplianceModal: React.FC = ({ enabled: isOpen && !!projectId, }); -// Beneficiaries already filtered by project - // Beneficiary outcomes query const { data: outcomes = [], isLoading: loadingOutcomes } = useQuery({ queryKey: ['beneficiaryOutcomes', projectBeneficiaries.map((b) => b.id)], @@ -283,7 +272,9 @@ export const ProjectComplianceModal: React.FC = ({ ({risks.filter((r) => (Number(r.likelihood) || 1) * (Number(r.impact) || 1) >= 12).length} High) - ISO 31000 risk register + + Milestones: {milestoneProgress}% + @@ -326,14 +317,14 @@ export const ProjectComplianceModal: React.FC = ({ ); return ( - {ci.title} + {ci.title || 'Untitled Item'} {ci.requirements || 'N/A'} {linkedBen ? ( - {linkedBen.name} + {linkedBen.name || 'Beneficiary'} ) : ( Project-Wide @@ -386,18 +377,18 @@ export const ProjectComplianceModal: React.FC = ({ >
- {b.name} + {b.name || 'Beneficiary Group'} - {b.category} • {b.location} + {b.category || 'General'}{b.location ? ` • ${b.location}` : ''}
- Target: {b.targetCount} + Target: {b.targetCount ?? 0} • - Reached: {b.reachedCount} + Reached: {b.reachedCount ?? 0}
@@ -417,8 +408,8 @@ export const ProjectComplianceModal: React.FC = ({ className="p-2.5 rounded-lg bg-slate-950/60 border border-slate-800/80 flex items-start justify-between gap-2" >
- {o.name} - {o.description} + {o.name || 'Outcome'} + {o.description || 'No description'}
@@ -456,8 +447,8 @@ export const ProjectComplianceModal: React.FC = ({ - - + + @@ -465,25 +456,20 @@ export const ProjectComplianceModal: React.FC = ({ {risks.map((r) => { const score = (Number(r.likelihood) || 1) * (Number(r.impact) || 1); + const scoreColor = getRiskScoreColor(r.likelihood, r.impact); return ( - - + + - ); diff --git a/PostFundManagement.ConsoleUI/src/pages/ExecutiveDashboard.tsx b/PostFundManagement.ConsoleUI/src/pages/ExecutiveDashboard.tsx index 2792cc4..5760f5d 100644 --- a/PostFundManagement.ConsoleUI/src/pages/ExecutiveDashboard.tsx +++ b/PostFundManagement.ConsoleUI/src/pages/ExecutiveDashboard.tsx @@ -114,6 +114,20 @@ export const ExecutiveDashboard: React.FC = () => { queryFn: () => getAllIndicators(), }); + // Filtered projects according to active Programme and Sector dropdown selections + const filteredProjects = useMemo(() => { + return projects.filter((p) => { + if (selectedProgramme !== 'All' && String(p.programmeId) !== selectedProgramme) { + return false; + } + if (selectedSector !== 'All') { + const sectorLabel = getIndustrySectorLabel(p.sector); + if (sectorLabel !== selectedSector) return false; + } + return true; + }); + }, [projects, selectedProgramme, selectedSector]); + const { data: projectComplianceMap = new Map() } = useQuery({ queryKey: ['projectComplianceMap', filteredProjects.map((p) => p.id)], queryFn: async () => { @@ -138,20 +152,6 @@ export const ExecutiveDashboard: React.FC = () => { queryClient.invalidateQueries(); }; - // Filtered projects according to active Programme and Sector dropdown selections - const filteredProjects = useMemo(() => { - return projects.filter((p) => { - if (selectedProgramme !== 'All' && String(p.programmeId) !== selectedProgramme) { - return false; - } - if (selectedSector !== 'All') { - const sectorLabel = getIndustrySectorLabel(p.sector); - if (sectorLabel !== selectedSector) return false; - } - return true; - }); - }, [projects, selectedProgramme, selectedSector]); - // Filtered risks associated with the filtered project set const filteredRisks = useMemo(() => { if (selectedProgramme === 'All' && selectedSector === 'All') { diff --git a/PostFundManagement.ConsoleUI/src/types.ts b/PostFundManagement.ConsoleUI/src/types.ts index f5a711b..9025436 100644 --- a/PostFundManagement.ConsoleUI/src/types.ts +++ b/PostFundManagement.ConsoleUI/src/types.ts @@ -782,7 +782,10 @@ export interface Risk { createdAt: string; owner?: string; mitigationAction?: string; + mitigation?: string | null; status?: string; + category?: string | null; + title?: string | null; } export interface CreateRiskRequest {
Risk TitleCategoryRisk NameCategory / Status Score Mitigation Strategy
{r.title}{r.category || 'Operational'}{r.name || r.title || 'Unnamed Risk'}{r.category || r.status || 'Operational'} = 12 - ? 'bg-rose-500/20 text-rose-300 border border-rose-500/30' - : score >= 8 - ? 'bg-amber-500/20 text-amber-300 border border-amber-500/30' - : 'bg-emerald-500/20 text-emerald-300 border border-emerald-500/30' - }`} + className={`px-2 py-0.5 rounded text-[10px] font-bold ${scoreColor.badge}`} > - Score: {score} + {scoreColor.level} ({score}) - {r.mitigation || 'No mitigation recorded'} + + {r.mitigationAction || r.mitigation || r.description || 'No mitigation recorded'}