import axios from "@/config/axios";
import type {
  CreateThemeType,
  GetThemesResponseType,
  GetThemeByIdResponseType,
  GetThemeValuesResponseType,
  CreateThemeValueType,
  UpdateThemeValueType,
} 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;
};

export const getThemeValues = async (
  id: string
): Promise<GetThemeValuesResponseType> => {
  const { data } = await axios.get<GetThemeValuesResponseType>(
    `/admin/category/theme-value/${id}/values`
  );
  return data;
};

export const createThemeValue = async (params: CreateThemeValueType) => {
  const { data } = await axios.post(`/admin/category/theme-value`, params);
  return data;
};

export const updateThemeValue = async (
  id: string,
  params: UpdateThemeValueType
) => {
  const { data } = await axios.put(`/admin/category/theme-value/${id}`, params);
  return data;
};

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