<template>
  <div>
    <template v-if="isMobile">
      <validationPhone-stepSelect v-if="step === 'select'" @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"/>
      <validationPhone-stepNew v-if="step === 'new'" @stepEvent="setStep" @lastEvent="setStepLast" :stepLast="stepLast" :tokenId="tokenId"/>
      <validationPhone-stepSuccess v-if="step === 'last'" @stepEvent="setStep" :stepLast="stepLast"/>
      <step-appeal v-if="step === 'appeal'" @stepEvent="setStep" @lastEvent="setStepLast"/>
    </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, ValidationPhoneStepSuccess, StepAppeal} from '~components/mobile/validation'
  export default {
    layout (context) {
      return context.store.state.option.isMobile ? 'mobile' : 'default'
    },
    middleware: 'authenticated',
    transition: {
      name: 'fade',
      mode: 'out-in'
    },
    data () {
      return {
        step: 'select',
        info: '',
        tokenId: '',
        stepLast: 'new'
      }
    },
    components: {
      AccountCenterHeader,
      PhoneValidation,
      ValidationPhoneStepSelect,
      ValidationPhoneStepMobile,
      ValidationPhoneStepEmail,
      ValidationPhoneStepSecurity,
      ValidationPhoneStepNew,
      ValidationPhoneStepSuccess,
      StepAppeal
    },
    computed: {
      isMobile () {
        return this.$store.state.option.isMobile
      }
    },
    mounted () {
      this.$route.query.token ? this.step = 'new' : this.step = 'select'
    },
    methods: {
      setStep (type) {
        console.log(type)
        this.step = type
      },
      setInfo (style) {
        this.info = style
      },
      loadToken (token) {
        this.tokenId = token
      },
      setStepLast (type) {
        console.log(type)
        this.stepLast = type
      }
    }
  }
</script>
