import { defineStore } from 'pinia'
import { ref } from 'vue'
import { useFetch } from '@/composables/useFetch.ts'

export interface Status {
  id: number
  name: string
  description?: string
  position: number
}

export const useStatusesStore = defineStore('statuses', () => {
  const statuses = ref<Status[]>([])
  const { GET } = useFetch('/api/statuses')

  async function findAll() {
    const response = await GET<Status[]>()
    if (response?.data) {
      statuses.value = response.data
    }
  }

  return { statuses, findAll }
})
