import { computed } from 'vue'
import { useFeedbackStore } from '@/stores/feedback'

export function useFeedback(alertId) {
  const store = useFeedbackStore()

  const feedback = computed(() => store.getFeedback(alertId))
  const hasRating = computed(() => !!feedback.value)
  const rating = computed(() => feedback.value?.rating ?? null)

  function rate(alertType, severity, ratingValue, notes = '') {
    store.addFeedback(alertId, alertType, severity, ratingValue, notes)
  }

  return { feedback, hasRating, rating, rate }
}