{"size": 935, "ext": "js", "max_stars_repo_path": "src/todo-list-vuex/store/index.js", "max_stars_repo_name": "534027739/vue-simple-use", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/todo-list-vuex/store/index.js", "max_issues_repo_name": "534027739/vue-simple-use", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/todo-list-vuex/store/index.js", "max_forks_repo_name": "534027739/vue-simple-use", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.7441860465, "max_line_length": 86, "alphanum_fraction": 0.5454545455}
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const state = {
    todos: [],
    filters: 'SHOW_ALL'
}

const mutations = {
    addTodo: function(state, payload){
        state.todos.push(payload)
    },
    toggleThing: function(state, index){
        state.todos[index].done = !state.todos[index].done
    },
    setFilter: function(state, curFilter){
        state.filters = curFilter;
    }
}

const getters = {
    filterData: function(state){
        switch (state.filters) {
            case 'SHOW_ALL':
                return state.todos;
            case 'SHOW_ACTIVE':
                return state.todos.filter(value => !value.done)
            case 'SHOW_COMPLETED':
                return state.todos.filter(value => value.done)                        
            default :
                return state.todos;
        }
    }
}


export default new Vuex.Store({
    state,
    getters,
    mutations
});