23 lines
791 B
TypeScript
23 lines
791 B
TypeScript
import { pikku } from "@/pikku/http"
|
|
import type { DB } from '@heygermany/sdk'
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
|
|
|
type LicenseUpdatePayload = Partial<Omit<DB.CandidateLicense, 'candidateId' | 'licenseId' | 'createdAt' | 'lastUpdatedAt'>>
|
|
|
|
export const useUpdateCandidateLicense = (candidateId: string) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation({
|
|
mutationFn: async (data: LicenseUpdatePayload) =>
|
|
await pikku().patch("/backoffice/candidate/:candidateId/license", { candidateId, ...data }),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({
|
|
queryKey: ['backoffice', 'candidate', candidateId]
|
|
})
|
|
queryClient.invalidateQueries({
|
|
queryKey: ['candidate', candidateId]
|
|
})
|
|
}
|
|
})
|
|
}
|