//@ts-nocheck
import { action, observable } from 'mobx';
import { Alert } from 'react-native';
import { Api } from '../../services/api';

class Store {
  @observable verify = null;

  @action
  async checkQualify(loanId, onSuccess?, onFailed?) {
    try {
      const response = await Api.getInstance().checkQualifyLoanbriefId(loanId);
      console.log(response);

      if (response.kind === 'ok') {
        if (response.data.meta.errorCode === 200) {
          if (onSuccess) onSuccess(response.data.data);
        } else {
          if (onFailed) onFailed();
        }
      } else {
        if (onFailed) onFailed();
      }
    } catch (error) {
      console.log(error);
    }
  }

  @action
  async postQualify(body, onSuccess?, onFailed?) {
    try {
      const response = await Api.getInstance().postQualifyLoanbriefId(body);
      console.log(response);
      if (response.kind === 'ok') {
        if (response.data.meta.errorCode === 200) {
          if (onSuccess) onSuccess(response.data.data);
        } else {
          if (onFailed) onFailed();
        }
      } else {
        if (onFailed) onFailed();
      }
    } catch (error) {
      console.log(error);
    }
  }
}

const qualifyStore = new Store();
export default qualifyStore;
