Files
heygermany-e2e-mrg1mo7z/apps/website/hooks/backoffice/useUpdateBackOfficeCandidate.ts
e2e aae77ea31e
Some checks failed
Main / Setup and Test (push) Has been cancelled
Main / Build Website (push) Has been cancelled
chore: heygermany customer project
2026-07-11 09:28:50 +02:00

25 lines
907 B
TypeScript

import { pikku } from "@/pikku/http"
import { useMutation, useQueryClient } from "@tanstack/react-query"
import { UpdateBackOfficeCandidateInput } from '@heygermany/functions/.pikku/http/pikku-http-wirings-map.gen.d.js'
type BackOfficeCandidatePatch = Omit<UpdateBackOfficeCandidateInput, 'candidateId'> & {
analysisIssues?: string[]
}
export const useUpdateBackOfficeCandidate = (candidateId: string) => {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async (data: BackOfficeCandidatePatch) =>
await pikku().patch("/backoffice/candidate/:candidateId", { candidateId, ...data }),
onSuccess: () => {
// Invalidate and refetch the candidate data
queryClient.invalidateQueries({
queryKey: ['backoffice', 'candidate', candidateId]
})
queryClient.invalidateQueries({
queryKey: ['candidate', candidateId]
})
}
})
}