Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
46 lines
2.0 KiB
TypeScript
46 lines
2.0 KiB
TypeScript
import { apiGet, apiPost, apiPut } from "@/app/lib/clientApi";
|
|
import type {
|
|
CompanyAccountCreatePayload,
|
|
CompanyAccountCreateResult,
|
|
CompanyAccountRow,
|
|
CompanyAccountUpdatePayload,
|
|
} from "@/app/lib/types";
|
|
|
|
// Client over the BFF route handlers (app/api/admin/company-accounts/**), which forward the
|
|
// bb_admin JWT to mobile-api. Company/HQ accounts receive referral-less registrations for a
|
|
// country (prefix); create/edit/deactivate/reactivate are all mutations and always go out on
|
|
// POST/PUT, never a GET (Next.js prefetch rule).
|
|
|
|
/** The company accounts configured for one registration country (prefix, e.g. "MY"). */
|
|
export async function listCompanyAccounts(prefix: string): Promise<CompanyAccountRow[]> {
|
|
return apiGet<CompanyAccountRow[]>(`/api/admin/company-accounts/${encodeURIComponent(prefix)}`);
|
|
}
|
|
|
|
/** Create: member + tree placement + allocation weight (+ optional login) in one action. */
|
|
export async function createCompanyAccount(
|
|
payload: CompanyAccountCreatePayload,
|
|
): Promise<CompanyAccountCreateResult> {
|
|
return apiPost<CompanyAccountCreateResult>("/api/admin/company-accounts", payload);
|
|
}
|
|
|
|
/** Edit weight/active/name. `prefix`/`memberCode` locate the row and are never themselves edited. */
|
|
export async function updateCompanyAccount(
|
|
payload: CompanyAccountUpdatePayload,
|
|
): Promise<CompanyAccountRow> {
|
|
return apiPut<CompanyAccountRow>("/api/admin/company-accounts", payload);
|
|
}
|
|
|
|
/** Drops the account from the weighted split; the member, its tree row and downline are untouched. */
|
|
export async function deactivateCompanyAccount(prefix: string, memberCode: string): Promise<void> {
|
|
await apiPost<void>(
|
|
`/api/admin/company-accounts/${encodeURIComponent(prefix)}/${encodeURIComponent(memberCode)}/deactivate`,
|
|
);
|
|
}
|
|
|
|
/** Restores the account to the weighted split. */
|
|
export async function reactivateCompanyAccount(prefix: string, memberCode: string): Promise<void> {
|
|
await apiPost<void>(
|
|
`/api/admin/company-accounts/${encodeURIComponent(prefix)}/${encodeURIComponent(memberCode)}/reactivate`,
|
|
);
|
|
}
|