import axios from "@/config/axios";
import type {
  CreateThemeType,
  GetThemesResponseType,
  GetThemeByIdResponseType,
} from "../type/Types";

export const getThemes = async (): Promise<GetThemesResponseType> => {
  const { data } = await axios.get<GetThemesResponseType>(
    "/admin/category/theme"
  );
  return data;
};

export const createTheme = async (params: CreateThemeType) => {
  const { data } = await axios.post("/admin/category/theme", params);
  return data;
};

export const getThemeById = async (
  id: string
): Promise<GetThemeByIdResponseType> => {
  const { data } = await axios.get<GetThemeByIdResponseType>(
    `/admin/category/theme/${id}`
  );
  return data;
};

export const updateTheme = async (id: string, params: CreateThemeType) => {
  const { data } = await axios.put(`/admin/category/theme`, {
    themeId: id,
    ...params,
  });
  return data;
};

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