import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    apiKey: 0,
    user: {},
    adminApiKey: 0,
    admin: {},
    countryId: 0,
    cityId: 0,
    countries: [],
    cities: [],
  },
  mutations: {
    login(state, data) {
      state.apiKey = data.UserID;
      state.user = data;
    },
    logout(state) {
      state.apiKey = 0;
      state.user = {};
    },
    adminLogin(state, data) {
      state.adminApiKey = data.AdminID;
      state.admin = data
    },
    adminLogout(state) {
      state.adminApiKey = 0;
      state.admin = {};
    },
    setCountryId(state, id) {
      state.countryId = id;
    },
    setCityId(state, id) {
      state.cityId = id;
    },
    setCountries(state, countries) {
      state.countries = countries;
    },
    setCities(state, cities) {
      state.cities = cities;
    }
  },
  actions: {
  },
  modules: {
  }
})
