chore: heygermany customer project
This commit is contained in:
10
apps/website/hooks/candidate/useCandidateForm.ts
Normal file
10
apps/website/hooks/candidate/useCandidateForm.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ApplicationCandidateData } from "@heygermany/sdk"
|
||||
import { useForm } from "react-hook-form"
|
||||
|
||||
export const useCandidateForm = (candidate: ApplicationCandidateData) => {
|
||||
const methods = useForm<ApplicationCandidateData>({
|
||||
defaultValues: candidate,
|
||||
})
|
||||
|
||||
return methods
|
||||
}
|
||||
18
apps/website/hooks/candidate/useGetCandidate.ts
Normal file
18
apps/website/hooks/candidate/useGetCandidate.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user