import http from '@/utils/http';
import { Inviters, CommunityBasic } from '@/types/common';

export async function getCommunityBasic(): Promise<CommunityBasic> {
  const {
    ok,
    data,
    msg,
  } = await http.get<CommunityBasic>('/community/basic');
  if (ok && data) {
    return data;
  }
  throw Error(msg);
}

export async function getCommunityList(pageIndex: number, pageSize: number): Promise<Inviters> {
  const {
    ok,
    data,
    msg,
  } = await http.get<Inviters>('/community/list', {
    pageIndex,
    pageSize,
  });
  if (ok && data) {
    return data;
  }
  throw Error(msg);
}
