blob: f4be79c73d41f4b99ca7c39cc5b36fd2a763e950 (
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
|
import AlertTypes from '~/constants/alertTypes';
export default ({ store }, inject) => {
inject('handler', {
async executeAction(action, param, showSuccess = true) {
try {
const response = await store.dispatch(action, param);
if (showSuccess) {
store.commit('alert/set', {
message: response?.message ?? 'Executed sucesfully',
type: AlertTypes.SUCCESS
});
}
return response;
} catch (e) {
store.commit('alert/set', {
message: e.message,
type: AlertTypes.ERROR
});
return null;
}
}
});
};
|