import { connect } from 'herculex';
import { getIn } from 'herculex/dist/utils/manipulate';

Component(connect({
  mapStateToProps: {},
})({
  data: {
    show: true,
  },
  methods: {
    onSubmit(e) {
      const formId = getIn(e, ['detail', 'formId'], '');
      this.commit('$global:updateState', { formId });
    },
    async onGetAuthorize() {
      this.dispatch('loginTriggerFn');
      this.dispatch('closeLoginModal');
    },
    onCancel() {
      /* 失败 */
      this.dispatch('loginTriggerRejectFn');
      this.dispatch('closeLoginModal');
    },
    onAuthError() {
      /* 失败 */
      this.dispatch('loginTriggerRejectFn');
      this.dispatch('closeLoginModal');
    },
  },
}));
