const host = "https://hi-po.com.cn";

export async function fetchConsultants() {
  const formData = new FormData();
  formData.append("page", "1");
  formData.append("size", "100");

  const result = await fetch(`${host}/api/v1/cms/listConsultant`, {
    method: "POST",
    body: formData,
  });
  const json = await result.json();
  return json;
}

export async function fetchConsultantDetail(id: number) {
  const formData = new FormData();
  formData.append("id", id.toString());

  const result = await fetch(`${host}/api/v1/cms/consultantDetail`, {
    method: "POST",
    body: formData,
  });
  const json = await result.json();
  return json;
}

export async function fetchArticleList(type: number, page: number, size: number) {
  const formData = new FormData();
  formData.append("type", type.toString());
  formData.append("page", page.toString());
  formData.append("size", size.toString());

  const result = await fetch(`${host}/api/v1/cms/listArticle`, {
    method: "POST",
    body: formData,
    cache: "no-store",
  });
  const json = await result.json();
  return json;
}

export async function fetchArticleDetail(id: number) {
  const formData = new FormData();
  formData.append("id", id.toString());

  const result = await fetch(`${host}/api/v1/cms/articleDetail`, {
    method: "POST",
    body: formData,
  });
  const json = await result.json();
  return json;
}

export async function fetchServiceProducts() {
  const formData = new FormData();
  formData.append("page", "1");
  formData.append("size", "100");

  const result = await fetch(`${host}/api/v1/cms/listServiceProduct`, {
    method: "POST",
    body: formData,
  });
  const json = await result.json();
  return json;
}

export async function fetchCustomers() {
  const formData = new FormData();
  formData.append("page", "1");
  formData.append("size", "100");

  const result = await fetch(`${host}/api/v1/cms/listCustomer`, {
    method: "POST",
    body: formData,
  });
  const json = await result.json();
  return json;
}

export async function fetchVideos() {
  const formData = new FormData();
  formData.append("page", "1");
  formData.append("size", "100");

  const result = await fetch(`${host}/api/v1/cms/listVideo`, {
    method: "POST",
    body: formData,
  });
  const json = await result.json();
  return json;
}
