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/admins", params);
  return data;
};

export const updateAdmin = async (id: string, params: CreateAdminType) => {
  const { data } = await axios.patch(`/admin/admins/${id}`, params);
  return data;
};

export const getAdminById = async (
  adminId: string
): Promise<GetAdminByIdResponse> => {
  const { data } = await axios.get<GetAdminByIdResponse>(
    `/admin/admins/${adminId}`
  );
  return data;
};
