import { mapGetters } from 'vuex'
import templateMixin from './templateMixin'
import { getValue } from '@/helpers/variable-handling'

export default {
  mixins: [templateMixin],
  computed: {
    ...mapGetters([
      'getSelectedCountry',
      'getCountryById',
      'getAppStatus',
      'getAppLocationCountry',
      'getMemberCountryId',
    ]),
    currency() {
      if (this.inThirdPartyAppsTemplate()) {
        return this.getSelectedCountry.currency.code
      } else {
        let countryCode =
          ((this.getAppStatus('eshop') ||
            this.getAppStatus('enrolment') ||
            this.getAppStatus('virel') ||
            this.getAppStatus('thirdPartyAppsResumePayment') ||
            this.getAppStatus('autoship') ||
            this.getAppStatus('myBundle') ||
            this.getAppStatus('iToken')) &&
            this.getAppLocationCountry.countryId) ||
          this.getMemberCountryId

        return getValue(this.getCountryById(countryCode), 'currency.code')
      }
    },
  },
}
