import { ThemeType } from 'models/theme.types';
import { request } from 'utils/fetch';
import { api } from 'constants/config';
/**
 * @description 根据主题名、配置项、type添加主题
 * @param name
 * @param config
 * @returns {boolean}
 */
export const addThemeByNameAndConfig = async ({
  name,
  config,
  type
}: {
  name: ThemeType['name'];
  config: ThemeType['config'];
  type: ThemeType['type'];
}) => {
  return await request(api.addThemeByNameAndConfig, undefined, undefined, JSON.stringify({ name, config, type }));
};

/**
 * @description 根据ids删除主题
 * @param ids
 * @returns {boolean}
 */
export const deleteThemeByIdList = async (ids: number) => {
  const res = await request(`${api.deleteThemeByIdList}/${ids}`);
  return res;
};

/**
 * 更新主题配置
 * @param param0
 * @returns
 */
export const updateThemeById = async (data: ThemeType) => {
  const { id, name, config, type } = data;
  return await request(`${api.updateThemeById}/${id}`, undefined, undefined, JSON.stringify({ name, config, type }));
};
