import store from '@/store'
import { getValue } from '@/helpers/variable-handling'
import validatedRouteMixin from '@/app/_global/mixins/validatedRouteMixin'
import {
  REDEEM_I_TOKEN,
  REDEEM_I_TOKEN_SELECT_PRODUCT,
  REDEEM_I_TOKEN_SHIPPING_INFO,
  REDEEM_I_TOKEN_PAYMENT_INFO,
  REDEEM_I_TOKEN_COMPLETE,
} from '@/config/url-prefix'
import { mapGetters } from 'vuex'

export default {
  mixins: [validatedRouteMixin],
  data() {
    let self = this
    let URL_PREFIX = [REDEEM_I_TOKEN, getValue(store, 'state.route.params.voucherId')].join('/')

    return {
      routingOrder: [
        {
          id: 1,
          path: [URL_PREFIX, REDEEM_I_TOKEN_SELECT_PRODUCT].join('/'),
          previous: this.$t('Common.Back'),
          next: this.$t('Common.Continue'),
          icon: 'sidebar-i-token',
          title: this.$t('Common.CheckoutSteps.SelectProduct'),
          validate: () => Promise.resolve(self.getITokenRedemptionFormDetails.cart.length > 0),
        },
        {
          id: 2,
          path: [URL_PREFIX, REDEEM_I_TOKEN_SHIPPING_INFO].join('/'),
          previous: this.$t('Common.Back'),
          next: this.$t('Common.Continue'),
          icon: 'eshop-shipping',
          title: this.$t('Eshop.Order.Review.Step.Title'),
          showContinueButton: true,
          validate: () => {
            return Promise.resolve(self.getITokenRedemptionFormDetails.shippingInfo.validate === true)
          },
        },
        {
          id: 3,
          path: [URL_PREFIX, REDEEM_I_TOKEN_PAYMENT_INFO].join('/'),
          previous: this.$t('Common.Back'),
          next: this.$t('Common.Continue'),
          icon: 'eshop-payment',
          title: this.$t('Common.MakePayment'),
        },
        {
          id: 4,
          path: [URL_PREFIX, REDEEM_I_TOKEN_COMPLETE].join('/'),
          previous: this.$t('Common.Back'),
          icon: 'eshop-completed',
          title: this.$t('Eshop.Order.Completed.Text'),
        },
      ],
    }
  },
  computed: {
    ...mapGetters('itoken', ['getITokenRedemptionFormDetails']),
  },
}
