import { config, networkUtils } from '../../utils';

const { request } = networkUtils;
const { api } = config;
const { basic } = api;

export async function login(data) {
  const formData = new FormData();
  formData.append('ent_code', data.ent_code);
  formData.append('login_no', data.login_no);
  formData.append('password', data.password);
  formData.append('captcha', data.captcha);

  return request({
    url: basic.userLogin,
    method: 'form',
    data: formData,
  });
}

export async function logout(data) {
  return request({
    url: basic.userLogin,
    method: 'post',
    data,
  });
}

export async function getCaptcha() {
  return request({
    url: basic.captcha,
    method: 'get',
  });
}

export async function getPrincipal() {
  return request({
    url: basic.principal,
    method: 'get',
  });
}

