import { getUserCookie } from './userApi';
import request from '../request';
// 场景模块

// 获取场景列表
export const getScenesList = (id: number, type: string) => {
  if (type == 'parent') {
    return request.get(`/api/scenarios`, {
      params: {
        parent_id: id,
      },
      headers: {
        authorization: `Bearer ${getUserCookie()}`,
      },
    });
  }
  const url = id ? `/api/scenarios/${id}` : `/api/scenarios`;
  return request.get(url, {
    headers: {
      authorization: `Bearer ${getUserCookie()}`,
    },
  });
};

// 获取场景推荐列表
export const getScenariosRecommend = () => {
  return request.get('/api/scenarios/recommend', {
    headers: {
      authorization: `Bearer ${getUserCookie()}`,
    },
  });
};

// 文案提交
export const useSubmitConversation = (data: any) => {
  return request.post('/api/users/conversation', data, {
    headers: {
      authorization: `Bearer ${getUserCookie()}`,
    },
  });
};

// 图片任务提交
export const useSubmitConversationImage = (data: any) => {
  return request.post('/api/users/conversation/image', data, {
    headers: {
      authorization: `Bearer ${getUserCookie()}`,
    },
  });
};

// 图片任务回调
export const useImageCallback = (data: any) => {
  return request.get('/api/users/conversation/image', {
    params: data,
    headers: {
      authorization: `Bearer ${getUserCookie()}`,
    },
  });
};

// 获取上传策略
export const useUploadStrategy = () => {
  return request.get('/api/users/upload/policy', {
    headers: {
      authorization: `Bearer ${getUserCookie()}`,
    },
  });
};

// 获取生成记录
export const getGenerateRecords = (data: any) => {
  return request.get('/api/users/scenarios/logs', {
    params: data,
    headers: {
      authorization: `Bearer ${getUserCookie()}`,
    },
  });
};

// 搜索关键词
export const useSearch = (data: any) => {
  return request.post('/api/users/content/search', data, {
    headers: {
      authorization: `Bearer ${getUserCookie()}`,
    },
  });
};
