Updated api usage, corrected table designs
This commit is contained in:
@@ -1531,8 +1531,20 @@ export const updateTenant = async (payload: UpdateTenantRequest): Promise<void>
|
||||
// ==========================================
|
||||
export const getProjectBeneficiaries = async (projectId: string | number): Promise<Beneficiary[]> => {
|
||||
const hashedProjectId = await toolsService.resolveProjectId(projectId);
|
||||
const res = await apiClient.get<Beneficiary[]>(`/v1/api/projects/beneficiaries/${hashedProjectId}`);
|
||||
return res.data || [];
|
||||
try {
|
||||
const res = await apiClient.get<Beneficiary[]>(`/v1/api/projects/${hashedProjectId}/beneficiaries`);
|
||||
return res.data || [];
|
||||
} catch (err: any) {
|
||||
if (String(projectId) !== String(hashedProjectId)) {
|
||||
try {
|
||||
const fallbackRes = await apiClient.get<Beneficiary[]>(`/v1/api/projects/${projectId}/beneficiaries`);
|
||||
return fallbackRes.data || [];
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
export const getBeneficiary = async (beneficiaryId: string | number): Promise<Beneficiary> => {
|
||||
@@ -1605,8 +1617,20 @@ export const updateOutcome = async (payload: UpdateOutcomeRequest): Promise<void
|
||||
// ==========================================
|
||||
export const getProjectChangeRequests = async (projectId: string | number): Promise<ChangeRequest[]> => {
|
||||
const hashedProjectId = await toolsService.resolveProjectId(projectId);
|
||||
const res = await apiClient.get<ChangeRequest[]>(`/v1/api/projects/changerequests/${hashedProjectId}`);
|
||||
return res.data || [];
|
||||
try {
|
||||
const res = await apiClient.get<ChangeRequest[]>(`/v1/api/projects/${hashedProjectId}/changerequests`);
|
||||
return res.data || [];
|
||||
} catch (err: any) {
|
||||
if (String(projectId) !== String(hashedProjectId)) {
|
||||
try {
|
||||
const fallbackRes = await apiClient.get<ChangeRequest[]>(`/v1/api/projects/${projectId}/changerequests`);
|
||||
return fallbackRes.data || [];
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
export const getChangeRequest = async (changeRequestId: string | number): Promise<ChangeRequest> => {
|
||||
@@ -1676,8 +1700,20 @@ export const updateComplianceItem = async (payload: UpdateComplianceItemRequest)
|
||||
// ==========================================
|
||||
export const getProjectIssues = async (projectId: string | number): Promise<Issue[]> => {
|
||||
const hashedProjectId = await toolsService.resolveProjectId(projectId);
|
||||
const res = await apiClient.get<Issue[]>(`/v1/api/projects/issues/${hashedProjectId}`);
|
||||
return res.data || [];
|
||||
try {
|
||||
const res = await apiClient.get<Issue[]>(`/v1/api/projects/${hashedProjectId}/issues`);
|
||||
return res.data || [];
|
||||
} catch (err: any) {
|
||||
if (String(projectId) !== String(hashedProjectId)) {
|
||||
try {
|
||||
const fallbackRes = await apiClient.get<Issue[]>(`/v1/api/projects/${projectId}/issues`);
|
||||
return fallbackRes.data || [];
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
export const getIssue = async (issueId: string | number): Promise<Issue> => {
|
||||
@@ -1718,8 +1754,20 @@ export const updateIssue = async (payload: UpdateIssueRequest): Promise<void> =>
|
||||
// ==========================================
|
||||
export const getProjectSiteVisits = async (projectId: string | number): Promise<SiteVisit[]> => {
|
||||
const hashedProjectId = await toolsService.resolveProjectId(projectId);
|
||||
const res = await apiClient.get<SiteVisit[]>(`/v1/api/projects/sitevisits/${hashedProjectId}`);
|
||||
return res.data || [];
|
||||
try {
|
||||
const res = await apiClient.get<SiteVisit[]>(`/v1/api/projects/${hashedProjectId}/sitevisits`);
|
||||
return res.data || [];
|
||||
} catch (err: any) {
|
||||
if (String(projectId) !== String(hashedProjectId)) {
|
||||
try {
|
||||
const fallbackRes = await apiClient.get<SiteVisit[]>(`/v1/api/projects/${projectId}/sitevisits`);
|
||||
return fallbackRes.data || [];
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
export const getSiteVisit = async (siteVisitId: string | number): Promise<SiteVisit> => {
|
||||
|
||||
Reference in New Issue
Block a user