Fine tuned organisation onboarding and tenant management
This commit is contained in:
@@ -64,6 +64,7 @@ import {
|
||||
ProblemDetails,
|
||||
ActivityStatus,
|
||||
Tenant,
|
||||
TenantOrganisation,
|
||||
CreateTenantRequest,
|
||||
UpdateTenantRequest,
|
||||
Beneficiary,
|
||||
@@ -180,6 +181,7 @@ export const normalizeOrganisation = (raw: any): Organisation => {
|
||||
name: raw.name ?? raw.Name ?? null,
|
||||
registrationNo: raw.registrationNo ?? raw.RegistrationNo ?? raw.regNo ?? raw.RegNo ?? null,
|
||||
email: raw.email ?? raw.Email ?? null,
|
||||
userId: raw.userId ?? raw.UserId ?? raw.organisationUser ?? raw.OrganisationUser ?? null,
|
||||
type: raw.type ?? raw.Type ?? raw.organisationType ?? raw.OrganisationType ?? 5,
|
||||
status,
|
||||
createdAt: raw.createdAt ?? raw.CreatedAt ?? new Date().toISOString(),
|
||||
@@ -214,6 +216,8 @@ export const createOrganisation = async (payload: CreateOrganisationRequest): Pr
|
||||
name: payload.name,
|
||||
registrationNo: payload.registrationNo,
|
||||
email: payload.email,
|
||||
idNumber: payload.idNumber,
|
||||
organisationUser: payload.organisationUser,
|
||||
type: payload.type !== undefined ? Number(payload.type) : 5,
|
||||
});
|
||||
return res.data;
|
||||
@@ -225,6 +229,8 @@ export const updateOrganisation = async (payload: UpdateOrganisationRequest): Pr
|
||||
name: payload.name,
|
||||
registrationNo: payload.registrationNo,
|
||||
email: payload.email,
|
||||
idNumber: payload.idNumber,
|
||||
organisationUser: payload.organisationUser,
|
||||
type: Number(payload.type),
|
||||
status: payload.status !== undefined ? Number(payload.status) : ActivityStatus.Active,
|
||||
});
|
||||
@@ -1527,6 +1533,26 @@ export const updateTenant = async (payload: UpdateTenantRequest): Promise<void>
|
||||
});
|
||||
};
|
||||
|
||||
export const getTenantOrganisations = async (tenantId: string | number): Promise<TenantOrganisation[]> => {
|
||||
const hashedTenantId = await toolsService.encodeId(tenantId);
|
||||
try {
|
||||
const res = await apiClient.get<TenantOrganisation[]>(
|
||||
`/v1/api/governance/tenants/${encodeURIComponent(hashedTenantId)}/organisations`
|
||||
);
|
||||
return res.data || [];
|
||||
} catch (err: any) {
|
||||
if (String(tenantId) !== String(hashedTenantId)) {
|
||||
try {
|
||||
const fallbackRes = await apiClient.get<TenantOrganisation[]>(
|
||||
`/v1/api/governance/tenants/${encodeURIComponent(String(tenantId))}/organisations`
|
||||
);
|
||||
return fallbackRes.data || [];
|
||||
} catch {}
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
// ==========================================
|
||||
// 10. Projects: Beneficiaries & Outcomes APIs
|
||||
// ==========================================
|
||||
|
||||
Reference in New Issue
Block a user