import { useQuasar } from 'quasar'
import { useI18n } from 'vue-i18n'
import type { ServerError } from 'boot/axios'

export type { ServerError }

export function useNotify() {
  const $q = useQuasar()
  const { t } = useI18n()

  const notifyError = (error: ServerError) => {
    $q.notify({
      message: `${t(error.message)} (${t('code')}: ${error.code})`,
      type: 'negative',
      position: 'bottom',
      timeout: 2000,
      multiLine: true
    })
  }

  return { notifyError }
}
