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

Component(connect({
  mapStateToProps: {
  },
})({
  props: {
    serviceList: [],
    imgSrcPrefix: '',
  },
  methods: {
    onSubmit(e) {
      const item = getIn(e, ['buttonTarget', 'dataset', 'item'], {});
      const formId = getIn(e, ['detail', 'formId'], '');

      this.commit('$global:updateFormId', {
        formId,
      });
      if (item.accessMode === 'customer' && item.from !== 'webview') {
        const customerCheckInPage = this.dispatch.bind(this, 'customerCheck');
        return navigateTo.call(this, {
          ...item,
          customerCheckInPage,
          isToService: true,
        });
      }
      navigateTo.call(this, {
        ...item,
        isToService: true,
      });
    },
  },
}));
