<template>
  <div>
    <template v-if="isMobile">
      <validationPhone-stepSelect v-if="step === 'first'" @stepEvent="setStep" @setDataEvent="setInfo"/>
      <validationPhone-stepMobile v-if="step === 'mobile'" @stepEvent="setStep" @tokenEvent="loadToken" :info="info"/>
      <validationPhone-stepEmail v-if="step === 'email'" @stepEvent="setStep" :info="info"/>
      <validationPhone-stepSecurity v-if="step === 'questions'" @stepEvent="setStep" @tokenEvent="loadToken" :tokenId="tokenId"/>
      <validationPhone-stepNew v-if="step === 'new'" @stepEvent="setStep" @lastEvent="setStepLast" :stepLast="stepLast" :tokenId="tokenId"/>
    </template>
    <template v-else>
      <accountCenter-header/>
      <phone-validation/>
    </template>
  </div>
</template>
<script>
  import AccountCenterHeader from '~components/default/AccountCenterHeader.vue'
  import PhoneValidation from '~components/validation/PhoneValidation.vue'
  import {ValidationPhoneStepSelect, ValidationPhoneStepMobile, ValidationPhoneStepEmail, ValidationPhoneStepSecurity, ValidationPhoneStepNew} from '~components/mobile/validation'
  export default {
    layout (context) {
      return context.store.state.option.isMobile ? 'mobile' : 'default'
    },
    transition: {
      name: 'fade',
      mode: 'out-in'
    },
    data () {
      return {
        step: 'first',
        info: '',
        tokenId: '',
        stepLast: 'new'
      }
    },
    components: {
      AccountCenterHeader,
      PhoneValidation,
      ValidationPhoneStepSelect,
      ValidationPhoneStepMobile,
      ValidationPhoneStepEmail,
      ValidationPhoneStepSecurity,
      ValidationPhoneStepNew
    },
    computed: {
      isMobile () {
        return this.$store.state.option.isMobile
      }
    },
    methods: {
      setStep (type) {
        this.step = type
      },
      setInfo (style) {
        this.info = style
      },
      loadToken (token) {
        this.tokenId = token
      },
      setStepLast (type) {
        console.log(type)
        this.stepLast = type
      }
    }
  }
</script>
