From 9e487fac4da96d611e0ae68c409c281f0df9c84c Mon Sep 17 00:00:00 2001 From: Erastus Amunwe Date: Mon, 26 Oct 2020 23:07:25 +0200 Subject: [PATCH] created store --- src/store.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/store.js diff --git a/src/store.js b/src/store.js new file mode 100644 index 0000000..1dcb3ce --- /dev/null +++ b/src/store.js @@ -0,0 +1,35 @@ +import { createStore } from 'vuex' + +export const store = createStore({ + state: { + settings: { + savedTr: [] + }, + search: '', + }, + mutations: { + add_translation (state,translation ) { + state.settings.savedTr.push(translation) + }, + remove_translation (state,abbr ) { + state.settings.savedTr = state.settings.savedTr.filter(tr => tr.abbreviation !==abbr) + + }, + add_search(state, search){ + state.search = search + } + }, + actions:{ + add({commit}, tr){ + commit('add_translation', tr); + }, + remove({commit}, abbr){ + commit('remove_translation', abbr); + }, + add_s({commit}, sr){ + commit('add_search', sr); + }, + } +}) + +// export default store; \ No newline at end of file