blob: cbd6359bfbf07794bedf6b944f0e41dd537d8b7a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import AlertTypes from '~/constants/alertTypes';
const getDefaultState = () => ({
message: null,
type: null,
snackbar: false
});
export const state = getDefaultState;
export const actions = {
set({ commit }, data) {
// Only exists for backwards compatibility, remove one day
if (data.error === true) data.type = AlertTypes.ERROR;
if (data.text !== undefined) data.message = data.text;
commit('set', data);
},
clear({ commit }) {
commit('clear');
}
};
export const mutations = {
set(state, { message, type, snackbar }) {
state.message = message;
state.type = type;
state.snackbar = snackbar || false;
},
clear(state) {
Object.assign(state, getDefaultState());
}
};
|