import { useQuery } from '@tanstack/react-query'
import { needService } from '../services/needService'

export function useNeeds() {
  return useQuery({
    queryKey: ['needs'],
    queryFn: () => needService.getAll(),
    select: (res) => res.data ?? [],
  })
}

export function useNeed(id: string) {
  return useQuery({
    queryKey: ['need', id],
    queryFn: () => needService.getById(id),
    enabled: Boolean(id),
    select: (res) => res.data ?? null,
  })
}

export const useNeedProfiles = useNeeds
