import axios from "@/config/axios";
import type { CreateRoleType, GetRolesResponseType } from "../types/Types";

export type GetRolesParams = {
  page?: number;
  limit?: number;
  search?: string;
};

export const getRoles = async (
  params?: GetRolesParams
): Promise<GetRolesResponseType> => {
  const { data } = await axios.get<GetRolesResponseType>("/admin/roles", {
    params,
  });
  return data;
};

export const createRole = async (params: CreateRoleType) => {
  const { data } = await axios.post("/admin/roles", params);
  return data;
};

export const deleteRole = async (id: string) => {
  const { data } = await axios.delete(`/admin/roles/${id}`);
  return data;
};
