diff options
| author | Zephyrrus <[email protected]> | 2020-07-10 01:17:00 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-07-10 01:17:00 +0300 |
| commit | a721681944e9eb06742e5b3f71c71aed9c1c117d (patch) | |
| tree | 93ff9fd13a0434d91fb1ae7ca0da48d6929c4d00 /src/site/plugins/handler.js | |
| parent | feat: backend pagination for albums (diff) | |
| parent | refactor: finish refactoring all the components to use vuex (diff) | |
| download | host.fuwn.me-a721681944e9eb06742e5b3f71c71aed9c1c117d.tar.xz host.fuwn.me-a721681944e9eb06742e5b3f71c71aed9c1c117d.zip | |
Merge pull request #1 from Zephyrrus/feature/store_refactor
Feature/store refactor
Diffstat (limited to 'src/site/plugins/handler.js')
| -rw-r--r-- | src/site/plugins/handler.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/site/plugins/handler.js b/src/site/plugins/handler.js new file mode 100644 index 0000000..3d85b15 --- /dev/null +++ b/src/site/plugins/handler.js @@ -0,0 +1,25 @@ +import AlertTypes from '~/constants/alertTypes'; + +export default ({ store }, inject) => { + inject('handler', { + async executeAction(action, param) { + try { + const response = await store.dispatch(action, param); + + 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; + } + }, + }); +}; |