Fixed mismatched endpoint calling

This commit is contained in:
2026-09-27 14:07:44 +02:00
parent 8afceda1cd
commit df167caf55
4 changed files with 599 additions and 81 deletions
@@ -24,11 +24,13 @@ import {
import {
getProjects,
getProjectBeneficiaries,
getBeneficiary,
createBeneficiary,
updateBeneficiary,
getBeneficiaryOutcomes,
createOutcome,
getProjectComplianceItems,
getComplianceItem,
createComplianceItem,
updateComplianceItem,
} from '../services/api';
@@ -288,26 +290,50 @@ export const BeneficiariesPage: React.FC = () => {
{ header: 'Status', key: 'status', format: (val) => (val === ApprovalStatus.Approved ? 'Approved' : 'Pending Review') },
];
const handleOpenEditBen = (b: Beneficiary) => {
setEditingBen(b);
benForm.reset({
name: b.name || '',
category: b.category || 'General',
location: b.location || '',
targetCount: b.targetCount || 0,
reachedCount: b.reachedCount || 0,
});
setIsBenModalOpen(true);
const handleOpenEditBen = async (b: Beneficiary) => {
try {
const fresh = await getBeneficiary(b.id);
setEditingBen(fresh);
benForm.reset({
name: fresh.name || '',
category: fresh.category || 'General',
location: fresh.location || '',
targetCount: fresh.targetCount || 0,
reachedCount: fresh.reachedCount || 0,
});
setIsBenModalOpen(true);
} catch {
setEditingBen(b);
benForm.reset({
name: b.name || '',
category: b.category || 'General',
location: b.location || '',
targetCount: b.targetCount || 0,
reachedCount: b.reachedCount || 0,
});
setIsBenModalOpen(true);
}
};
const handleOpenEditComp = (c: ComplianceItem) => {
setEditingComp(c);
compForm.reset({
title: c.title || '',
requirements: c.requirements || '',
status: c.status ?? ApprovalStatus.Pending,
});
setIsCompModalOpen(true);
const handleOpenEditComp = async (c: ComplianceItem) => {
try {
const fresh = await getComplianceItem(c.id);
setEditingComp(fresh);
compForm.reset({
title: fresh.title || '',
requirements: fresh.requirements || '',
status: fresh.status ?? ApprovalStatus.Pending,
});
setIsCompModalOpen(true);
} catch {
setEditingComp(c);
compForm.reset({
title: c.title || '',
requirements: c.requirements || '',
status: c.status ?? ApprovalStatus.Pending,
});
setIsCompModalOpen(true);
}
};
return (