import { ref } from 'vue';

export function useAlert() {
  const show_alert = ref(false);
  const alert_variant = ref('');
  const alert_msg = ref('');

  const showAlert = (
    message: string,
    variant: string,
    autoHide: boolean = false
  ) => {
    alert_msg.value = message;
    alert_variant.value = variant;
    show_alert.value = true;

    if (autoHide) {
      setTimeout(() => {
        show_alert.value = false;
      }, 3000);
    }
  };

  return {
    show_alert,
    alert_variant,
    alert_msg,
    showAlert,
  };
}
