import { getField, updateField } from 'vuex-map-fields';
import humps from 'lodash-humps';

export const layout = {
    namespaced: true,
    state: {
        user: {
            userVisits: localStorage.getItem('cr_userVisitCount') ? localStorage.getItem('cr_userVisitCount') : 0
        },
        categoryQueryParam: {
            pageSize: '',
            pageNo: '',
            sortSelect: '',
            categoryId: '',
            search: '',
            sideFilter: ''
        },
        heroContent: {},
    },
    getters: {
        getField,
    },
    mutations: {
        updateField,
        setCategoryQueryParam(state, data) {
            state.categoryQueryParam = data;
        },
        setHeroContent(state, content) {
            state.heroContent = content
        },
    },
    actions: {
        updateCategoryQueryParam({ commit }, values) {
            commit('setCategoryQueryParam', values);
        },
        setHeroContent({ commit }, one) {
            commit('setHeroContent', humps(one));
        },
    }

};