<script setup>
import { defineProps, watch, ref } from 'vue';
import { getError, clearErrors } from "@/components/request/HandleGlobalError.vue";

const props = defineProps({
  error: {
    type: [String, Object],
    default: null,
    required: false
  },
  message: {
    type: [String, Function, Object],
    default: null,
    required: false
  }
});
</script>

<template>
  <template v-if="message">
    <div class="notification is-warning">
      <button class="delete"
              @click="clearErrors()"
      ></button>
      {{ typeof message === 'function' ? message() : message }}
    </div>
  </template>
  <template v-else>
  <div v-if="getError(error)"
       class="notification is-danger">
    <button class="delete"
            @click="clearErrors()"
    ></button>
    {{ getError(error) }}
  </div>
  </template>
</template>

<style scoped>

</style>