import moment from 'moment'

const initState = {
  imei: "",
  pageState: "await", // await | loading | isLoaded | error
  packsData: [{
    pack_number: 1,
    machine_type: "MPK",
    pack_dt: new Date(),
    zav_nomer: "qwe",
    machine_id: "4512",
    device_id: "43",
    imei: "88884166784",
    railway_name: "railway_name",
    org_name: "org_name",
    nomer_zn8: "nomer_zn8",
    device_number: "device_number",
  }],
  packNum: ""
}

const state = {
    ...initState
}

const getters = {
  imei:       (state)  => state.imei,
  pageState:  (state)  => state.pageState,
  packsData:  (state)  => state.packsData,
  packNum:    (state)  => state.packNum
}

const mutations = {
  setPackNum:      (state, updVal) => {
    state.packNum = updVal
  }
}


const actions = {
  uploadData: ({commit, state}) => {
    setTimeout(() => {
      state.pageState = 'loading'
    }, 500);
    setTimeout(() => {
      state.pageState = 'isLoaded'
    }, 3000);
  }
}

export const store = {
    namespaced: true,
    state,
    getters,
    mutations,
    actions,
}
