This commit is contained in:
pfych 2024-10-12 14:08:09 +11:00
commit 0029086b3f
148 changed files with 19047 additions and 0 deletions

View file

@ -0,0 +1,61 @@
import { Admin } from '@baseline/types/admin';
import { RequestHandler } from './request-handler';
export const getAllAdmins = async (
requestHandler: RequestHandler,
): Promise<Admin[]> => {
const response = await requestHandler.request<Admin[]>({
method: 'GET',
url: `admin/list`,
hasAuthentication: true,
});
if ('data' in response) {
return response.data;
}
throw response;
};
export const deleteAdmin = async (
requestHandler: RequestHandler,
data: { adminId: string },
): Promise<boolean> => {
const response = await requestHandler.request<boolean>({
method: 'DELETE',
url: `admin/${data.adminId}`,
hasAuthentication: true,
});
if ('data' in response) {
return response.data;
}
throw response;
};
export const createAdmin = async (
requestHandler: RequestHandler,
data: { userEmail: string },
): Promise<Admin> => {
const response = await requestHandler.request<Admin>({
method: 'POST',
url: `admin`,
hasAuthentication: true,
data,
});
if ('data' in response) {
return response.data;
}
throw response;
};
export const checkAdmin = async (
requestHandler: RequestHandler,
): Promise<boolean> => {
const response = await requestHandler.request<Admin>({
method: 'GET',
url: `admin`,
hasAuthentication: true,
});
if ('data' in response) {
return !!response.data.userSub;
}
return false;
};