import * as T from '../../utils/types'

export default {
  [T.SET_UPLOAD_SETTINGS](state, payload) {
    state.uploadsSettings = payload
  },
  [T.SET_UPLOADS](state, payload) {
    state.uploads.push(payload)
  },
  [T.RESET_UPLOADS](state) {
    state.uploads = []
  },
  [T.SET_CLASSIC_VERIFICATION](state, payload) {
    state.externalAPIs.classicVerification = payload
  },
  [T.SET_CLASSIC_CROSS_SPONSORING_VERIFICATION](state, payload) {
    state.externalAPIs.classicCrossSponsoringVerification = payload
  },
  [T.SET_ON_DEMAND_VERIFICATION](state, payload) {
    state.userOnDemandVerification = payload
  },
  [T.SET_IC_PASSPORT_VALIDATION](state, payload) {
    if (payload.ic_pass_type_id !== undefined) {
      state.icPassportValidation.ic_pass_type_id = payload.ic_pass_type_id
    } else {
      state.icPassportValidation.ic_passport_number = payload.ic_passport_number
    }
  },
  [T.RESET_ON_DEMAND_VERIFICATION](state) {
    state.userOnDemandVerification = {}
  },
  [T.RESET_CLASSIC_CROSS_SPONSORING_VERIFICATION](state) {
    state.externalAPIs.classicCrossSponsoringVerification = {}
  },
  [T.RESET_IC_PASSPORT_VALIDATION](state) {
    state.icPassportValidation = {
      ic_pass_type_id: null,
      ic_passport_number: '',
    }
  },
  [T.SET_AUTO_VALIDATION_TRIGGER_STATUS](state) {
    state.autoValidationActivate = new Date().getTime()
  },
  [T.SET_EXPERIMENTAL_FEATURE](state, payload) {
    for (let key in payload) {
      if (state.experimentalFeature.hasOwnProperty(key)) {
        state.experimentalFeature[key] = payload[key]
      }
    }
  },
}
