Toggle deleteMode with button in Header

This commit is contained in:
2020-12-07 15:27:54 +01:00
parent 5ef8c424fd
commit d826e758ff
10 changed files with 64 additions and 39 deletions

View File

@@ -18,7 +18,10 @@ export default {
removeFruit: async ({ commit }, id) => {
await axios
.delete(`http://localhost:3000/fruit/${id}`)
.then(() => commit("removeFruit", id))
.then(() => {
commit("removeFruit", id);
commit("toggleDeleteMode");
})
.catch(err => console.log(err));
},
getImageFromUnsplash: async ({ commit }, keyword) => {

View File

@@ -8,7 +8,8 @@ export const state = {
fruits: [],
fruit: {},
modalIsOpen: false,
loading: true
loading: true,
deleteMode: false
};
Vue.use(Vuex);

View File

@@ -18,5 +18,8 @@ export default {
},
setLoading: (state, loading) => {
state.loading = loading;
},
toggleDeleteMode: state => {
state.deleteMode = !state.deleteMode;
}
};