import { editorRequest } from '@/lib/client';
import { LikeObjectParamsType, SignInListType } from './type';

export async function fetchCharacters({ index, limit, query }: any) {
  const { data } = await editorRequest('/api/character/list', {
    method: 'POST',
    data: { index, limit, ...query },
  });
  return data;
}

export async function fetchCharacter(params: any) {
  const { data } = await editorRequest('/api/character/detail', { method: 'POST', data: params });
  return data;
}

export async function fetchCharacterTags(params: any = {}) {
  return editorRequest('/api/tag/list', { method: 'POST', data: params });
}

export async function thmubObject(params: LikeObjectParamsType) {
  return editorRequest('/api/like/likeOrCancel', { method: 'POST', data: params });
}

export async function getLikeStatus(params: Pick<LikeObjectParamsType, 'objectId' | 'userId'>) {
  return editorRequest('/api/like/getLikeStatus', { method: 'POST', data: params });
}

export async function getSevenDaysSignList(params: any = {}): Promise<SignInListType> {
  const { data } = await editorRequest('/api/sign/list', { method: 'POST', data: params });
  return data;
}

export async function signIn(params: any = {}) {
  return editorRequest('/api/sign/asi', { method: 'POST', data: params });
}
