Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sundowndev
GitHub Repository: sundowndev/phoneinfoga
Path: blob/master/web/client/src/store/index.ts
994 views
1
import Vue from "vue";
2
import Vuex, { Store } from "vuex";
3
4
Vue.use(Vuex);
5
6
interface ErrorAlert {
7
message: string;
8
}
9
10
interface StoreInterface {
11
number: string;
12
errors: ErrorAlert[];
13
}
14
15
const store: Store<StoreInterface> = new Vuex.Store({
16
state: {
17
number: "",
18
errors: [] as ErrorAlert[],
19
},
20
mutations: {
21
pushError(state, error: ErrorAlert): void {
22
state.errors.push(error);
23
},
24
setNumber(state, number: string): void {
25
state.number = number;
26
},
27
resetState(state) {
28
state.number = "";
29
state.errors = [];
30
31
return state;
32
},
33
},
34
getters: {},
35
actions: {
36
resetState(context): void {
37
context.commit("resetState");
38
},
39
},
40
modules: {},
41
});
42
43
export default store;
44
45