import * as actions from './actions'
import getters from './getters'
import mutations from './mutations'
import {
  USER_COUNTRY,
  SELECTED_COUNTRY,
  LOGGED_IN_USER,
  STATES_LIST,
  COUNTRY_LIST,
  LANGUAGE_LIST,
  SELECTED_LANGUAGE,
  SELECTED_AUTOSHIP_COUNTRY,
  THIRD_PARTY_APPS_COUNTRY,
  IP_COUNTRY,
  CURRENT_IP,
} from '../../utils/localStorageKeys'

const state = {
  autoshipCountry:
    sessionStorage.getItem(SELECTED_AUTOSHIP_COUNTRY) !== null
      ? JSON.parse(sessionStorage.getItem(SELECTED_AUTOSHIP_COUNTRY))
      : false,
  countries: localStorage.getItem(COUNTRY_LIST) !== null ? JSON.parse(localStorage.getItem(COUNTRY_LIST)) : [],
  userCountry: JSON.parse(localStorage.getItem(USER_COUNTRY)),
  selectedCountry: JSON.parse(localStorage.getItem(SELECTED_COUNTRY)) || { id: '' },
  selectedLanguage: JSON.parse(localStorage.getItem(SELECTED_LANGUAGE)) || { id: '' },
  loggedInUser: JSON.parse(localStorage.getItem(LOGGED_IN_USER)),
  languages: [],
  languagesAll: localStorage.getItem(LANGUAGE_LIST) !== null ? JSON.parse(localStorage.getItem(LANGUAGE_LIST)) : [],
  shippingData: {},
  states: [],
  shippingCountries: [],
  stockistStateAndCities: {},
  locationTypeList: [],
  nationality: [],
  allCountries: [],
  dynamicContentData: {
    data: [],
  },
  statesByCountriesData: {
    data: {
      options: [],
    },
  },
  citiesByStateData: {
    data: {
      options: [],
    },
  },
  countryRelation: {
    data: {},
  },
  ipCountry: JSON.parse(localStorage.getItem(IP_COUNTRY)) || {},
  currentIp: localStorage.getItem(CURRENT_IP) || null,
}

export default {
  state,
  actions,
  mutations,
  getters,
}
