import { defineStore } from 'pinia'
import { getInterviewOptions } from '@/api'
import type { InterviewOptionDto } from '@/api/article/types'
/**
 * 关于专访的相关数据 --不分页
 */
export const useInterviewStore = defineStore('interview', () => {
  const interviewList = ref<InterviewOptionDto[]>([])

  let isLoading = false

  const fetchInterviewList = async () => {
    if (isLoading) return
    if (interviewList.value.length > 0) return
    isLoading = true
    try {
      const { data } = await getInterviewOptions()
      interviewList.value = data
    } catch (error) {
      console.error(error)
    } finally {
      isLoading = false
    }
  }
  fetchInterviewList()

  return { interviewList, fetchInterviewList }
})
