HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/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>