//import { createApp }   from "vue";
import { createStore } from "vuex";

const store = createStore({
    state () {
        return {
            author: {
                name:  "",
                image: "",
                wiki:  ""
            },
            authors: [],
            books:   [],
            book: {
                author: "",
                photo:  "",
                title:  "",
                cover:  "",
                wiki:   ""
            },
            chapters: []
        }
    },

    getters: {
        author:   state => { return state.author; },
        authors:  state => { return state.authors; },
        books:    state => { return state.books; },
        book:     state => { return state.book; },
        chapters: state => { return state.chapters }
    },

    mutations: {
        setAuthors (state, payload)  { state.authors  = payload; },
        setAuthor (state, payload)   { state.author   = payload; },
        setBooks (state, payload)    { state.books    = payload; },
        setBook (state, payload)     { state.book     = payload; },
        setChapters (state, payload) { state.chapters = payload; }
    }
});

export default store;
