import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { FAQ } from '@/types'
import { mockFAQs } from '@/mock'

export const useCommonStore = defineStore('common', () => {
  const faqs = ref<FAQ[]>([...mockFAQs])
  const currentFaq = ref<FAQ | null>(null)

  function setCurrentFaq(id: string) {
    currentFaq.value = faqs.value.find((f) => f.id === id) || null
  }

  return {
    faqs,
    currentFaq,
    setCurrentFaq,
  }
})
