import storage from 'store'
import {
  LINE_CONFIG_SELECTED,
  LINE_CONFIG_OPTIONS,
  TEMPLATE_ID_CHANGE,
  TOP_WELL_CHOOSEN,
  SELECTED_JHX
} from '@/store/mutation-types'
let jhhhhhh=storage.get(SELECTED_JHX);

const app = {
  state: {
    lineConfigSelected: undefined,
    chartData: undefined,
    configureKey: undefined,
    templateId: undefined,
    radius: '5000',
    selectedJhx: jhhhhhh,
    serchTime: ''
  },
  mutations: {
    [LINE_CONFIG_SELECTED]: (state, payload) => {
      state.lineConfigSelected = payload
      storage.set(LINE_CONFIG_SELECTED, payload)
    },
    [LINE_CONFIG_OPTIONS]: (state, payload) => {
      state.chartData = payload
    },
    [TEMPLATE_ID_CHANGE]: (state, payload) => {
      state.templateId = payload
    },
    SET_KEY: (state, payload) => {
      state.configureKey = payload
    },
    RadiusSet: (state, payload) => {
      state.radius = payload
    },
    serchJhSet: (state, payload) => {
      state.selectedJhx = payload
      console.log(payload)
      storage.set(SELECTED_JHX, payload)
      console.log(storage.get(SELECTED_JHX))

    },
    serchTime: (state, payload) => {
      state.serchTime = payload
    }
  },
  actions: {
    setLineConfigSelected({ commit }, config) {
      commit(LINE_CONFIG_SELECTED, config)
    }
  }
}

export default app
