import { defineStore } from 'pinia'
import { ref } from 'vue'

export interface Notification {
  id: string
  topic: string
  severity: 'info' | 'warning' | 'error'
  title: string
  body: string
  link?: string
  read_at?: string
  created_at: string
  metadata?: Record<string, unknown>
}

export const useNotificationsStore = defineStore('notifications', () => {
  const items = ref<Notification[]>([])
  const unreadCount = ref(0)

  function setItems(list: Notification[]) {
    items.value = list
  }
  function setUnreadCount(n: number) {
    unreadCount.value = n
  }

  return { items, unreadCount, setItems, setUnreadCount }
})
