fixes
This commit is contained in:
@@ -16,6 +16,8 @@ import {
|
||||
|
||||
export const ADMIN_USERS_PATH = "/api/admin/users";
|
||||
export const ADMIN_COMPANIES_PATH = "/api/admin/companies";
|
||||
export const ADMIN_CLONE_CATALOG_PATH = (companyId: string) =>
|
||||
`${ADMIN_COMPANIES_PATH}/${encodeURIComponent(companyId)}/clone-catalog`;
|
||||
export const ADMIN_STAFF_ROLE_PATH = (userId: string) =>
|
||||
`/api/admin/users/${encodeURIComponent(userId)}/staff-role`;
|
||||
|
||||
@@ -201,6 +203,28 @@ export async function setAdminStaffRole(
|
||||
return res.user;
|
||||
}
|
||||
|
||||
export type CloneCatalogResult = {
|
||||
status: string;
|
||||
source_company_id: string;
|
||||
dest_company_id: string;
|
||||
counts: Record<string, number>;
|
||||
};
|
||||
|
||||
/** Copy source company catalog into the admin sandbox (home / dest). Source is unchanged. */
|
||||
export async function cloneAdminCompanyCatalog(
|
||||
sourceCompanyId: string,
|
||||
opts?: { destCompanyId?: string }
|
||||
): Promise<CloneCatalogResult> {
|
||||
const body: { confirm: true; dest_company_id?: string } = { confirm: true };
|
||||
if (opts?.destCompanyId?.trim()) {
|
||||
body.dest_company_id = opts.destCompanyId.trim();
|
||||
}
|
||||
return api<CloneCatalogResult>(ADMIN_CLONE_CATALOG_PATH(sourceCompanyId), {
|
||||
method: "POST",
|
||||
body
|
||||
});
|
||||
}
|
||||
|
||||
export function isStaffRoleApiUnavailable(err: unknown): boolean {
|
||||
return err instanceof ApiError && (err.status === 404 || err.status === 501);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user