File: //proc/thread-self/root/home/arjun/projects/buyercall/buyercall/assets/vue/widgets/Toast/Toast.vue
<template></template>
<script>
import * as _ from 'lodash';
export default {
mounted() {
if (backendFlashMessages) {
_.forEach(
_.map(JSON.parse(backendFlashMessages.replace(/\'/g, '"')), (flash) => {
const toastType = _.keys(flash)[0];
const toastMessage = flash[_.keys(flash)[0]];
return {
toastType,
toastMessage,
};
}),
({ toastType, toastMessage: message }) => {
let type = 'default';
//success, info, warning, error, default
switch (toastType) {
case 'danger':
case 'error':
type = 'error';
break;
case 'success':
type = 'success';
break;
case 'warn':
case 'warning':
type = 'warning';
break;
case 'info':
type = 'info';
break;
}
this.$toast.open({
message,
type,
position: 'top-right',
duration: 5000,
});
},
);
}
},
};
</script>