<template>
  <span class="queue-notif"></span>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import queueNotifService from '@/services/QueueNotifService'
import notif from '@/utils/notif'

@Component
export default class QueueNotif extends Vue {
  public mounted() {
    queueNotifService.subscribe((notification) => {
      switch (notification.type) {
        case 'success':
          notif.success(notification.message)
          break
        case 'error':
          notif.error(notification.message)
          break
      }
    })
  }

  public beforeDestroy() {
    queueNotifService.unsubscribe()
  }
}
</script>
