Last active
May 7, 2017 22:40
-
-
Save israeleriston/a46307c540b603b3b22d65f66b835f92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//actions | |
export const resetMessages = ({ commit }) => { | |
commit(TYPES.SET_MESSAGE, { type: 'success', message: '' }) | |
commit(TYPES.SET_MESSAGE, { type: 'error', message: [] }) | |
commit(TYPES.SET_MESSAGE, { type: 'warning', message: '' }) | |
commit(TYPES.SET_MESSAGE, { type: 'validation', message: [] }) | |
} | |
// mutations | |
export default { | |
[TYPES.SET_MESSAGE_SUCCESS] (state, obj) { | |
state.messages.success = obj.message | |
}, | |
[TYPES.SET_MESSAGE_VALIDATOR] (state, obj) { | |
state.messages.validation = obj.message | |
}, | |
[TYPES.SET_MESSAGE_ERROR] (state, obj) { | |
state.messages.error = obj.message | |
}, | |
[TYPES.SET_MESSAGE_WARNING] (state, obj) { | |
state.messages.warning = obj.message | |
} | |
} | |
// state | |
export default { | |
messages: { | |
validation: [], | |
warning: '', | |
success: '', | |
error: [] | |
} | |
} | |
// beforeEach | |
export default (to, from, next) => { | |
store.dispatch('resetMessages') | |
if (!isLogged()) { | |
next('/auth') | |
} else { | |
next() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment