import { pikku } from '@/pikku/http'
import type { ApplicationCandidateData } from '@heygermany/sdk'
import { useQuery } from '@tanstack/react-query'

export const useGetCandidate = (candidateId?: string) => {
  return useQuery({
    queryKey: ['candidate'],
    queryFn: async (): Promise<ApplicationCandidateData> => {
      if (!candidateId) {
       return await pikku().get('/candidate')
      } else {
        return await pikku().get('/candidate/:candidateId', { candidateId })
    }
    },
    staleTime: 5 * 60 * 1000, // 5 minutes,
    retry: 0
  })
}
