39 lines
980 B
TypeScript
39 lines
980 B
TypeScript
import axios from "@/config/axios";
|
|
import type {
|
|
GetAdminsResponse,
|
|
GetAdminsParams,
|
|
CreateAdminType,
|
|
GetAdminByIdResponse,
|
|
} from "../types/Types";
|
|
|
|
export const getAdmins = async (
|
|
params?: GetAdminsParams
|
|
): Promise<GetAdminsResponse> => {
|
|
const { data } = await axios.get<GetAdminsResponse>("/admin/admins", {
|
|
params,
|
|
});
|
|
return data;
|
|
};
|
|
|
|
export const deleteAdmin = async (id: string) => {
|
|
const { data } = await axios.delete(`/admin/admins/${id}`);
|
|
return data;
|
|
};
|
|
|
|
export const createAdmin = async (params: CreateAdminType) => {
|
|
const { data } = await axios.post("/admin", params);
|
|
return data;
|
|
};
|
|
|
|
export const updateAdmin = async (id: string, params: CreateAdminType) => {
|
|
const { data } = await axios.patch(`/admin/${id}`, params);
|
|
return data;
|
|
};
|
|
|
|
export const getAdminById = async (
|
|
adminId: string
|
|
): Promise<GetAdminByIdResponse> => {
|
|
const { data } = await axios.get<GetAdminByIdResponse>(`/admin/${adminId}`);
|
|
return data;
|
|
};
|