UNPKG

@hperchec/scorpion-ui-template-default

Version:
40 lines (36 loc) 887 B
import { utils } from '@hperchec/scorpion-ui' import options from './options' const { isNull } = utils /** * Vuex plugin: display-modal-on-system-error */ export default { /** * Function to create plugin * @param {Object} options - The create plugin options * @returns {Function} */ createPlugin: function (options) { // Process options // ... // Plugin return (store) => { /** * Watch mutations */ store.subscribe((mutation, state) => { if (mutation.type === 'System/SET_ERROR_PAYLOAD') { // Show/hide modal store.commit('Modals/SET_SHOW_MODAL', { name: 'GlobalErrorModal', value: !isNull(mutation.payload) // Hide if null }, { root: true }) } }) } }, /** * createPlugin options */ options }