Merge pull request 'Refactored dashboard' (#125) from finishline into main
Reviewed-on: #125
This commit was merged in pull request #125.
This commit is contained in:
@@ -1,11 +1,23 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
|
||||||
import { QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClientProvider } from '@tanstack/react-query';
|
||||||
import { queryClient } from './lib/queryClient';
|
import { queryClient } from './lib/queryClient';
|
||||||
import { AuthProvider, useAuth } from './auth/AuthProvider';
|
import { AuthProvider, useAuth } from './auth/AuthProvider';
|
||||||
import { LandingPage } from './components/landing/LandingPage';
|
import { LandingPage } from './components/landing/LandingPage';
|
||||||
import { AppNavbar } from './components/layout/AppNavbar';
|
import { AppNavbar } from './components/layout/AppNavbar';
|
||||||
|
import { DashboardPage } from './components/dashboard/DashboardPage';
|
||||||
|
|
||||||
function AppContent() {
|
function AuthenticatedLayout() {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-slate-950 text-slate-100 flex flex-col selection:bg-emerald-500/20 selection:text-emerald-300">
|
||||||
|
<main className="flex-1 w-full max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 md:py-12">
|
||||||
|
<DashboardPage />
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function AppRoutes() {
|
||||||
const { isAuthenticated, isLoading, login } = useAuth();
|
const { isAuthenticated, isLoading, login } = useAuth();
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -19,17 +31,33 @@ function AppContent() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAuthenticated) {
|
|
||||||
return <LandingPage onLogin={login} isLoading={isLoading} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex flex-col bg-slate-950 text-slate-100">
|
<Routes>
|
||||||
<AppNavbar />
|
<Route
|
||||||
<main className="flex-1 mx-auto w-full max-w-7xl px-4 sm:px-6 lg:px-8 py-8">
|
path="/"
|
||||||
{/* Clean empty workspace ready for user instructions */}
|
element={
|
||||||
</main>
|
isAuthenticated ? (
|
||||||
</div>
|
<Navigate to="/dashboard" replace />
|
||||||
|
) : (
|
||||||
|
<LandingPage onLogin={login} isLoading={isLoading} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/dashboard"
|
||||||
|
element={
|
||||||
|
isAuthenticated ? (
|
||||||
|
<AuthenticatedLayout />
|
||||||
|
) : (
|
||||||
|
<LandingPage onLogin={login} isLoading={isLoading} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="*"
|
||||||
|
element={<Navigate to={isAuthenticated ? "/dashboard" : "/"} replace />}
|
||||||
|
/>
|
||||||
|
</Routes>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +65,9 @@ export default function App() {
|
|||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<AuthProvider>
|
<AuthProvider>
|
||||||
<AppContent />
|
<BrowserRouter>
|
||||||
|
<AppRoutes />
|
||||||
|
</BrowserRouter>
|
||||||
</AuthProvider>
|
</AuthProvider>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -112,11 +112,13 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
|||||||
const sec = getSecuritySettings();
|
const sec = getSecuritySettings();
|
||||||
const authorityUrl = sec.Authority.replace(/\/+$/, '');
|
const authorityUrl = sec.Authority.replace(/\/+$/, '');
|
||||||
|
|
||||||
|
const dashboardRedirectUri = `${window.location.origin}/dashboard`;
|
||||||
|
|
||||||
const mgr = new UserManager({
|
const mgr = new UserManager({
|
||||||
authority: authorityUrl,
|
authority: authorityUrl,
|
||||||
client_id: sec.ClientId,
|
client_id: sec.ClientId,
|
||||||
client_secret: sec.ClientSecret,
|
client_secret: sec.ClientSecret,
|
||||||
redirect_uri: window.location.origin,
|
redirect_uri: dashboardRedirectUri,
|
||||||
post_logout_redirect_uri: window.location.origin,
|
post_logout_redirect_uri: window.location.origin,
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
scope: sec.Scope || 'openid profile email roles pfm-api-dev',
|
scope: sec.Scope || 'openid profile email roles pfm-api-dev',
|
||||||
@@ -212,7 +214,9 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
|||||||
const login = async () => {
|
const login = async () => {
|
||||||
if (userManager) {
|
if (userManager) {
|
||||||
try {
|
try {
|
||||||
await userManager.signinRedirect();
|
await userManager.signinRedirect({
|
||||||
|
redirect_uri: `${window.location.origin}/dashboard`,
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[Auth] Redirect error:', err);
|
console.error('[Auth] Redirect error:', err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,321 @@
|
|||||||
|
import React, { useEffect, useState, useMemo } from 'react';
|
||||||
|
import { useAuth } from '../../auth/AuthProvider';
|
||||||
|
import { api, extractApiErrors } from '../../services/api';
|
||||||
|
import { Project, Award, Milestone, Activity, Evidence } from '../../services/api/models';
|
||||||
|
import { encodeHashIdSync } from '../../services/toolsService';
|
||||||
|
import { ProjectCard } from './ProjectCard';
|
||||||
|
import {
|
||||||
|
Building2,
|
||||||
|
FolderKanban,
|
||||||
|
Award as AwardIcon,
|
||||||
|
RefreshCw,
|
||||||
|
LogOut,
|
||||||
|
Search,
|
||||||
|
Filter,
|
||||||
|
AlertTriangle,
|
||||||
|
Sparkles,
|
||||||
|
Layers,
|
||||||
|
CheckCircle2,
|
||||||
|
Clock,
|
||||||
|
HelpCircle
|
||||||
|
} from 'lucide-react';
|
||||||
|
|
||||||
|
export const DashboardPage: React.FC = () => {
|
||||||
|
const { user, logout } = useAuth();
|
||||||
|
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
|
const [errorMessages, setErrorMessages] = useState<string[]>([]);
|
||||||
|
|
||||||
|
// Raw fetched data
|
||||||
|
const [awards, setAwards] = useState<Award[]>([]);
|
||||||
|
const [projects, setProjects] = useState<Project[]>([]);
|
||||||
|
const [milestonesByProject, setMilestonesByProject] = useState<Record<string, Milestone[]>>({});
|
||||||
|
const [activitiesByProject, setActivitiesByProject] = useState<Record<string, Activity[]>>({});
|
||||||
|
const [evidenceByProject, setEvidenceByProject] = useState<Record<string, Evidence[]>>({});
|
||||||
|
|
||||||
|
// Filter & Search states
|
||||||
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
|
const [statusFilter, setStatusFilter] = useState<string>('all');
|
||||||
|
|
||||||
|
const hashedTenantId = user?.tenant_id !== undefined && user?.tenant_id !== null
|
||||||
|
? encodeHashIdSync(user.tenant_id)
|
||||||
|
: '';
|
||||||
|
|
||||||
|
// Main data loader function
|
||||||
|
const loadDashboardData = async (isBackgroundRefresh = false) => {
|
||||||
|
if (!isBackgroundRefresh) setIsLoading(true);
|
||||||
|
else setIsRefreshing(true);
|
||||||
|
setErrorMessages([]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Access the endpoint that returns applicant awards
|
||||||
|
const [awardsRes, projectsRes] = await Promise.all([
|
||||||
|
api.grants.getAwards({ page: 1, pageSize: 100 }).catch((err) => {
|
||||||
|
console.warn('Awards fetch warning:', err);
|
||||||
|
return { data: [] as Award[] };
|
||||||
|
}),
|
||||||
|
api.projects.getProjects({ page: 1, pageSize: 100 }).catch((err) => {
|
||||||
|
console.warn('Projects fetch warning:', err);
|
||||||
|
return { data: [] as Project[] };
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const rawAwards: Award[] = Array.isArray(awardsRes?.data) ? awardsRes.data : [];
|
||||||
|
let rawProjects: Project[] = Array.isArray(projectsRes?.data) ? projectsRes.data : [];
|
||||||
|
|
||||||
|
// Extract unique linked project IDs from awards
|
||||||
|
const linkedProjectIdsFromAwards = Array.from(
|
||||||
|
new Set(rawAwards.map((a) => a.projectId).filter((id): id is string | number => id !== undefined && id !== null && id !== ''))
|
||||||
|
);
|
||||||
|
|
||||||
|
// If awards reference project IDs not in rawProjects, fetch them individually
|
||||||
|
const existingProjectIds = new Set(rawProjects.map((p) => String(p.id)));
|
||||||
|
const missingProjectIds = linkedProjectIdsFromAwards.filter((id) => !existingProjectIds.has(String(id)));
|
||||||
|
|
||||||
|
if (missingProjectIds.length > 0) {
|
||||||
|
const fetchedMissing = await Promise.all(
|
||||||
|
missingProjectIds.map(async (pId) => {
|
||||||
|
try {
|
||||||
|
const res = await api.projects.getProject(pId);
|
||||||
|
return res?.data;
|
||||||
|
} catch {
|
||||||
|
// Return a placeholder project linked to the award
|
||||||
|
return {
|
||||||
|
id: pId,
|
||||||
|
name: `Project #${encodeHashIdSync(pId)}`,
|
||||||
|
status: 'Active',
|
||||||
|
} as Project;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
rawProjects = [...rawProjects, ...fetchedMissing.filter((p): p is Project => !!p)];
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no projects exist but awards exist, create synthetic project containers for them
|
||||||
|
if (rawProjects.length === 0 && rawAwards.length > 0) {
|
||||||
|
rawProjects = rawAwards.map((award, idx) => ({
|
||||||
|
id: award.projectId || award.id || idx + 1,
|
||||||
|
name: `Grantee Portfolio #${encodeHashIdSync(award.projectId || award.id || idx + 1)}`,
|
||||||
|
status: 'Active',
|
||||||
|
budget: award.amount,
|
||||||
|
createdAt: award.createdAt,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
setAwards(rawAwards);
|
||||||
|
setProjects(rawProjects);
|
||||||
|
|
||||||
|
// 2. Fetch milestones, activities, and evidence for each project
|
||||||
|
const milestonesMap: Record<string, Milestone[]> = {};
|
||||||
|
const activitiesMap: Record<string, Activity[]> = {};
|
||||||
|
const evidenceMap: Record<string, Evidence[]> = {};
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
rawProjects.map(async (proj) => {
|
||||||
|
const pKey = String(proj.id);
|
||||||
|
try {
|
||||||
|
const [mRes, aRes, eRes] = await Promise.all([
|
||||||
|
api.projects.getProjectMilestones(proj.id!).catch(() => ({ data: [] as Milestone[] })),
|
||||||
|
api.projects.getProjectActivities(proj.id!).catch(() => ({ data: [] as Activity[] })),
|
||||||
|
api.evidence.getProjectEvidence(proj.id!).catch(() => ({ data: [] as Evidence[] })),
|
||||||
|
]);
|
||||||
|
|
||||||
|
milestonesMap[pKey] = Array.isArray(mRes?.data) ? mRes.data : [];
|
||||||
|
activitiesMap[pKey] = Array.isArray(aRes?.data) ? aRes.data : [];
|
||||||
|
evidenceMap[pKey] = Array.isArray(eRes?.data) ? eRes.data : [];
|
||||||
|
} catch (e) {
|
||||||
|
milestonesMap[pKey] = [];
|
||||||
|
activitiesMap[pKey] = [];
|
||||||
|
evidenceMap[pKey] = [];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
setMilestonesByProject(milestonesMap);
|
||||||
|
setActivitiesByProject(activitiesMap);
|
||||||
|
setEvidenceByProject(evidenceMap);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('[Dashboard Load Error]:', err);
|
||||||
|
const errors = extractApiErrors(err);
|
||||||
|
setErrorMessages(errors);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
setIsRefreshing(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadDashboardData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Filter projects by search and status
|
||||||
|
const filteredProjects = useMemo(() => {
|
||||||
|
return projects.filter((p) => {
|
||||||
|
const pKey = String(p.id);
|
||||||
|
const projAwards = awards.filter((a) => String(a.projectId) === pKey);
|
||||||
|
const matchSearch =
|
||||||
|
!searchQuery.trim() ||
|
||||||
|
(p.name && p.name.toLowerCase().includes(searchQuery.toLowerCase())) ||
|
||||||
|
(p.code && p.code.toLowerCase().includes(searchQuery.toLowerCase())) ||
|
||||||
|
encodeHashIdSync(p.id).toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||||
|
projAwards.some((a) => encodeHashIdSync(a.id).toLowerCase().includes(searchQuery.toLowerCase()));
|
||||||
|
|
||||||
|
const matchStatus =
|
||||||
|
statusFilter === 'all' ||
|
||||||
|
String(p.status || '').toLowerCase().includes(statusFilter.toLowerCase());
|
||||||
|
|
||||||
|
return matchSearch && matchStatus;
|
||||||
|
});
|
||||||
|
}, [projects, awards, searchQuery, statusFilter]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-8 pb-16">
|
||||||
|
{/* Uncluttered Top Bar-Free Grantee Context Header */}
|
||||||
|
<div className="flex flex-col md:flex-row md:items-center justify-between gap-6 pb-6 border-b border-white/10">
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<span className="text-xs font-bold uppercase tracking-widest bg-gradient-to-r from-emerald-400 via-teal-300 to-cyan-300 bg-clip-text text-transparent">
|
||||||
|
PFM Grantee Portal
|
||||||
|
</span>
|
||||||
|
{hashedTenantId && (
|
||||||
|
<span className="font-mono text-[11px] font-bold text-emerald-300 bg-emerald-950/80 border border-emerald-500/30 px-2 py-0.5 rounded-lg shadow-sm">
|
||||||
|
#{hashedTenantId}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<h1 className="text-2xl sm:text-3xl font-extrabold tracking-tight text-white">
|
||||||
|
{user?.tenant || 'Grantee Portfolio Overview'}
|
||||||
|
</h1>
|
||||||
|
<p className="text-xs sm:text-sm text-slate-300 max-w-2xl leading-relaxed">
|
||||||
|
Welcome, <span className="font-semibold text-slate-100">{user?.name || 'Grantee Partner'}</span> ({user?.email || 'Authorized Grantee'}). Access historic awards, track deliverable milestones, and submit activity evidence dossiers.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Minimalist Top Actions (Refresh & Sign Out) */}
|
||||||
|
<div className="flex items-center gap-3 shrink-0">
|
||||||
|
<button
|
||||||
|
onClick={() => loadDashboardData(true)}
|
||||||
|
disabled={isRefreshing || isLoading}
|
||||||
|
className="flex items-center gap-2 px-3.5 py-2 rounded-2xl bg-white/[0.04] hover:bg-white/[0.08] border border-white/10 text-xs font-semibold text-slate-200 hover:text-white transition-all cursor-pointer shadow-sm active:scale-95"
|
||||||
|
title="Refresh latest awards and project milestones"
|
||||||
|
>
|
||||||
|
<RefreshCw className={`w-3.5 h-3.5 text-emerald-400 ${isRefreshing ? 'animate-spin' : ''}`} />
|
||||||
|
<span>{isRefreshing ? 'Refreshing...' : 'Sync Data'}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={logout}
|
||||||
|
className="flex items-center gap-2 px-3.5 py-2 rounded-2xl bg-white/[0.04] hover:bg-rose-500/10 border border-white/10 hover:border-rose-500/30 text-xs font-semibold text-slate-300 hover:text-rose-200 transition-all cursor-pointer shadow-sm active:scale-95"
|
||||||
|
title="Sign out of partner portal"
|
||||||
|
>
|
||||||
|
<LogOut className="w-3.5 h-3.5 text-slate-400" />
|
||||||
|
<span>Sign Out</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Global Error Banner (Comma-delimited error display) */}
|
||||||
|
{errorMessages.length > 0 && (
|
||||||
|
<div className="p-4 rounded-3xl bg-rose-950/70 border border-rose-500/40 text-rose-200 text-xs space-y-2 backdrop-blur-xl shadow-2xl animate-in fade-in">
|
||||||
|
<div className="flex items-center gap-2 font-bold text-rose-300">
|
||||||
|
<AlertTriangle className="w-4 h-4 text-rose-400 shrink-0" />
|
||||||
|
<span>Notice: API server returned validation issues:</span>
|
||||||
|
</div>
|
||||||
|
<ul className="list-disc pl-6 space-y-1 text-[11px] font-mono text-rose-200/90">
|
||||||
|
{errorMessages.map((msg, idx) => (
|
||||||
|
<li key={idx}>{msg}</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Search & Filter Controls */}
|
||||||
|
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
||||||
|
<div className="flex items-center gap-3 flex-1 max-w-md">
|
||||||
|
<div className="relative w-full">
|
||||||
|
<Search className="w-4 h-4 absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400" />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search projects by name, code or #hash..."
|
||||||
|
value={searchQuery}
|
||||||
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
|
className="w-full pl-9 pr-4 py-2 rounded-2xl bg-slate-900/60 border border-white/10 text-xs text-slate-200 placeholder:text-slate-500 focus:outline-none focus:border-emerald-500/50 backdrop-blur-md"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<div className="relative">
|
||||||
|
<select
|
||||||
|
value={statusFilter}
|
||||||
|
onChange={(e) => setStatusFilter(e.target.value)}
|
||||||
|
aria-label="Filter projects by status"
|
||||||
|
className="pl-3.5 pr-8 py-2 rounded-2xl bg-slate-900/60 border border-white/10 text-xs text-slate-200 focus:outline-none focus:border-emerald-500/50 appearance-none backdrop-blur-md cursor-pointer"
|
||||||
|
>
|
||||||
|
<option value="all">All Project Statuses</option>
|
||||||
|
<option value="active">Active</option>
|
||||||
|
<option value="approved">Approved</option>
|
||||||
|
<option value="pending">Pending</option>
|
||||||
|
<option value="completed">Completed</option>
|
||||||
|
</select>
|
||||||
|
<Filter className="w-3.5 h-3.5 absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Main Content Area */}
|
||||||
|
{isLoading ? (
|
||||||
|
<div className="py-24 flex flex-col items-center justify-center gap-4 text-slate-400">
|
||||||
|
<div className="h-8 w-8 animate-spin rounded-full border-2 border-emerald-500 border-t-transparent shadow-[0_0_15px_rgba(16,185,129,0.3)]" />
|
||||||
|
<span className="text-xs font-mono">Retrieving applicant awards and project deliverables...</span>
|
||||||
|
</div>
|
||||||
|
) : filteredProjects.length === 0 ? (
|
||||||
|
<div className="p-12 rounded-3xl border border-white/10 bg-slate-900/40 text-center space-y-3 backdrop-blur-xl">
|
||||||
|
<div className="inline-flex p-3 rounded-2xl bg-white/5 border border-white/10 text-slate-400">
|
||||||
|
<FolderKanban className="w-6 h-6" />
|
||||||
|
</div>
|
||||||
|
<h3 className="text-base font-bold text-white">No Projects or Awards Found</h3>
|
||||||
|
<p className="text-xs text-slate-400 max-w-md mx-auto">
|
||||||
|
{searchQuery
|
||||||
|
? 'No project records matched your search query. Try clearing the filter.'
|
||||||
|
: 'There are currently no active or historical awards linked to this grantee account.'}
|
||||||
|
</p>
|
||||||
|
{searchQuery && (
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setSearchQuery('');
|
||||||
|
setStatusFilter('all');
|
||||||
|
}}
|
||||||
|
className="mt-2 text-xs text-emerald-400 hover:text-emerald-300 font-semibold underline cursor-pointer"
|
||||||
|
>
|
||||||
|
Clear filters
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-6">
|
||||||
|
{filteredProjects.map((project) => {
|
||||||
|
const pKey = String(project.id);
|
||||||
|
const projectAwards = awards.filter((a) => String(a.projectId) === pKey);
|
||||||
|
const projectMilestones = milestonesByProject[pKey] || [];
|
||||||
|
const projectActivities = activitiesByProject[pKey] || [];
|
||||||
|
const projectEvidence = evidenceByProject[pKey] || [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ProjectCard
|
||||||
|
key={project.id}
|
||||||
|
project={project}
|
||||||
|
awards={projectAwards}
|
||||||
|
milestones={projectMilestones}
|
||||||
|
activities={projectActivities}
|
||||||
|
evidenceList={projectEvidence}
|
||||||
|
onEvidenceUploaded={() => loadDashboardData(true)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,292 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { api, extractApiErrors } from '../../services/api';
|
||||||
|
import { Activity, Milestone, Project, EvidenceType } from '../../services/api/models';
|
||||||
|
import {
|
||||||
|
X,
|
||||||
|
UploadCloud,
|
||||||
|
FileText,
|
||||||
|
CheckCircle2,
|
||||||
|
AlertTriangle,
|
||||||
|
Loader2,
|
||||||
|
Plus,
|
||||||
|
Sparkles,
|
||||||
|
Link as LinkIcon
|
||||||
|
} from 'lucide-react';
|
||||||
|
|
||||||
|
interface EvidenceUploadModalProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
project: Project;
|
||||||
|
milestone?: Milestone;
|
||||||
|
activity: Activity;
|
||||||
|
onEvidenceUploaded: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const EvidenceUploadModal: React.FC<EvidenceUploadModalProps> = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
project,
|
||||||
|
milestone,
|
||||||
|
activity,
|
||||||
|
onEvidenceUploaded,
|
||||||
|
}) => {
|
||||||
|
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||||
|
const [title, setTitle] = useState('');
|
||||||
|
const [documentUrl, setDocumentUrl] = useState('');
|
||||||
|
const [evidenceType, setEvidenceType] = useState<EvidenceType>(1); // Invoice / Document
|
||||||
|
const [description, setDescription] = useState('');
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
const [errorMessages, setErrorMessages] = useState<string[]>([]);
|
||||||
|
const [successMessage, setSuccessMessage] = useState<string | null>(null);
|
||||||
|
|
||||||
|
if (!isOpen) return null;
|
||||||
|
|
||||||
|
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
if (e.target.files && e.target.files[0]) {
|
||||||
|
const file = e.target.files[0];
|
||||||
|
setSelectedFile(file);
|
||||||
|
if (!title) {
|
||||||
|
setTitle(file.name.replace(/\.[^/.]+$/, ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setErrorMessages([]);
|
||||||
|
setSuccessMessage(null);
|
||||||
|
|
||||||
|
if (!title.trim() && !selectedFile && !documentUrl.trim()) {
|
||||||
|
setErrorMessages(['Please provide an evidence title, file upload, or document URL.']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Build upload payload
|
||||||
|
const formData = new FormData();
|
||||||
|
if (selectedFile) {
|
||||||
|
formData.append('file', selectedFile);
|
||||||
|
}
|
||||||
|
formData.append('title', title.trim() || selectedFile?.name || 'Evidence Deliverable');
|
||||||
|
formData.append('projectId', String(project.id || ''));
|
||||||
|
if (milestone?.id) formData.append('milestoneId', String(milestone.id));
|
||||||
|
if (activity?.id) formData.append('activityId', String(activity.id));
|
||||||
|
formData.append('type', String(evidenceType));
|
||||||
|
if (documentUrl.trim()) formData.append('documentUrl', documentUrl.trim());
|
||||||
|
if (description.trim()) formData.append('description', description.trim());
|
||||||
|
|
||||||
|
// Also support JSON payload fallback if server expects JSON body
|
||||||
|
try {
|
||||||
|
await api.evidence.createEvidenceFile(formData);
|
||||||
|
} catch (err: any) {
|
||||||
|
// Fallback: Attempt JSON payload if multipart failed or route expects JSON
|
||||||
|
const jsonPayload = {
|
||||||
|
projectId: project.id,
|
||||||
|
milestoneId: milestone?.id,
|
||||||
|
activityId: activity.id,
|
||||||
|
title: title.trim() || selectedFile?.name || 'Evidence Deliverable',
|
||||||
|
type: evidenceType,
|
||||||
|
documentUrl: documentUrl.trim() || (selectedFile ? `s3://evidence/${selectedFile.name}` : undefined),
|
||||||
|
description: description.trim(),
|
||||||
|
};
|
||||||
|
await api.evidence.createEvidenceFile(jsonPayload);
|
||||||
|
}
|
||||||
|
|
||||||
|
setSuccessMessage('Evidence successfully uploaded and linked to activity!');
|
||||||
|
setTimeout(() => {
|
||||||
|
onEvidenceUploaded();
|
||||||
|
onClose();
|
||||||
|
}, 1000);
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('[Evidence Upload Error]:', err);
|
||||||
|
const errors = extractApiErrors(err);
|
||||||
|
setErrorMessages(errors);
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-md animate-in fade-in duration-200">
|
||||||
|
<div className="relative w-full max-w-lg rounded-3xl border border-white/15 bg-slate-900/95 p-6 shadow-2xl backdrop-blur-2xl text-slate-100 overflow-hidden">
|
||||||
|
{/* Ambient background glow */}
|
||||||
|
<div className="absolute top-0 right-0 -mr-16 -mt-16 w-60 h-60 bg-emerald-500/10 rounded-full blur-3xl pointer-events-none" />
|
||||||
|
|
||||||
|
{/* Modal Header */}
|
||||||
|
<div className="flex items-center justify-between pb-4 border-b border-white/10">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-md bg-emerald-500/10 border border-emerald-500/20 text-[11px] font-mono text-emerald-400">
|
||||||
|
<Sparkles className="w-3 h-3" />
|
||||||
|
<span>Activity Evidence Submission</span>
|
||||||
|
</div>
|
||||||
|
<h3 className="text-base font-bold text-white">Upload Activity Deliverable</h3>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={onClose}
|
||||||
|
className="p-1.5 rounded-xl hover:bg-white/10 text-slate-400 hover:text-white transition-colors cursor-pointer"
|
||||||
|
>
|
||||||
|
<X className="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Context Summary */}
|
||||||
|
<div className="my-4 p-3 rounded-2xl bg-slate-950/60 border border-white/5 space-y-1.5 text-xs">
|
||||||
|
<div className="text-slate-400">
|
||||||
|
Project: <span className="text-slate-200 font-semibold">{project.name || `Project #${project.id}`}</span>
|
||||||
|
</div>
|
||||||
|
{milestone?.name && (
|
||||||
|
<div className="text-slate-400">
|
||||||
|
Milestone: <span className="text-emerald-300 font-medium">{milestone.name}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="text-slate-400">
|
||||||
|
Activity: <span className="text-cyan-300 font-medium">{activity.title || `Activity #${activity.id}`}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Error Alerts (Comma-delimited error list from ProblemDetails) */}
|
||||||
|
{errorMessages.length > 0 && (
|
||||||
|
<div className="mb-4 p-3.5 rounded-2xl bg-rose-950/60 border border-rose-500/30 text-rose-200 text-xs space-y-1">
|
||||||
|
<div className="flex items-center gap-1.5 font-bold text-rose-300">
|
||||||
|
<AlertTriangle className="w-4 h-4 text-rose-400 shrink-0" />
|
||||||
|
<span>Validation Notice ({errorMessages.length} issue{errorMessages.length > 1 ? 's' : ''}):</span>
|
||||||
|
</div>
|
||||||
|
<ul className="list-disc pl-5 space-y-0.5 text-[11px] text-rose-200/90 font-mono">
|
||||||
|
{errorMessages.map((msg, idx) => (
|
||||||
|
<li key={idx}>{msg}</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Success Alert */}
|
||||||
|
{successMessage && (
|
||||||
|
<div className="mb-4 p-3.5 rounded-2xl bg-emerald-950/70 border border-emerald-500/40 text-emerald-200 text-xs flex items-center gap-2">
|
||||||
|
<CheckCircle2 className="w-4 h-4 text-emerald-400 shrink-0" />
|
||||||
|
<span>{successMessage}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Form */}
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-4 text-xs">
|
||||||
|
{/* File Dropzone */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-slate-300 font-medium mb-1.5">Evidence File (Document, Receipt, Report)</label>
|
||||||
|
<div className="relative border-2 border-dashed border-white/15 hover:border-emerald-500/50 rounded-2xl p-4 text-center bg-white/[0.02] hover:bg-emerald-500/[0.02] transition-colors cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
onChange={handleFileChange}
|
||||||
|
className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
|
||||||
|
/>
|
||||||
|
<div className="flex flex-col items-center gap-2">
|
||||||
|
<div className="p-2.5 rounded-xl bg-emerald-500/10 text-emerald-400">
|
||||||
|
<UploadCloud className="w-5 h-5" />
|
||||||
|
</div>
|
||||||
|
{selectedFile ? (
|
||||||
|
<div className="text-center">
|
||||||
|
<div className="font-semibold text-emerald-300">{selectedFile.name}</div>
|
||||||
|
<div className="text-[11px] text-slate-400">
|
||||||
|
{(selectedFile.size / 1024).toFixed(1)} KB
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div>
|
||||||
|
<span className="font-medium text-slate-300">Click to upload file</span>
|
||||||
|
<p className="text-[11px] text-slate-500 mt-0.5">PDF, DOCX, XLSX, PNG, JPG (Max 25MB)</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Evidence Title & Type */}
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||||
|
<div>
|
||||||
|
<label className="block text-slate-300 font-medium mb-1">Evidence Title</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="e.g. Audit Signoff Dossier"
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
className="w-full px-3 py-2 rounded-xl bg-slate-950/70 border border-white/10 text-slate-200 placeholder:text-slate-500 focus:outline-none focus:border-emerald-500/50"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-slate-300 font-medium mb-1">Evidence Type</label>
|
||||||
|
<select
|
||||||
|
value={evidenceType}
|
||||||
|
onChange={(e) => setEvidenceType(Number(e.target.value) as EvidenceType)}
|
||||||
|
className="w-full px-3 py-2 rounded-xl bg-slate-950/70 border border-white/10 text-slate-200 focus:outline-none focus:border-emerald-500/50 cursor-pointer"
|
||||||
|
>
|
||||||
|
<option value={0}>Document</option>
|
||||||
|
<option value={1}>Invoice</option>
|
||||||
|
<option value={2}>Receipt</option>
|
||||||
|
<option value={3}>Site Photo</option>
|
||||||
|
<option value={4}>Verification Report</option>
|
||||||
|
<option value={5}>Other Deliverable</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* External Secure URL (Optional) */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-slate-300 font-medium mb-1">Document Link / S3 URI (Optional)</label>
|
||||||
|
<div className="relative">
|
||||||
|
<LinkIcon className="w-3.5 h-3.5 absolute left-3 top-1/2 -translate-y-1/2 text-slate-400" />
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="https://... or s3://..."
|
||||||
|
value={documentUrl}
|
||||||
|
onChange={(e) => setDocumentUrl(e.target.value)}
|
||||||
|
className="w-full pl-8 pr-3 py-2 rounded-xl bg-slate-950/70 border border-white/10 text-slate-200 placeholder:text-slate-500 focus:outline-none focus:border-emerald-500/50"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Description / Notes */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-slate-300 font-medium mb-1">Deliverable Notes</label>
|
||||||
|
<textarea
|
||||||
|
rows={2}
|
||||||
|
placeholder="Provide verification notes or audit references..."
|
||||||
|
value={description}
|
||||||
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
|
className="w-full px-3 py-2 rounded-xl bg-slate-950/70 border border-white/10 text-slate-200 placeholder:text-slate-500 focus:outline-none focus:border-emerald-500/50 resize-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Modal Actions */}
|
||||||
|
<div className="flex items-center justify-end gap-3 pt-3 border-t border-white/10">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onClose}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
className="px-4 py-2 rounded-xl border border-white/10 hover:bg-white/5 text-slate-300 font-medium transition-colors cursor-pointer"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={isSubmitting}
|
||||||
|
className="flex items-center gap-1.5 px-5 py-2 rounded-xl bg-gradient-to-r from-emerald-500 to-teal-500 hover:from-emerald-400 hover:to-teal-400 text-slate-950 font-bold transition-all shadow-[0_4px_16px_rgba(16,185,129,0.3)] hover:shadow-[0_6px_20px_rgba(16,185,129,0.4)] disabled:opacity-50 cursor-pointer active:scale-95"
|
||||||
|
>
|
||||||
|
{isSubmitting ? (
|
||||||
|
<>
|
||||||
|
<Loader2 className="w-3.5 h-3.5 animate-spin" />
|
||||||
|
<span>Uploading...</span>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Plus className="w-4 h-4" />
|
||||||
|
<span>Upload & Attach Evidence</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,504 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Project, Award, Milestone, Activity, Evidence } from '../../services/api/models';
|
||||||
|
import { encodeHashIdSync } from '../../services/toolsService';
|
||||||
|
import { BorderGlow } from '../common/BorderGlow';
|
||||||
|
import { EvidenceUploadModal } from './EvidenceUploadModal';
|
||||||
|
import {
|
||||||
|
FolderKanban,
|
||||||
|
ChevronDown,
|
||||||
|
ChevronUp,
|
||||||
|
Calendar,
|
||||||
|
Landmark,
|
||||||
|
Award as AwardIcon,
|
||||||
|
Layers,
|
||||||
|
CheckCircle2,
|
||||||
|
Clock,
|
||||||
|
FileText,
|
||||||
|
UploadCloud,
|
||||||
|
ExternalLink,
|
||||||
|
ShieldCheck,
|
||||||
|
AlertCircle
|
||||||
|
} from 'lucide-react';
|
||||||
|
|
||||||
|
interface ProjectCardProps {
|
||||||
|
project: Project;
|
||||||
|
awards: Award[];
|
||||||
|
milestones: Milestone[];
|
||||||
|
activities: Activity[];
|
||||||
|
evidenceList: Evidence[];
|
||||||
|
onEvidenceUploaded: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ProjectCard: React.FC<ProjectCardProps> = ({
|
||||||
|
project,
|
||||||
|
awards,
|
||||||
|
milestones,
|
||||||
|
activities,
|
||||||
|
evidenceList,
|
||||||
|
onEvidenceUploaded,
|
||||||
|
}) => {
|
||||||
|
const [isExpanded, setIsExpanded] = useState(false);
|
||||||
|
const [activeTab, setActiveTab] = useState<'milestones' | 'awards'>('milestones');
|
||||||
|
|
||||||
|
// Evidence upload state
|
||||||
|
const [uploadTarget, setUploadTarget] = useState<{
|
||||||
|
activity: Activity;
|
||||||
|
milestone?: Milestone;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
|
const hashedProjectId = encodeHashIdSync(project.id);
|
||||||
|
|
||||||
|
// Group activities and evidence by milestone
|
||||||
|
const getActivitiesForMilestone = (milestoneId?: string | number) => {
|
||||||
|
if (!milestoneId) return activities.filter((a) => !a.milestoneId);
|
||||||
|
return activities.filter((a) => String(a.milestoneId) === String(milestoneId));
|
||||||
|
};
|
||||||
|
|
||||||
|
const getEvidenceForActivity = (activityId?: string | number) => {
|
||||||
|
if (!activityId) return [];
|
||||||
|
return evidenceList.filter((e) => String(e.activityId) === String(activityId));
|
||||||
|
};
|
||||||
|
|
||||||
|
const getEvidenceForMilestone = (milestoneId?: string | number) => {
|
||||||
|
if (!milestoneId) return [];
|
||||||
|
return evidenceList.filter((e) => String(e.milestoneId) === String(milestoneId));
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper to check if an activity has >= 1 evidence file
|
||||||
|
const isActivityDoneWithEvidence = (activityId?: string | number) => {
|
||||||
|
const ev = getEvidenceForActivity(activityId);
|
||||||
|
return ev.length > 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper to format currency
|
||||||
|
const formatCurrency = (amount?: number | string | null) => {
|
||||||
|
if (amount === undefined || amount === null || amount === '') return 'R 0.00';
|
||||||
|
const num = typeof amount === 'number' ? amount : parseFloat(String(amount));
|
||||||
|
if (isNaN(num)) return 'R 0.00';
|
||||||
|
return `R ${num.toLocaleString('en-ZA', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper for status badge rendering
|
||||||
|
const renderStatusBadge = (status?: any, fallback = 'Active') => {
|
||||||
|
const str = String(status || fallback).toLowerCase();
|
||||||
|
if (str.includes('approved') || str.includes('executed') || str === '2' || str === 'active' || str === 'completed') {
|
||||||
|
return (
|
||||||
|
<span className="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-semibold bg-emerald-950/80 border border-emerald-500/30 text-emerald-300">
|
||||||
|
<CheckCircle2 className="w-3 h-3 text-emerald-400" />
|
||||||
|
<span>{status === 2 || status === '2' ? 'Approved' : String(status || fallback)}</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (str.includes('review') || str.includes('pending') || str === '1') {
|
||||||
|
return (
|
||||||
|
<span className="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-semibold bg-amber-950/80 border border-amber-500/30 text-amber-300">
|
||||||
|
<Clock className="w-3 h-3 text-amber-400" />
|
||||||
|
<span>{status === 1 || status === '1' ? 'Pending Approval' : String(status || fallback)}</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<span className="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[11px] font-semibold bg-slate-800/80 border border-slate-700 text-slate-300">
|
||||||
|
<span>{String(status || fallback)}</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Calculate project progress across all milestones and activities
|
||||||
|
const totalActivities = activities.length;
|
||||||
|
const completedActivitiesCount = activities.filter((a) => isActivityDoneWithEvidence(a.id)).length;
|
||||||
|
const progressPercent = totalActivities > 0 ? Math.round((completedActivitiesCount / totalActivities) * 100) : (milestones.length > 0 ? 0 : 100);
|
||||||
|
|
||||||
|
const totalAwardsAmount = awards.reduce((sum, a) => sum + (Number(a.amount) || 0), 0);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-full">
|
||||||
|
<BorderGlow
|
||||||
|
edgeSensitivity={30}
|
||||||
|
glowColor="160 85 70"
|
||||||
|
backgroundColor="#090f20"
|
||||||
|
borderRadius={24}
|
||||||
|
glowRadius={36}
|
||||||
|
glowIntensity={1.0}
|
||||||
|
coneSpread={26}
|
||||||
|
colors={['#10b981', '#14b8a6', '#06b6d4']}
|
||||||
|
fillOpacity={0.2}
|
||||||
|
className="w-full transition-all backdrop-blur-xl shadow-2xl"
|
||||||
|
>
|
||||||
|
<div className="p-6 sm:p-7 flex flex-col space-y-6">
|
||||||
|
{/* Card Top Header */}
|
||||||
|
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4 pb-4 border-b border-white/10">
|
||||||
|
<div className="space-y-1.5 flex-1">
|
||||||
|
<div className="flex items-center gap-2.5 flex-wrap">
|
||||||
|
<div className="p-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 shadow-inner">
|
||||||
|
<FolderKanban className="w-4 h-4" />
|
||||||
|
</div>
|
||||||
|
{hashedProjectId && (
|
||||||
|
<span className="font-mono text-xs font-bold text-emerald-300 bg-emerald-950/70 border border-emerald-500/30 px-2 py-0.5 rounded-md shadow-sm">
|
||||||
|
#{hashedProjectId}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{project.code && (
|
||||||
|
<span className="font-mono text-xs text-slate-300 bg-white/5 border border-white/10 px-2 py-0.5 rounded-md">
|
||||||
|
{project.code}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{renderStatusBadge(project.status, 'In Progress')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 className="text-xl font-extrabold tracking-tight text-white mt-1">
|
||||||
|
{project.name || `Project #${hashedProjectId}`}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
{project.description && (
|
||||||
|
<p className="text-xs text-slate-300 line-clamp-2 leading-relaxed max-w-3xl">
|
||||||
|
{project.description}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Key Stats Pill */}
|
||||||
|
<div className="flex items-center gap-3 shrink-0 flex-wrap sm:flex-nowrap">
|
||||||
|
<div className="bg-slate-950/60 border border-white/10 px-4 py-2 rounded-2xl">
|
||||||
|
<div className="text-[10px] text-slate-400 uppercase tracking-wider font-semibold">Total Budget</div>
|
||||||
|
<div className="text-sm font-bold text-emerald-300 font-mono">
|
||||||
|
{formatCurrency(project.budget || totalAwardsAmount)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="bg-slate-950/60 border border-white/10 px-4 py-2 rounded-2xl">
|
||||||
|
<div className="text-[10px] text-slate-400 uppercase tracking-wider font-semibold">Linked Awards</div>
|
||||||
|
<div className="text-sm font-bold text-cyan-300 font-mono">
|
||||||
|
{awards.length} Award{awards.length !== 1 ? 's' : ''}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Meta Bar: Dates & Milestone Progress */}
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4 text-xs">
|
||||||
|
{/* Timeline */}
|
||||||
|
<div className="flex items-center gap-2 text-slate-300">
|
||||||
|
<Calendar className="w-4 h-4 text-slate-400 shrink-0" />
|
||||||
|
<div>
|
||||||
|
<span className="text-slate-500 block text-[10px] uppercase font-bold">Timeline</span>
|
||||||
|
<span>
|
||||||
|
{project.startedAt ? new Date(project.startedAt).toLocaleDateString() : 'Start Pending'} —{' '}
|
||||||
|
{project.endedAt ? new Date(project.endedAt).toLocaleDateString() : 'Open'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Milestones & Activities count */}
|
||||||
|
<div className="flex items-center gap-2 text-slate-300">
|
||||||
|
<Layers className="w-4 h-4 text-teal-400 shrink-0" />
|
||||||
|
<div>
|
||||||
|
<span className="text-slate-500 block text-[10px] uppercase font-bold">Deliverables</span>
|
||||||
|
<span>
|
||||||
|
{milestones.length} Milestone{milestones.length !== 1 ? 's' : ''} • {totalActivities} Activit{totalActivities !== 1 ? 'ies' : 'y'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Evidence Verification Progress */}
|
||||||
|
<div className="space-y-1 sm:text-right">
|
||||||
|
<div className="flex items-center sm:justify-end gap-2 text-[11px]">
|
||||||
|
<span className="text-slate-400">Evidence Completion:</span>
|
||||||
|
<span className="font-mono font-bold text-emerald-300">{progressPercent}%</span>
|
||||||
|
</div>
|
||||||
|
<div className="w-full bg-slate-950/80 rounded-full h-2 overflow-hidden border border-white/5">
|
||||||
|
<div
|
||||||
|
className="bg-gradient-to-r from-emerald-500 to-teal-400 h-full rounded-full transition-all duration-500"
|
||||||
|
style={{ width: `${progressPercent}%` }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Expand / Collapse Button */}
|
||||||
|
<div className="pt-2 flex justify-between items-center border-t border-white/5">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setIsExpanded(true);
|
||||||
|
setActiveTab('milestones');
|
||||||
|
}}
|
||||||
|
className={`px-3 py-1.5 rounded-xl text-xs font-semibold transition-all cursor-pointer ${
|
||||||
|
isExpanded && activeTab === 'milestones'
|
||||||
|
? 'bg-emerald-500/20 text-emerald-300 border border-emerald-500/30'
|
||||||
|
: 'text-slate-400 hover:text-slate-200 bg-white/[0.02] hover:bg-white/[0.06] border border-white/10'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
Milestones & Activities ({milestones.length})
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setIsExpanded(true);
|
||||||
|
setActiveTab('awards');
|
||||||
|
}}
|
||||||
|
className={`px-3 py-1.5 rounded-xl text-xs font-semibold transition-all cursor-pointer ${
|
||||||
|
isExpanded && activeTab === 'awards'
|
||||||
|
? 'bg-cyan-500/20 text-cyan-300 border border-cyan-500/30'
|
||||||
|
: 'text-slate-400 hover:text-slate-200 bg-white/[0.02] hover:bg-white/[0.06] border border-white/10'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
Historic & Current Awards ({awards.length})
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={() => setIsExpanded(!isExpanded)}
|
||||||
|
className="flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl bg-white/[0.04] hover:bg-white/[0.08] border border-white/10 text-xs font-semibold text-slate-300 hover:text-white transition-all cursor-pointer shadow-sm"
|
||||||
|
>
|
||||||
|
<span>{isExpanded ? 'Collapse Details' : 'Expand Project Details'}</span>
|
||||||
|
{isExpanded ? <ChevronUp className="w-3.5 h-3.5" /> : <ChevronDown className="w-3.5 h-3.5" />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Expanded Section */}
|
||||||
|
{isExpanded && (
|
||||||
|
<div className="pt-4 border-t border-white/10 animate-in fade-in slide-in-from-top-2 duration-300 space-y-6">
|
||||||
|
{/* TAB 1: MILESTONES & ACTIVITIES */}
|
||||||
|
{activeTab === 'milestones' && (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h4 className="text-sm font-bold text-white flex items-center gap-2">
|
||||||
|
<Layers className="w-4 h-4 text-emerald-400" />
|
||||||
|
Milestone Deliverables & Activity Verification
|
||||||
|
</h4>
|
||||||
|
<p className="text-[11px] text-slate-400 mt-0.5">
|
||||||
|
Upload 1 or more evidence files against each activity. A milestone is verified when all its activities have evidence.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{milestones.length === 0 ? (
|
||||||
|
<div className="p-6 rounded-2xl bg-slate-950/40 border border-white/5 text-center text-xs text-slate-400">
|
||||||
|
No milestones recorded for this project yet.
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{milestones.map((milestone) => {
|
||||||
|
const milestoneActs = getActivitiesForMilestone(milestone.id);
|
||||||
|
const milestoneEvidence = getEvidenceForMilestone(milestone.id);
|
||||||
|
const actsWithEvidence = milestoneActs.filter((a) => isActivityDoneWithEvidence(a.id));
|
||||||
|
const isMilestoneFullyEvidenced = milestoneActs.length > 0 && actsWithEvidence.length === milestoneActs.length;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={milestone.id}
|
||||||
|
className="rounded-2xl border border-white/10 bg-slate-950/60 p-4 sm:p-5 space-y-3 shadow-inner"
|
||||||
|
>
|
||||||
|
{/* Milestone Header */}
|
||||||
|
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-2.5 border-b border-white/5">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
|
<span className="font-mono text-xs text-emerald-300 font-bold">
|
||||||
|
Milestone #{encodeHashIdSync(milestone.id)}
|
||||||
|
</span>
|
||||||
|
{renderStatusBadge(milestone.status, 'In Progress')}
|
||||||
|
{isMilestoneFullyEvidenced && (
|
||||||
|
<span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-500/20 text-emerald-300 border border-emerald-500/40">
|
||||||
|
<ShieldCheck className="w-3 h-3" />
|
||||||
|
Evidence Complete
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<h5 className="text-sm font-bold text-slate-100">{milestone.name || 'Milestone Target'}</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="text-xs text-slate-400 flex items-center gap-4">
|
||||||
|
{milestone.dueAt && (
|
||||||
|
<span>
|
||||||
|
Due: <span className="text-slate-200 font-mono">{new Date(milestone.dueAt).toLocaleDateString()}</span>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span className="font-mono text-[11px] text-teal-300 bg-teal-950/60 border border-teal-500/20 px-2 py-0.5 rounded-md">
|
||||||
|
{actsWithEvidence.length} / {milestoneActs.length} Activities Verified
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Nested Activities */}
|
||||||
|
<div className="space-y-2 pt-1">
|
||||||
|
<div className="text-[11px] font-semibold uppercase tracking-wider text-slate-400">
|
||||||
|
Activities & Uploaded Evidence
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{milestoneActs.length === 0 ? (
|
||||||
|
<div className="py-2 text-xs text-slate-500 italic">
|
||||||
|
No individual activities defined under this milestone.
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-2.5">
|
||||||
|
{milestoneActs.map((act) => {
|
||||||
|
const actEvidence = getEvidenceForActivity(act.id);
|
||||||
|
const isDone = actEvidence.length > 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={act.id}
|
||||||
|
className="p-3.5 rounded-xl bg-white/[0.02] border border-white/5 hover:border-white/10 transition-colors space-y-2.5"
|
||||||
|
>
|
||||||
|
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="font-semibold text-xs text-slate-200">
|
||||||
|
{act.title || `Activity #${encodeHashIdSync(act.id)}`}
|
||||||
|
</span>
|
||||||
|
{isDone ? (
|
||||||
|
<span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-bold bg-emerald-950/80 border border-emerald-500/30 text-emerald-300">
|
||||||
|
<CheckCircle2 className="w-3 h-3 text-emerald-400" />
|
||||||
|
Done ({actEvidence.length} Evidence)
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-medium bg-amber-950/60 border border-amber-500/20 text-amber-300">
|
||||||
|
<Clock className="w-3 h-3 text-amber-400" />
|
||||||
|
Pending Evidence
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{act.description && (
|
||||||
|
<p className="text-[11px] text-slate-400">{act.description}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Upload Evidence Button */}
|
||||||
|
<button
|
||||||
|
onClick={() => setUploadTarget({ activity: act, milestone })}
|
||||||
|
className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl bg-emerald-500/10 hover:bg-emerald-500/20 border border-emerald-500/30 text-emerald-300 hover:text-emerald-200 text-xs font-semibold transition-all shrink-0 cursor-pointer shadow-sm hover:shadow-[0_0_12px_rgba(16,185,129,0.2)]"
|
||||||
|
>
|
||||||
|
<UploadCloud className="w-3.5 h-3.5" />
|
||||||
|
<span>Upload Evidence</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* List of uploaded evidence records against this activity */}
|
||||||
|
{actEvidence.length > 0 && (
|
||||||
|
<div className="pt-2 border-t border-white/5 space-y-1.5">
|
||||||
|
<div className="text-[10px] uppercase font-bold tracking-wider text-slate-500">
|
||||||
|
Attached Deliverables ({actEvidence.length}):
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||||
|
{actEvidence.map((ev) => (
|
||||||
|
<div
|
||||||
|
key={ev.id}
|
||||||
|
className="flex items-center justify-between p-2 rounded-lg bg-slate-900/80 border border-white/5 text-[11px]"
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2 truncate">
|
||||||
|
<FileText className="w-3.5 h-3.5 text-emerald-400 shrink-0" />
|
||||||
|
<span className="text-slate-200 font-medium truncate">
|
||||||
|
{ev.title || ev.fileName || `Evidence #${encodeHashIdSync(ev.id)}`}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{ev.documentUrl && (
|
||||||
|
<a
|
||||||
|
href={ev.documentUrl}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
className="text-emerald-400 hover:text-emerald-300 p-1 hover:bg-white/5 rounded shrink-0"
|
||||||
|
title="View Document"
|
||||||
|
>
|
||||||
|
<ExternalLink className="w-3 h-3" />
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* TAB 2: AWARDS */}
|
||||||
|
{activeTab === 'awards' && (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h4 className="text-sm font-bold text-white flex items-center gap-2">
|
||||||
|
<AwardIcon className="w-4 h-4 text-cyan-400" />
|
||||||
|
Grantee Awards (Historic & Current)
|
||||||
|
</h4>
|
||||||
|
<p className="text-[11px] text-slate-400 mt-0.5">
|
||||||
|
Official grant award commitments linked to this project portfolio.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{awards.length === 0 ? (
|
||||||
|
<div className="p-6 rounded-2xl bg-slate-950/40 border border-white/5 text-center text-xs text-slate-400">
|
||||||
|
No grant awards linked to this project.
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||||
|
{awards.map((award) => (
|
||||||
|
<div
|
||||||
|
key={award.id}
|
||||||
|
className="p-4 rounded-2xl bg-slate-950/60 border border-white/10 space-y-2.5 shadow-inner"
|
||||||
|
>
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<span className="font-mono text-xs font-bold text-cyan-300">
|
||||||
|
Award #{encodeHashIdSync(award.id)}
|
||||||
|
</span>
|
||||||
|
{renderStatusBadge(award.status, 'Active')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="text-[10px] text-slate-400 uppercase font-semibold">Award Amount</div>
|
||||||
|
<div className="text-lg font-bold text-white font-mono">
|
||||||
|
{formatCurrency(award.amount)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="pt-2 border-t border-white/5 flex items-center justify-between text-[11px] text-slate-400">
|
||||||
|
<span>
|
||||||
|
Created: <span className="text-slate-300">{award.createdAt ? new Date(award.createdAt).toLocaleDateString() : 'N/A'}</span>
|
||||||
|
</span>
|
||||||
|
{award.programmeId && (
|
||||||
|
<span className="font-mono text-[10px] text-slate-400">
|
||||||
|
Prog #{encodeHashIdSync(award.programmeId)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</BorderGlow>
|
||||||
|
|
||||||
|
{/* Modal for Evidence Upload */}
|
||||||
|
{uploadTarget && (
|
||||||
|
<EvidenceUploadModal
|
||||||
|
isOpen={true}
|
||||||
|
onClose={() => setUploadTarget(null)}
|
||||||
|
project={project}
|
||||||
|
milestone={uploadTarget.milestone}
|
||||||
|
activity={uploadTarget.activity}
|
||||||
|
onEvidenceUploaded={() => {
|
||||||
|
onEvidenceUploaded();
|
||||||
|
setUploadTarget(null);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ export const LandingPage: React.FC<LandingPageProps> = ({ onLogin, isLoading })
|
|||||||
<ArrowRight className="h-5 w-5 text-emerald-200" />
|
<ArrowRight className="h-5 w-5 text-emerald-200" />
|
||||||
</SpecularButton>
|
</SpecularButton>
|
||||||
<span className="text-[11px] text-slate-400 font-mono tracking-tight">
|
<span className="text-[11px] text-slate-400 font-mono tracking-tight">
|
||||||
Single Sign-On enabled for authorized institutional tenants
|
Single Sign-On enabled for authorized users
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,425 @@
|
|||||||
|
import { apiClient } from '../httpClient';
|
||||||
|
import { encodeHashIdSync } from '../toolsService';
|
||||||
|
import * as Models from './models';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility helper to ensure URL parameters are encoded using the Hashids service
|
||||||
|
*/
|
||||||
|
export function hashParam(id: number | string | null | undefined): string {
|
||||||
|
if (id === undefined || id === null || id === '') return '';
|
||||||
|
return encodeHashIdSync(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Users & Integration Endpoints
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
export const usersApi = {
|
||||||
|
getUser: (userId: string | number) =>
|
||||||
|
apiClient.get<Models.User>(`/v1/api/users/${hashParam(userId)}`),
|
||||||
|
|
||||||
|
getUsersPaged: (page: number, pageSize: number, filter?: Models.UserFilterRequest) =>
|
||||||
|
apiClient.post<Models.User[]>(`/v1/api/users/${page}/${pageSize}`, filter || {}),
|
||||||
|
|
||||||
|
syncIntegration: (payload: any) =>
|
||||||
|
apiClient.post<any>('/v1/api/integration/sync', payload),
|
||||||
|
|
||||||
|
updateUserStatus: (userId: string | number, status: string | number) =>
|
||||||
|
apiClient.get<any>(`/v1/api/users/${hashParam(userId)}/status/${status}`),
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Projects & Sub-resources Endpoints
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
export const projectsApi = {
|
||||||
|
// Projects
|
||||||
|
getProjects: (params?: { page?: number; pageSize?: number }) =>
|
||||||
|
apiClient.get<Models.Project[]>('/v1/api/projects', { params }),
|
||||||
|
|
||||||
|
getProject: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.Project>(`/v1/api/projects/${hashParam(projectId)}`),
|
||||||
|
|
||||||
|
createProject: (payload: Models.CreateProjectRequest) =>
|
||||||
|
apiClient.post<Models.Project>('/v1/api/projects', payload),
|
||||||
|
|
||||||
|
updateProject: (payload: Models.UpdateProjectRequest) =>
|
||||||
|
apiClient.put<Models.Project>('/v1/api/projects', payload),
|
||||||
|
|
||||||
|
updateProjectStatus: (payload: Models.UpdateProjectStatusRequest) =>
|
||||||
|
apiClient.put<any>('/v1/api/projects/status', payload),
|
||||||
|
|
||||||
|
// Activities
|
||||||
|
createActivity: (payload: Models.CreateActivityRequest) =>
|
||||||
|
apiClient.post<Models.Activity>('/v1/api/projects/activities', payload),
|
||||||
|
|
||||||
|
getProjectActivities: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.Activity[]>(`/v1/api/projects/${hashParam(projectId)}/activities`),
|
||||||
|
|
||||||
|
getActivity: (activityId: string | number) =>
|
||||||
|
apiClient.get<Models.Activity>(`/v1/api/projects/activities/${hashParam(activityId)}`),
|
||||||
|
|
||||||
|
// Beneficiaries
|
||||||
|
createBeneficiary: (payload: Models.CreateBeneficiaryRequest) =>
|
||||||
|
apiClient.post<Models.Beneficiary>('/v1/api/projects/beneficiaries', payload),
|
||||||
|
|
||||||
|
updateBeneficiary: (payload: Models.UpdateBeneficiaryRequest) =>
|
||||||
|
apiClient.put<Models.Beneficiary>('/v1/api/projects/beneficiaries', payload),
|
||||||
|
|
||||||
|
getProjectBeneficiaries: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.Beneficiary[]>(`/v1/api/projects/${hashParam(projectId)}/beneficiaries`),
|
||||||
|
|
||||||
|
getBeneficiary: (beneficiaryId: string | number) =>
|
||||||
|
apiClient.get<Models.Beneficiary>(`/v1/api/projects/beneficiaries/${hashParam(beneficiaryId)}`),
|
||||||
|
|
||||||
|
// Outcomes
|
||||||
|
createOutcome: (payload: Models.CreateOutcomeRequest) =>
|
||||||
|
apiClient.post<Models.Outcome>('/v1/api/projects/beneficiaris/outcomes', payload),
|
||||||
|
|
||||||
|
updateOutcome: (payload: Models.UpdateOutcomeRequest) =>
|
||||||
|
apiClient.put<Models.Outcome>('/v1/api/projects/outcomes', payload),
|
||||||
|
|
||||||
|
getOutcome: (outcomeId: string | number) =>
|
||||||
|
apiClient.get<Models.Outcome>(`/v1/api/projects/outcomes/${hashParam(outcomeId)}`),
|
||||||
|
|
||||||
|
getBeneficiaryOutcomes: (beneficiaryId: string | number) =>
|
||||||
|
apiClient.get<Models.Outcome[]>(`/v1/api/projects/outcomes/${hashParam(beneficiaryId)}`),
|
||||||
|
|
||||||
|
// Change Requests
|
||||||
|
createChangeRequest: (payload: Models.CreateChangeRequest) =>
|
||||||
|
apiClient.post<Models.ChangeRequest>('/v1/api/projects/changerequests', payload),
|
||||||
|
|
||||||
|
updateChangeRequest: (payload: Models.UpdateChangeRequest) =>
|
||||||
|
apiClient.put<Models.ChangeRequest>('/v1/api/projects/changerequests', payload),
|
||||||
|
|
||||||
|
getProjectChangeRequests: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.ChangeRequest[]>(`/v1/api/projects/${hashParam(projectId)}/changerequests`),
|
||||||
|
|
||||||
|
getChangeRequest: (changeRequestId: string | number) =>
|
||||||
|
apiClient.get<Models.ChangeRequest>(`/v1/api/projects/changerequests/${hashParam(changeRequestId)}`),
|
||||||
|
|
||||||
|
// Compliance
|
||||||
|
createComplianceItem: (payload: Models.CreateComplianceItemRequest) =>
|
||||||
|
apiClient.post<Models.ComplianceItem>('/v1/api/projects/complianceitems', payload),
|
||||||
|
|
||||||
|
updateComplianceItem: (payload: Models.UpdateComplianceItemRequest) =>
|
||||||
|
apiClient.put<Models.ComplianceItem>('/v1/api/projects/complianceitems', payload),
|
||||||
|
|
||||||
|
getProjectComplianceItems: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.ComplianceItem[]>(`/v1/api/projects/${hashParam(projectId)}/complianceitems`),
|
||||||
|
|
||||||
|
getComplianceItem: (complianceItemId: string | number) =>
|
||||||
|
apiClient.get<Models.ComplianceItem>(`/v1/api/projects/complianceitems/${hashParam(complianceItemId)}`),
|
||||||
|
|
||||||
|
// Issues
|
||||||
|
createIssue: (payload: Models.CreateIssueRequest) =>
|
||||||
|
apiClient.post<Models.Issue>('/v1/api/projects/issues', payload),
|
||||||
|
|
||||||
|
updateIssue: (payload: Models.UpdateIssueRequest) =>
|
||||||
|
apiClient.put<Models.Issue>('/v1/api/projects/issues', payload),
|
||||||
|
|
||||||
|
getProjectIssues: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.Issue[]>(`/v1/api/projects/${hashParam(projectId)}/issues`),
|
||||||
|
|
||||||
|
getIssue: (issueId: string | number) =>
|
||||||
|
apiClient.get<Models.Issue>(`/v1/api/projects/issues/${hashParam(issueId)}`),
|
||||||
|
|
||||||
|
// Milestones
|
||||||
|
getProjectMilestones: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.Milestone[]>(`/v1/api/projects/${hashParam(projectId)}/milestones`),
|
||||||
|
|
||||||
|
getMilestone: (milestoneId: string | number) =>
|
||||||
|
apiClient.get<Models.Milestone>(`/v1/api/projects/milestones/${hashParam(milestoneId)}`),
|
||||||
|
|
||||||
|
getMilestonesPaged: (page: number, pageSize: number) =>
|
||||||
|
apiClient.get<Models.Milestone[]>(`/v1/api/projects/milestones/${page}/${pageSize}`),
|
||||||
|
|
||||||
|
updateMilestone: (payload: Models.UpdateMilestoneRequest) =>
|
||||||
|
apiClient.put<Models.Milestone>('/v1/api/projects/milestone', payload),
|
||||||
|
|
||||||
|
// Indicators & Risks & Site Visits
|
||||||
|
getProjectIndicators: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.Indicator[]>(`/v1/api/projects/indicators/project/${hashParam(projectId)}`),
|
||||||
|
|
||||||
|
getProjectRisks: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.Risk[]>(`/v1/api/projects/${hashParam(projectId)}/risks`),
|
||||||
|
|
||||||
|
getProjectSiteVisits: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.SiteVisit[]>(`/v1/api/projects/${hashParam(projectId)}/sitevisits`),
|
||||||
|
|
||||||
|
getSiteVisit: (siteVisitId: string | number) =>
|
||||||
|
apiClient.get<Models.SiteVisit>(`/v1/api/projects/sitevisits/${hashParam(siteVisitId)}`),
|
||||||
|
|
||||||
|
createSiteVisit: (payload: Models.CreateSiteVisitRequest) =>
|
||||||
|
apiClient.post<Models.SiteVisit>('/v1/api/projects/sitevisits', payload),
|
||||||
|
|
||||||
|
updateSiteVisit: (payload: Models.UpdateSiteVisitRequest) =>
|
||||||
|
apiClient.put<Models.SiteVisit>('/v1/api/projects/sitevisits', payload),
|
||||||
|
|
||||||
|
// Programmes under projects
|
||||||
|
createProgramme: (payload: Models.CreateProgrammeRequest) =>
|
||||||
|
apiClient.post<Models.Programme>('/v1/api/projects/programme', payload),
|
||||||
|
|
||||||
|
updateProgramme: (payload: Models.UpdateProgrammeRequest) =>
|
||||||
|
apiClient.put<Models.Programme>('/v1/api/projects/programme', payload),
|
||||||
|
|
||||||
|
getProgrammeProjects: (programmeId: string | number) =>
|
||||||
|
apiClient.get<Models.Project[]>(`/v1/api/projects/${hashParam(programmeId)}/programme`),
|
||||||
|
|
||||||
|
getProgrammeById: (programmeId: string | number) =>
|
||||||
|
apiClient.get<Models.Programme>(`/v1/api/projects/programme/${hashParam(programmeId)}`),
|
||||||
|
|
||||||
|
getProgrammesPaged: (page: number, pageSize: number) =>
|
||||||
|
apiClient.get<Models.Programme[]>(`/v1/api/projects/programme/${page}/${pageSize}`),
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Grants Endpoints
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
export const grantsApi = {
|
||||||
|
// Awards
|
||||||
|
createAward: (payload: Models.CreateAwardRequest) =>
|
||||||
|
apiClient.post<Models.Award>('/v1/api/grants/awards', payload),
|
||||||
|
|
||||||
|
getAwards: (params?: { page?: number; pageSize?: number }) =>
|
||||||
|
apiClient.get<Models.Award[]>('/v1/api/grants/awards', { params }),
|
||||||
|
|
||||||
|
getAward: (awardId: string | number) =>
|
||||||
|
apiClient.get<Models.Award>(`/v1/api/grants/awards/${hashParam(awardId)}`),
|
||||||
|
|
||||||
|
// Budgets
|
||||||
|
createBudget: (payload: Models.CreateBudgetRequest) =>
|
||||||
|
apiClient.post<Models.Budget>('/v1/api/grants/budgets', payload),
|
||||||
|
|
||||||
|
getBudgets: (params?: { page?: number; pageSize?: number }) =>
|
||||||
|
apiClient.get<Models.Budget[]>('/v1/api/grants/budgets', { params }),
|
||||||
|
|
||||||
|
updateBudget: (payload: Models.UpdateBudgetRequest) =>
|
||||||
|
apiClient.put<Models.Budget>('/v1/api/grants/budgets', payload),
|
||||||
|
|
||||||
|
getBudget: (budgetId: string | number) =>
|
||||||
|
apiClient.get<Models.Budget>(`/v1/api/grants/budgets/${hashParam(budgetId)}`),
|
||||||
|
|
||||||
|
// Contracts
|
||||||
|
createContract: (payload: Models.CreateContractRequest) =>
|
||||||
|
apiClient.post<Models.Contract>('/v1/api/grants/contracts', payload),
|
||||||
|
|
||||||
|
getContracts: (params?: { page?: number; pageSize?: number }) =>
|
||||||
|
apiClient.get<Models.Contract[]>('/v1/api/grants/contracts', { params }),
|
||||||
|
|
||||||
|
updateContract: (payload: Models.UpdateContractRequest) =>
|
||||||
|
apiClient.put<Models.Contract>('/v1/api/grants/contracts', payload),
|
||||||
|
|
||||||
|
executeContract: (payload: Models.ExecuteContractRequest) =>
|
||||||
|
apiClient.post<any>('/v1/api/grants/contracts/execute', payload),
|
||||||
|
|
||||||
|
getContract: (contractId: string | number) =>
|
||||||
|
apiClient.get<Models.Contract>(`/v1/api/grants/contracts/${hashParam(contractId)}`),
|
||||||
|
|
||||||
|
uploadContractFile: (contractId: string | number, formData: FormData) =>
|
||||||
|
apiClient.post<any>(`/v1/api/grants/contracts/${hashParam(contractId)}`, formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
}),
|
||||||
|
|
||||||
|
getContractSecureLink: (contractId: string | number) =>
|
||||||
|
apiClient.get<{ url: string }>(`/v1/api/grants/contracts/${hashParam(contractId)}/securelink`),
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Governance Endpoints
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
export const governanceApi = {
|
||||||
|
getDashboard: () =>
|
||||||
|
apiClient.get<Models.Dashboard>('/v1/api/governance/dashboard'),
|
||||||
|
|
||||||
|
getAuditLogs: (payload?: any) =>
|
||||||
|
apiClient.post<Models.AuditLog[]>('/v1/api/governance/auditlog', payload || {}),
|
||||||
|
|
||||||
|
// Instruments
|
||||||
|
createInstrument: (payload: Models.CreateInstrumentRequest) =>
|
||||||
|
apiClient.post<Models.Instrument>('/v1/api/governance/instruments', payload),
|
||||||
|
|
||||||
|
updateInstrument: (payload: Models.UpdateInstrumentRequest) =>
|
||||||
|
apiClient.put<Models.Instrument>('/v1/api/governance/instruments', payload),
|
||||||
|
|
||||||
|
getProgrammeInstruments: (programmeId: string | number) =>
|
||||||
|
apiClient.get<Models.Instrument[]>(`/v1/api/governance/instruments/${hashParam(programmeId)}`),
|
||||||
|
|
||||||
|
// Organisations
|
||||||
|
createOrganisation: (payload: Models.CreateOrganisationRequest) =>
|
||||||
|
apiClient.post<Models.Organisation>('/v1/api/governance/organisations', payload),
|
||||||
|
|
||||||
|
getOrganisations: (params?: { page?: number; pageSize?: number }) =>
|
||||||
|
apiClient.get<Models.Organisation[]>('/v1/api/governance/organisations', { params }),
|
||||||
|
|
||||||
|
updateOrganisation: (payload: Models.UpdateOrganisationRequest) =>
|
||||||
|
apiClient.put<Models.Organisation>('/v1/api/governance/organisations', payload),
|
||||||
|
|
||||||
|
getOrganisation: (organisationId: string | number) =>
|
||||||
|
apiClient.get<Models.Organisation>(`/v1/api/governance/organisations/${hashParam(organisationId)}`),
|
||||||
|
|
||||||
|
getOrganisationPortfolios: (organisationId: string | number) =>
|
||||||
|
apiClient.get<Models.Portfolio[]>(`/v1/api/governance/organisations/${hashParam(organisationId)}/portfolio`),
|
||||||
|
|
||||||
|
createOrganisationPortfolio: (payload: Models.CreatePortfolioRequest) =>
|
||||||
|
apiClient.post<Models.Portfolio>('/v1/api/governance/organisations/portfolio', payload),
|
||||||
|
|
||||||
|
updateOrganisationPortfolio: (payload: Models.UpdatePortfolioRequest) =>
|
||||||
|
apiClient.put<Models.Portfolio>('/v1/api/governance/organisations/portfolio', payload),
|
||||||
|
|
||||||
|
getOrganisationsPortfoliosList: (payload?: any) =>
|
||||||
|
apiClient.post<Models.Portfolio[]>('/v1/api/governance/organisations/portfolios', payload || {}),
|
||||||
|
|
||||||
|
// Portfolios
|
||||||
|
getPortfolio: (portfolioId: string | number) =>
|
||||||
|
apiClient.get<Models.Portfolio>(`/v1/api/governance/portfolios/${hashParam(portfolioId)}`),
|
||||||
|
|
||||||
|
getPortfolioValue: (portfolioId: string | number) =>
|
||||||
|
apiClient.get<{ value: number }>(`/v1/api/governance/portfolios/${hashParam(portfolioId)}/value`),
|
||||||
|
|
||||||
|
getPortfolioProgrammes: (portfolioId: string | number) =>
|
||||||
|
apiClient.get<Models.Programme[]>(`/v1/api/governance/portfolios/${hashParam(portfolioId)}/programmes`),
|
||||||
|
|
||||||
|
// Programmes under governance
|
||||||
|
getProgrammesByPortfolio: (portfolioId: string | number) =>
|
||||||
|
apiClient.get<Models.Programme[]>(`/v1/api/governance/programmes/${hashParam(portfolioId)}`),
|
||||||
|
|
||||||
|
getProgrammeValue: (programmeId: string | number) =>
|
||||||
|
apiClient.get<{ value: number }>(`/v1/api/governance/programmes/${hashParam(programmeId)}/value`),
|
||||||
|
|
||||||
|
// Tenants
|
||||||
|
createTenant: (payload: Models.CreateTenantRequest) =>
|
||||||
|
apiClient.post<Models.Tenant>('/v1/api/governance/tenants', payload),
|
||||||
|
|
||||||
|
getTenants: () =>
|
||||||
|
apiClient.get<Models.Tenant[]>('/v1/api/governance/tenants'),
|
||||||
|
|
||||||
|
updateTenant: (payload: Models.UpdateTenantRequest) =>
|
||||||
|
apiClient.put<Models.Tenant>('/v1/api/governance/tenants', payload),
|
||||||
|
|
||||||
|
getTenant: (tenantId: string | number) =>
|
||||||
|
apiClient.get<Models.Tenant>(`/v1/api/governance/tenants/${hashParam(tenantId)}`),
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Execution Endpoints
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
export const executionApi = {
|
||||||
|
// Disbursements
|
||||||
|
getDisbursements: (params?: { page?: number; pageSize?: number }) =>
|
||||||
|
apiClient.get<Models.Disbursement[]>('/v1/api/execution/disbursements', { params }),
|
||||||
|
|
||||||
|
getDisbursement: (disbursementId: string | number) =>
|
||||||
|
apiClient.get<Models.Disbursement>(`/v1/api/execution/disbursements/${hashParam(disbursementId)}`),
|
||||||
|
|
||||||
|
createDisbursement: (payload: Models.CreateDisbursementRequest) =>
|
||||||
|
apiClient.post<Models.Disbursement>('/v1/api/execution/disbursements', payload),
|
||||||
|
|
||||||
|
updateDisbursement: (payload: Models.UpdateDisbursementRequest) =>
|
||||||
|
apiClient.put<Models.Disbursement>('/v1/api/execution/disbursements', payload),
|
||||||
|
|
||||||
|
approveDisbursement: (disbursementId: string | number) =>
|
||||||
|
apiClient.post<any>(`/v1/api/execution/disbursements/${hashParam(disbursementId)}/approve`),
|
||||||
|
|
||||||
|
// Risks
|
||||||
|
getRisks: (params?: { page?: number; pageSize?: number }) =>
|
||||||
|
apiClient.get<Models.Risk[]>('/v1/api/execution/risks', { params }),
|
||||||
|
|
||||||
|
getRisk: (riskId: string | number) =>
|
||||||
|
apiClient.get<Models.Risk>(`/v1/api/execution/risks/${hashParam(riskId)}`),
|
||||||
|
|
||||||
|
createRisk: (payload: Models.CreateRiskRequest) =>
|
||||||
|
apiClient.post<Models.Risk>('/v1/api/execution/risks', payload),
|
||||||
|
|
||||||
|
updateRisk: (payload: Models.UpdateRiskRequest) =>
|
||||||
|
apiClient.put<Models.Risk>('/v1/api/execution/risks', payload),
|
||||||
|
|
||||||
|
// Rules
|
||||||
|
getRule: (ruleId: string | number) =>
|
||||||
|
apiClient.get<Models.Rule>(`/v1/api/execution/rules/${hashParam(ruleId)}`),
|
||||||
|
|
||||||
|
createRule: (payload: Models.CreateRuleRequest) =>
|
||||||
|
apiClient.post<Models.Rule>('/v1/api/execution/rules', payload),
|
||||||
|
|
||||||
|
updateRule: (payload: Models.UpdateRuleRequest) =>
|
||||||
|
apiClient.put<Models.Rule>('/v1/api/execution/rules', payload),
|
||||||
|
|
||||||
|
getProgrammeRules: (payload?: any) =>
|
||||||
|
apiClient.post<Models.Rule[]>('/v1/api/execution/programmes/rules', payload || {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Evidence & M&E Endpoints
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
export const evidenceApi = {
|
||||||
|
// Evidence files & records
|
||||||
|
createEvidenceFile: (payload: FormData | any) => {
|
||||||
|
const isFormData = typeof FormData !== 'undefined' && payload instanceof FormData;
|
||||||
|
return apiClient.put<Models.Evidence>('/v1/api/evidence/file', payload, {
|
||||||
|
headers: isFormData ? { 'Content-Type': 'multipart/form-data' } : undefined,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
updateEvidence: (payload: Models.UpdateEvidenceRequest) =>
|
||||||
|
apiClient.put<Models.Evidence>('/v1/api/evidence', payload),
|
||||||
|
|
||||||
|
getEvidence: (evidenceId: string | number) =>
|
||||||
|
apiClient.get<Models.Evidence>(`/v1/api/evidence/${hashParam(evidenceId)}`),
|
||||||
|
|
||||||
|
getEvidenceFilesPaged: (page: number, pageSize: number) =>
|
||||||
|
apiClient.get<Models.Evidence[]>(`/v1/api/evidence/files/${page}/${pageSize}`),
|
||||||
|
|
||||||
|
getEvidenceSecureLink: (evidenceId: string | number) =>
|
||||||
|
apiClient.get<{ url: string }>(`/v1/api/evidence/${hashParam(evidenceId)}/securelink`),
|
||||||
|
|
||||||
|
getMilestoneEvidence: (milestoneId: string | number) =>
|
||||||
|
apiClient.get<Models.Evidence[]>(`/v1/api/evidence/milestone/${hashParam(milestoneId)}`),
|
||||||
|
|
||||||
|
getProjectEvidence: (projectId: string | number) =>
|
||||||
|
apiClient.get<Models.Evidence[]>(`/v1/api/evidence/${hashParam(projectId)}`),
|
||||||
|
|
||||||
|
createMilestoneRequest: (payload: Models.CreateMilestoneRequest) =>
|
||||||
|
apiClient.post<Models.Milestone>('/v1/api/evidence/milestones', payload),
|
||||||
|
|
||||||
|
// Indicators
|
||||||
|
createIndicator: (payload: Models.CreateIndicatorRequest) =>
|
||||||
|
apiClient.post<Models.Indicator>('/v1/api/evidence/indicators', payload),
|
||||||
|
|
||||||
|
getIndicator: (indicatorId: string | number) =>
|
||||||
|
apiClient.get<Models.Indicator>(`/v1/api/evidence/indicators/${hashParam(indicatorId)}`),
|
||||||
|
|
||||||
|
getIndicatorsPaged: (page: number, pageSize: number) =>
|
||||||
|
apiClient.get<Models.Indicator[]>(`/v1/api/evidence/indicators/${page}/${pageSize}`),
|
||||||
|
|
||||||
|
recordIndicatorActualAmount: (indicatorId: string | number, actualAmount: number) =>
|
||||||
|
apiClient.post<any>(`/v1/api/evidence/indicators/${hashParam(indicatorId)}/actuals/${actualAmount}`),
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Communications Endpoints
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
export const communicationsApi = {
|
||||||
|
sendInvite: (payload: Models.InviteRequest) =>
|
||||||
|
apiClient.post<Models.Invite>('/v1/api/communications/invites', payload),
|
||||||
|
|
||||||
|
getInvitesPaged: (page: number, pageSize: number) =>
|
||||||
|
apiClient.get<Models.Invite[]>(`/v1/api/communications/invites/${page}/${pageSize}`),
|
||||||
|
|
||||||
|
getApplicantInvites: (applicantUserId: string | number) =>
|
||||||
|
apiClient.get<Models.Invite[]>(`/v1/api/communications/invites/${hashParam(applicantUserId)}`),
|
||||||
|
|
||||||
|
getApplicantInvite: (applicantUserId: string | number) =>
|
||||||
|
apiClient.get<Models.Invite>(`/v1/api/communications/invites/applicants/${hashParam(applicantUserId)}`),
|
||||||
|
|
||||||
|
getNotifications: (organisationId: string | number) =>
|
||||||
|
apiClient.get<Models.Notification[]>(`/v1/api/communications/norifications/${hashParam(organisationId)}`),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Consolidated export
|
||||||
|
export const api = {
|
||||||
|
users: usersApi,
|
||||||
|
projects: projectsApi,
|
||||||
|
grants: grantsApi,
|
||||||
|
governance: governanceApi,
|
||||||
|
execution: executionApi,
|
||||||
|
evidence: evidenceApi,
|
||||||
|
communications: communicationsApi,
|
||||||
|
};
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import { ProblemDetails } from './models';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts comma-delimited error messages from the ProblemDetails `detail` field
|
||||||
|
* or falls back to message/title/string.
|
||||||
|
*/
|
||||||
|
export function extractApiErrors(error: unknown): string[] {
|
||||||
|
if (!error) {
|
||||||
|
return ['An unknown error occurred.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle Axios / Fetch response error structures
|
||||||
|
const axiosError = error as any;
|
||||||
|
const responseData: ProblemDetails | string | undefined = axiosError?.response?.data || axiosError?.data;
|
||||||
|
|
||||||
|
if (responseData) {
|
||||||
|
if (typeof responseData === 'object') {
|
||||||
|
if (responseData.detail && typeof responseData.detail === 'string') {
|
||||||
|
const parsed = responseData.detail
|
||||||
|
.split(',')
|
||||||
|
.map((item) => item.trim())
|
||||||
|
.filter((item) => item.length > 0);
|
||||||
|
if (parsed.length > 0) return parsed;
|
||||||
|
}
|
||||||
|
if (responseData.title && typeof responseData.title === 'string') {
|
||||||
|
return [responseData.title.trim()];
|
||||||
|
}
|
||||||
|
if ((responseData as any).message && typeof (responseData as any).message === 'string') {
|
||||||
|
return [(responseData as any).message.trim()];
|
||||||
|
}
|
||||||
|
} else if (typeof responseData === 'string' && responseData.trim()) {
|
||||||
|
return [responseData.trim()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof error === 'object' && error !== null) {
|
||||||
|
if ('detail' in error && typeof (error as any).detail === 'string') {
|
||||||
|
const parsed = (error as any).detail
|
||||||
|
.split(',')
|
||||||
|
.map((item: string) => item.trim())
|
||||||
|
.filter((item: string) => item.length > 0);
|
||||||
|
if (parsed.length > 0) return parsed;
|
||||||
|
}
|
||||||
|
if ('message' in error && typeof (error as any).message === 'string') {
|
||||||
|
return [(error as any).message.trim()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof error === 'string') {
|
||||||
|
return [error.trim()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['An unexpected error occurred while communicating with the server.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a formatted single message from the extracted comma-delimited errors.
|
||||||
|
*/
|
||||||
|
export function formatApiErrorMessage(error: unknown): string {
|
||||||
|
const errors = extractApiErrors(error);
|
||||||
|
return errors.join('\n• ');
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export * from './models';
|
||||||
|
export * from './errorHelper';
|
||||||
|
export * from './endpoints';
|
||||||
@@ -0,0 +1,692 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI TypeScript Models for PostFundManagement.Api v1
|
||||||
|
* Synchronized from https://api.ifri.khongisa.co.za/openapi/v1/
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface ProblemDetails {
|
||||||
|
type?: string | null;
|
||||||
|
title?: string | null;
|
||||||
|
status?: number | string | null;
|
||||||
|
detail?: string | null;
|
||||||
|
instance?: string | null;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ActivityStatus = 0 | 1 | 2 | 3 | 4 | 'Planned' | 'InProgress' | 'Completed' | 'Delayed' | 'Cancelled' | number | string;
|
||||||
|
export type ApprovalStatus = 0 | 1 | 2 | 3 | 'Draft' | 'PendingApproval' | 'Approved' | 'Rejected' | number | string;
|
||||||
|
export type ContractStatus = 0 | 1 | 2 | 3 | 4 | 'Draft' | 'Active' | 'Executed' | 'Terminated' | 'Expired' | number | string;
|
||||||
|
export type EvidenceType = 0 | 1 | 2 | 3 | 4 | 5 | 'Document' | 'Invoice' | 'Receipt' | 'SitePhoto' | 'Report' | 'Other' | number | string;
|
||||||
|
export type IndustrySector = number | string;
|
||||||
|
export type NotificationPlatform = 0 | 1 | 2 | 'Email' | 'SMS' | 'InApp' | number | string;
|
||||||
|
export type NotificationStatus = 0 | 1 | 2 | 3 | 'Queued' | 'Sent' | 'Failed' | 'Delivered' | number | string;
|
||||||
|
export type OrganisationType = 0 | 1 | 2 | 3 | 'Grantee' | 'Funder' | 'Partner' | 'Auditor' | number | string;
|
||||||
|
export type Priority = 0 | 1 | 2 | 3 | 'Low' | 'Medium' | 'High' | 'Critical' | number | string;
|
||||||
|
export type ProjectType = 0 | 1 | 2 | 3 | 'Grant' | 'Loan' | 'Equity' | 'Hybrid' | number | string;
|
||||||
|
export type RiskImpact = 0 | 1 | 2 | 3 | 'Low' | 'Medium' | 'High' | 'Critical' | number | string;
|
||||||
|
export type RiskLikelihood = 0 | 1 | 2 | 3 | 'Rare' | 'Unlikely' | 'Possible' | 'Likely' | number | string;
|
||||||
|
export type UnitOfMeasure = number | string;
|
||||||
|
|
||||||
|
export interface Pagination {
|
||||||
|
page?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
totalRecords?: number;
|
||||||
|
totalPages?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface User {
|
||||||
|
id?: string;
|
||||||
|
sub?: string;
|
||||||
|
email?: string;
|
||||||
|
name?: string;
|
||||||
|
role?: string;
|
||||||
|
tenant?: string;
|
||||||
|
tenant_id?: number | string;
|
||||||
|
status?: string | number;
|
||||||
|
createdAt?: string;
|
||||||
|
updatedAt?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserFilterRequest {
|
||||||
|
email?: string;
|
||||||
|
name?: string;
|
||||||
|
role?: string;
|
||||||
|
status?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Activity {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
status?: ActivityStatus;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
|
progressPercentage?: number;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateActivityRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
|
status?: ActivityStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Beneficiary {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
name?: string;
|
||||||
|
identificationNumber?: string;
|
||||||
|
contactNumber?: string;
|
||||||
|
email?: string;
|
||||||
|
location?: string;
|
||||||
|
gender?: string;
|
||||||
|
age?: number;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateBeneficiaryRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
name: string;
|
||||||
|
identificationNumber?: string;
|
||||||
|
contactNumber?: string;
|
||||||
|
email?: string;
|
||||||
|
location?: string;
|
||||||
|
gender?: string;
|
||||||
|
age?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateBeneficiaryRequest {
|
||||||
|
id: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
name?: string;
|
||||||
|
identificationNumber?: string;
|
||||||
|
contactNumber?: string;
|
||||||
|
email?: string;
|
||||||
|
location?: string;
|
||||||
|
gender?: string;
|
||||||
|
age?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Outcome {
|
||||||
|
id?: string | number;
|
||||||
|
beneficiaryId?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
targetMetric?: string;
|
||||||
|
achievedMetric?: string;
|
||||||
|
dateRecorded?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOutcomeRequest {
|
||||||
|
beneficiaryId?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
targetMetric?: string;
|
||||||
|
achievedMetric?: string;
|
||||||
|
dateRecorded?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOutcomeRequest {
|
||||||
|
id: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
targetMetric?: string;
|
||||||
|
achievedMetric?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChangeRequest {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
reason?: string;
|
||||||
|
proposedChanges?: string;
|
||||||
|
requestedBy?: string;
|
||||||
|
status?: ApprovalStatus;
|
||||||
|
requestDate?: string;
|
||||||
|
approvalDate?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateChangeRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
reason: string;
|
||||||
|
proposedChanges: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateChangeRequest {
|
||||||
|
id: string | number;
|
||||||
|
reason?: string;
|
||||||
|
proposedChanges?: string;
|
||||||
|
status?: ApprovalStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ComplianceItem {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
isCompliant?: boolean;
|
||||||
|
dueDate?: string;
|
||||||
|
verifiedAt?: string;
|
||||||
|
verifiedBy?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateComplianceItemRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
dueDate?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateComplianceItemRequest {
|
||||||
|
id: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
isCompliant?: boolean;
|
||||||
|
dueDate?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Issue {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
priority?: Priority;
|
||||||
|
status?: string;
|
||||||
|
reportedBy?: string;
|
||||||
|
resolvedAt?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateIssueRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
priority?: Priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateIssueRequest {
|
||||||
|
id: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
priority?: Priority;
|
||||||
|
status?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Milestone {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
dueDate?: string;
|
||||||
|
amount?: number;
|
||||||
|
status?: ApprovalStatus;
|
||||||
|
completionPercentage?: number;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateMilestoneRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
dueDate?: string;
|
||||||
|
amount?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateMilestoneRequest {
|
||||||
|
id: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
dueDate?: string;
|
||||||
|
amount?: number;
|
||||||
|
status?: ApprovalStatus;
|
||||||
|
completionPercentage?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Project {
|
||||||
|
id?: string | number;
|
||||||
|
programmeId?: string | number;
|
||||||
|
organisationId?: string | number;
|
||||||
|
name?: string;
|
||||||
|
code?: string;
|
||||||
|
description?: string;
|
||||||
|
type?: ProjectType;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
|
budget?: number;
|
||||||
|
status?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateProjectRequest {
|
||||||
|
programmeId: string | number;
|
||||||
|
organisationId: string | number;
|
||||||
|
name: string;
|
||||||
|
code?: string;
|
||||||
|
description?: string;
|
||||||
|
type?: ProjectType;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
|
budget?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateProjectRequest {
|
||||||
|
id: string | number;
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
budget?: number;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateProjectStatusRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
status: string | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SiteVisit {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
visitDate?: string;
|
||||||
|
visitorName?: string;
|
||||||
|
findings?: string;
|
||||||
|
recommendations?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateSiteVisitRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
visitDate: string;
|
||||||
|
visitorName: string;
|
||||||
|
findings?: string;
|
||||||
|
recommendations?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateSiteVisitRequest {
|
||||||
|
id: string | number;
|
||||||
|
visitDate?: string;
|
||||||
|
visitorName?: string;
|
||||||
|
findings?: string;
|
||||||
|
recommendations?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Award {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
amount?: number;
|
||||||
|
awardDate?: string;
|
||||||
|
conditions?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateAwardRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
amount: number;
|
||||||
|
awardDate?: string;
|
||||||
|
conditions?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Budget {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
category?: string;
|
||||||
|
allocatedAmount?: number;
|
||||||
|
spentAmount?: number;
|
||||||
|
notes?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateBudgetRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
category: string;
|
||||||
|
allocatedAmount: number;
|
||||||
|
notes?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateBudgetRequest {
|
||||||
|
id: string | number;
|
||||||
|
category?: string;
|
||||||
|
allocatedAmount?: number;
|
||||||
|
spentAmount?: number;
|
||||||
|
notes?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Contract {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
title?: string;
|
||||||
|
contractNumber?: string;
|
||||||
|
status?: ContractStatus;
|
||||||
|
signedDate?: string;
|
||||||
|
expiryDate?: string;
|
||||||
|
value?: number;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateContractRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
title: string;
|
||||||
|
contractNumber?: string;
|
||||||
|
signedDate?: string;
|
||||||
|
expiryDate?: string;
|
||||||
|
value?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateContractRequest {
|
||||||
|
id: string | number;
|
||||||
|
title?: string;
|
||||||
|
status?: ContractStatus;
|
||||||
|
expiryDate?: string;
|
||||||
|
value?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ExecuteContractRequest {
|
||||||
|
contractId: string | number;
|
||||||
|
executionDate: string;
|
||||||
|
notes?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Instrument {
|
||||||
|
id?: string | number;
|
||||||
|
programmeId?: string | number;
|
||||||
|
name?: string;
|
||||||
|
type?: string;
|
||||||
|
description?: string;
|
||||||
|
terms?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateInstrumentRequest {
|
||||||
|
programmeId: string | number;
|
||||||
|
name: string;
|
||||||
|
type?: string;
|
||||||
|
description?: string;
|
||||||
|
terms?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateInstrumentRequest {
|
||||||
|
id: string | number;
|
||||||
|
name?: string;
|
||||||
|
type?: string;
|
||||||
|
description?: string;
|
||||||
|
terms?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Organisation {
|
||||||
|
id?: string | number;
|
||||||
|
name?: string;
|
||||||
|
registrationNumber?: string;
|
||||||
|
type?: OrganisationType;
|
||||||
|
email?: string;
|
||||||
|
phone?: string;
|
||||||
|
address?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOrganisationRequest {
|
||||||
|
name: string;
|
||||||
|
registrationNumber?: string;
|
||||||
|
type?: OrganisationType;
|
||||||
|
email?: string;
|
||||||
|
phone?: string;
|
||||||
|
address?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOrganisationRequest {
|
||||||
|
id: string | number;
|
||||||
|
name?: string;
|
||||||
|
registrationNumber?: string;
|
||||||
|
type?: OrganisationType;
|
||||||
|
email?: string;
|
||||||
|
phone?: string;
|
||||||
|
address?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Portfolio {
|
||||||
|
id?: string | number;
|
||||||
|
organisationId?: string | number;
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
totalValue?: number;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreatePortfolioRequest {
|
||||||
|
organisationId: string | number;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdatePortfolioRequest {
|
||||||
|
id: string | number;
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Programme {
|
||||||
|
id?: string | number;
|
||||||
|
portfolioId?: string | number;
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
budget?: number;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateProgrammeRequest {
|
||||||
|
portfolioId: string | number;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
budget?: number;
|
||||||
|
startDate?: string;
|
||||||
|
endDate?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateProgrammeRequest {
|
||||||
|
id: string | number;
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
budget?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Tenant {
|
||||||
|
id?: string | number;
|
||||||
|
name?: string;
|
||||||
|
code?: string;
|
||||||
|
isActive?: boolean;
|
||||||
|
createdDate?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateTenantRequest {
|
||||||
|
name: string;
|
||||||
|
code?: string;
|
||||||
|
isActive?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateTenantRequest {
|
||||||
|
id: string | number;
|
||||||
|
name?: string;
|
||||||
|
code?: string;
|
||||||
|
isActive?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Dashboard {
|
||||||
|
totalProjects?: number;
|
||||||
|
totalCommittedCapital?: number;
|
||||||
|
totalDisbursedCapital?: number;
|
||||||
|
activeMilestonesCount?: number;
|
||||||
|
complianceRate?: number;
|
||||||
|
recentActivities?: any[];
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuditLog {
|
||||||
|
id?: string | number;
|
||||||
|
entityName?: string;
|
||||||
|
entityId?: string | number;
|
||||||
|
action?: string;
|
||||||
|
timestamp?: string;
|
||||||
|
performedBy?: string;
|
||||||
|
details?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Disbursement {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
milestoneId?: string | number;
|
||||||
|
amount?: number;
|
||||||
|
disbursementDate?: string;
|
||||||
|
status?: ApprovalStatus;
|
||||||
|
referenceNumber?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateDisbursementRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
milestoneId?: string | number;
|
||||||
|
amount: number;
|
||||||
|
referenceNumber?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateDisbursementRequest {
|
||||||
|
id: string | number;
|
||||||
|
amount?: number;
|
||||||
|
status?: ApprovalStatus;
|
||||||
|
referenceNumber?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Risk {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
likelihood?: RiskLikelihood;
|
||||||
|
impact?: RiskImpact;
|
||||||
|
mitigationPlan?: string;
|
||||||
|
status?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateRiskRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
likelihood?: RiskLikelihood;
|
||||||
|
impact?: RiskImpact;
|
||||||
|
mitigationPlan?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateRiskRequest {
|
||||||
|
id: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
likelihood?: RiskLikelihood;
|
||||||
|
impact?: RiskImpact;
|
||||||
|
mitigationPlan?: string;
|
||||||
|
status?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Rule {
|
||||||
|
id?: string | number;
|
||||||
|
programmeId?: string | number;
|
||||||
|
name?: string;
|
||||||
|
expression?: string;
|
||||||
|
description?: string;
|
||||||
|
isActive?: boolean;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateRuleRequest {
|
||||||
|
programmeId: string | number;
|
||||||
|
name: string;
|
||||||
|
expression: string;
|
||||||
|
description?: string;
|
||||||
|
isActive?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateRuleRequest {
|
||||||
|
id: string | number;
|
||||||
|
name?: string;
|
||||||
|
expression?: string;
|
||||||
|
description?: string;
|
||||||
|
isActive?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Evidence {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
milestoneId?: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
type?: EvidenceType;
|
||||||
|
fileUrl?: string;
|
||||||
|
fileName?: string;
|
||||||
|
fileSize?: number;
|
||||||
|
uploadedAt?: string;
|
||||||
|
verified?: boolean;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateEvidenceRequest {
|
||||||
|
id: string | number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
type?: EvidenceType;
|
||||||
|
verified?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Indicator {
|
||||||
|
id?: string | number;
|
||||||
|
projectId?: string | number;
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
targetValue?: number;
|
||||||
|
actualValue?: number;
|
||||||
|
unit?: UnitOfMeasure;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateIndicatorRequest {
|
||||||
|
projectId: string | number;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
targetValue: number;
|
||||||
|
unit?: UnitOfMeasure;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Invite {
|
||||||
|
id?: string | number;
|
||||||
|
email?: string;
|
||||||
|
role?: string;
|
||||||
|
organisationId?: string | number;
|
||||||
|
status?: string;
|
||||||
|
expiresAt?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InviteRequest {
|
||||||
|
email: string;
|
||||||
|
role?: string;
|
||||||
|
organisationId?: string | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Notification {
|
||||||
|
id?: string | number;
|
||||||
|
organisationId?: string | number;
|
||||||
|
platform?: NotificationPlatform;
|
||||||
|
status?: NotificationStatus;
|
||||||
|
message?: string;
|
||||||
|
recipient?: string;
|
||||||
|
sentAt?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user