Skip to content

Instantly share code, notes, and snippets.

@TheJaredWilcurt
Last active May 12, 2019 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheJaredWilcurt/f710524a0d1e691a698662fd0d2ec4e6 to your computer and use it in GitHub Desktop.
Save TheJaredWilcurt/f710524a0d1e691a698662fd0d2ec4e6 to your computer and use it in GitHub Desktop.
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