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

type AddContactParam = {
  name?: string;
  company?: string;
  email?: string;
  userRemark?: string;
  position?: string;
  phone?: string;
  area?: string;
  city?: string;
};

export async function addContact(params: AddContactParam) {
  const formData = new FormData();
  Object.keys(params).forEach((key) => {
    const value = params[key as keyof AddContactParam];
    if (value !== undefined && value !== null) {
      formData.append(key, value.toString());
    }
  });

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