import * as T from '@/store/utils/types'

export default {
  [T.SET_EWALLET_ACTIVATION0_STEP](state, data) {
    state.eWalletActivation0Step = data
  },
  [T.SET_EWALLET_REPRINT_DATA](state, data) {
    state.eWalletReprintData = data
  },
  [T.SET_EWALLET_TEMPORARY_MOBILE_PHONE](state, data) {
    let tempData = {
      mobile_1_country_code_id: data.mobile_1_country_code_id,
      mobile_1_num: data.mobile_1_num,
    }
    state.tempMobilePhone = tempData
  },
  [T.SET_EWALLET_RESEND_CODE](state, data) {
    state.resendCode = data
  },
  [T.SET_EWALLET_SELECTED_PAYMENT_TYPE](state, data) {
    state.eWalletSelectedPayment = data
  },
  [T.SET_EWALLET_AUTOWITHDRAWAL_STATUS](state, data) {
    state.eWalletAutoWithdrawalStatus = data
  },
  [T.SET_EWALLET_PAYMENT_TYPE](state, data) {
    state.eWalletPaymentType = data
  },
  [T.SET_EWALLET_CURRENT_RECORD_OFFSET](state, data) {
    state.currentRecordOffset = data
  },
  [T.SET_EWALLET_CURRENT_HISTORY_OFFSET](state, data) {
    state.currentHistoryOffset = data
  },
  [T.SET_EWALLET_TOTAL_TRANSACTION_ROWS](state, data) {
    state.totalEwalletTransactionRows = data
  },
  [T.SET_EWALLET_USER_CURRENCY](state, data) {
    state.eWalletUserCurrency = data
  },
  [T.SET_EWALLET_RECORD_DATERANGE](state, data) {
    state.eWalletRecordDate = data
  },
  [T.SET_EWALLET_HISTORY_DATERANGE](state, data) {
    state.eWalletHistoryDate = data
  },
  [T.SET_EWALLET_TAB_INDEX](state, data) {
    state.eWalletTabIndex = data
  },
  [T.SET_FORGOT_SECURITY_PIN_INFO](state, data) {
    state.eWalletSecurityPinInfo = data
  },
  [T.SET_EWALLET_SECURITY_PIN_MODAL](state, data) {
    state.eWalletForgotSecurityPinModal = data
  },
  [T.SET_EWALLET_SHOW_MODAL_PROCESS_TYPE](state, data) {
    state.eWalletShowModalProcessType = data
  },
  [T.SET_EWALLET_SELECTED_MPAY_INFO](state, data) {
    let temp = {
      eWalletCardNumber: data[2].value,
      eWalletCardHolderName: data[1].value,
      eWalletCardExpiryDate: { mm: data[3].value, yy: data[4].value },
    }
    state.eWalletSelectedMPayInfo = temp
  },
  [T.SET_EWALLET_BANK_INFO](state, data) {
    state.eWalletBankInfo = data
  },
  [T.SET_EWALLET_SELECTED_BANK_INFO](state, data) {
    let temp = {}
    if (data !== null) {
      temp = {
        bankName: data[1].value,
        bankSwiftCode: data[3].value,
        bankAccountNumber: data[5].value,
        bankAccountHolderName: data[2].value,
      }
    }
    state.eWalletSelectedBankInfo = temp
  },
  [T.CONFIRM_FUND_STEP](state, data) {
    state.ewalletFundStep = data
    if (data === 'fundSecondStep') {
      state.classObject1['active-step'] = false
      state.classObject1['completed-step'] = true
      state.classObject2['active-step'] = true
      state.classObject2['completed-step'] = false
    } else if (data === 'fundFirstStep') {
      state.classObject1['active-step'] = true
      state.classObject1['completed-step'] = false
      state.classObject2['active-step'] = false
      state.classObject2['completed-step'] = false
      state.classObject3['active-step'] = false
      state.classObject3['completed-step'] = false
    } else {
      // Go to step 3
      state.classObject1['active-step'] = false
      state.classObject1['completed-step'] = true
      state.classObject2['active-step'] = false
      state.classObject2['completed-step'] = true
      state.classObject3['active-step'] = true
      state.classObject3['completed-step'] = false
    }
  },
  [T.CANCEL_FUND_STEP](state, data) {
    state.ewalletFundStep = data
    if (data === 'fundFirstStep') {
      state.classObject1['active-step'] = true
      state.classObject1['completed-step'] = false
      state.classObject2['active-step'] = false
      state.classObject2['completed-step'] = false
      state.classObject3['active-step'] = false
      state.classObject3['completed-step'] = false
    } else {
      // Back to step 2
      state.classObject2['active-step'] = true
      state.classObject2['completed-step'] = false
      state.classObject3['active-step'] = false
      state.classObject3['completed-step'] = false
    }
  },
  [T.FINISH_FUND_STEP](state, data) {
    state.ewalletFundStep = data
    state.classObject1['active-step'] = true
    state.classObject1['completed-step'] = false
    state.classObject2['active-step'] = false
    state.classObject2['completed-step'] = false
    state.classObject3['active-step'] = false
    state.classObject3['completed-step'] = false
  },
  [T.SET_EWALLET_INFO](state, data) {
    state.eWalletId = data.id
    state.eWalletUserId = data.user_id
    state.eWalletSelectedCountryCode = data.mobile_1_country_code_id
    state.eWalletMobileNumber = data.mobile_1_num
    state.eWalletAutoWithdrawalStatus = data.auto_withdrawal
    state.eWalletBalance = data.balance
    state.eWalletActiveStatus = data.active
    state.eWalletCurrencyCode = data.currency.code
    state.eWalletCurrencyId = data.currency.id
  },
  [T.SET_EWALLET_ACTIVE_STATUS](state, data) {
    state.eWalletActiveStatus = data
  },
  [T.SET_MOBILE_COUNTRIES_CODES](state, data) {
    state.listMobileCountriesCodes = data
  },
  [T.SET_EWALLET_MOBILE_VERIFICATION_STATUS](state, data) {
    state.mobileVerificationStatus = data
  },
  [T.SET_EWALLET_MOBILE_VERIFICATION_MESSAGE](state, data) {
    state.mobileVerificationMessage = data
  },
  [T.SET_MOBILE_COUNTRY_CODE](state, data) {
    state.eWalletMobileNumber = data.mobile_1_num
    state.eWalletSelectedCountryCode = data.mobile_1_country_code_id
  },
  [T.SET_EWALLET_MOBILE_CONFIRMATION_STATUS](state, data) {
    state.mobileConfirmationStatus = data
  },
  [T.SET_EWALLET_MOBILE_CONFIRMATION_MESSAGE](state, data) {
    state.mobileConfirmationMessage = data
  },
  [T.FETCH_EWALLET_TRANSACTION_HISTORY](state, data) {
    state.eWalletTransactionHistory = data.history
    state.eWalletRecord = data.record
  },
  [T.SET_EWALLET_FUND_TRANSFER_INFO](state, data) {
    state.eWalletFundTransferInfo = data
  },
  [T.SET_EWALLET_TRANSACTION_TYPE](state, data) {
    state.eWalletTransactionTypeId = data
  },
  [T.SET_EWALLET_BALANCE](state, data) {
    state.eWalletBalance = data
  },
  [T.SET_EWALLET_FUND_TRANSFER_STATUS_INFO](state, data) {
    state.eWalletFundTransferResponseInfo = data
  },
  [T.SET_EWALLET_FUND_TRANSFER_STATUS](state, data) {
    state.eWalletFundTransferStatus = data
  },
  [T.SET_EWALLET_FUND_TRANSFER_MESSAGE](state, data) {
    state.eWalletFundTransferMessage = data
  },
  [T.SET_EWALLET_FUND_WITHDRAWAL_INFO](state, data) {
    state.eWalletFundWithdrawalInfo = data
  },
  [T.SET_EWALLET_TRANSACTION_STATUS](state, data) {
    state.eWalletTransactionStatus = data
  },
  [T.SET_EWALLET_INSUFFICIENT_FUND_ERR](state, data) {
    state.eWalletInsufficientFundError = data
  },
  [T.SET_EWALLET_RANGE_FUND_ERR](state, data) {
    state.eWalletRangeFundError = data
  },
  [T.SET_EWALLET_SHOW_MODAL](state, data) {
    state.eWalletShowModal = data
  },
  [T.SET_EWALLET_DETAILS](state, data) {
    state.eWalletDetails = data
  },
}
