Last active
May 12, 2019 13:21
-
-
Save TheJaredWilcurt/f710524a0d1e691a698662fd0d2ec4e6 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
export const mutations = { | |
/** | |
* Sets the snackbar values in state | |
* @param {object} state The state of the Vuex store | |
* @param {object} payload Settings for snackbar, including message and color | |
*/ | |
setSnack: function (state, payload) { | |
const allowedColors = [ | |
'error', | |
'success', | |
'info', | |
'warning' | |
]; | |
let color = 'info'; | |
if (allowedColors.includes(payload.color)) { | |
color = payload.color; | |
} | |
let message = ''; | |
if (typeof(payload.message) === 'string') { | |
message = payload.message; | |
} | |
state.snackColor = color; | |
state.message = message; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment