Fixed beneficiary outcomes misconfiguration

This commit is contained in:
2026-10-22 17:08:01 +02:00
parent 3fda1ac5db
commit d45a89ab67
10 changed files with 955 additions and 314 deletions
File diff suppressed because it is too large Load Diff
@@ -1743,14 +1743,41 @@ export const updateBeneficiary = async (payload: UpdateBeneficiaryRequest): Prom
export const getOutcome = async (outcomeId: string | number): Promise<Outcome> => {
const hashedOutcomeId = await toolsService.encodeId(outcomeId);
const res = await apiClient.get<Outcome>(`/v1/api/projects/outcomes/${hashedOutcomeId}`);
return res.data;
try {
const res = await apiClient.get<Outcome>(`/v1/api/projects/outcome/${hashedOutcomeId}`);
return res.data;
} catch {
const res = await apiClient.get<Outcome>(`/v1/api/projects/outcomes/single/${hashedOutcomeId}`);
return res.data;
}
};
export const getBeneficiaryOutcomes = async (beneficiaryId: string | number): Promise<Outcome[]> => {
const hashedBeneficiaryId = await toolsService.encodeId(beneficiaryId);
const res = await apiClient.get<Outcome[]>(`/v1/api/projects/outcomes/${hashedBeneficiaryId}`);
return res.data || [];
try {
const res = await apiClient.get<Outcome[]>(`/v1/api/projects/beneficiaries/${hashedBeneficiaryId}/outcomes`);
return Array.isArray(res.data) ? res.data : (res.data ? [res.data] : []);
} catch (err: any) {
if (err?.response?.status === 404) {
try {
const res = await apiClient.get<Outcome[]>(`/v1/api/projects/outcomes/${hashedBeneficiaryId}`);
return Array.isArray(res.data) ? res.data : (res.data ? [res.data] : []);
} catch {
return [];
}
}
return [];
}
};
export const getProjectOutcomes = async (projectId: string | number): Promise<Outcome[]> => {
const hashedProjectId = await toolsService.resolveProjectId(projectId);
try {
const res = await apiClient.get<Outcome[]>(`/v1/api/projects/${hashedProjectId}/outcomes`);
return Array.isArray(res.data) ? res.data : [];
} catch {
return [];
}
};
export const createOutcome = async (payload: CreateOutcomeRequest): Promise<void> => {
@@ -1761,10 +1788,10 @@ export const createOutcome = async (payload: CreateOutcomeRequest): Promise<void
status: payload.status !== undefined ? Number(payload.status) : 1,
};
try {
await apiClient.post('/v1/api/projects/beneficiaris/outcomes', body);
await apiClient.post('/v1/api/projects/beneficiaries/outcomes', body);
} catch (err: any) {
if (err?.response?.status === 404) {
await apiClient.post('/v1/api/projects/beneficiaries/outcomes', body);
await apiClient.post('/v1/api/projects/beneficiaris/outcomes', body);
} else {
throw err;
}