import {
  okOptions
} from '../../settings/ok';

export class IntroOptionController {
  constructor($http, $log, $state, toastr, globalVar, $scope, introService) {
    'ngInject';

    this.$http = $http;
    this.$log = $log;
    this.$state = $state;
    this.toastr = toastr;
    this.globalVar = globalVar;
    this.$scope = $scope;
    this.introService = introService;
    this.okOptions = okOptions;

    this.$onInit = this.onInit.bind(this);
    this.$onChanges = this.onChanges.bind(this);
  }

  onInit() {
  }

  onChanges(changes) {
    if (changes) {

    }
  }

  goToOrderMenuPage() {
    window.location.href = this.globalVar.TASTY_URL + '#/order/menu?showIntro=finish';
  }

  goToMemberCardCreatePage() {
    window.location.href = this.globalVar.VOUCHER_URL + '#/membercard/create?showIntro=finish';
  }

  goToCouponActivity() {
    _laq.push(['send', 'click', 'btn-type', 'help-index-coupon-btn']);

    this.closeModal('reopen');
    this.introService.openModal('introCouponActivity', 'modal-650');
  }

  introOldStager() {
    _laq.push(['send', 'click', 'btn-type', 'help-index-oldman-btn']);

    this.closeModal('reopen');
    this.introService.openModal('introOldStager', 'modal-650');
  }

  introLookAround() {
    _laq.push(['send', 'click', 'btn-type', 'help-index-look-btn']);

    this.closeModal('reopen');
    this.introService.openModal('introLookAround', 'modal-650');
  }

  closeModal(value) {
    if (this.modalInstance) {
      return this.modalInstance.close({
        $value: value
      });
    }
  }
}

export const introOptionComponent = {
  bindings: {
    // For uibModal
    resolve: '<',
    modalInstance: '<',
    close: '&',
    dismiss: '&'
  },
  templateUrl: 'app/modules/intros/components/intro-option/intro-option.html',
  controller: IntroOptionController
};