28 lines
829 B
TypeScript
28 lines
829 B
TypeScript
import { pikku } from "@/pikku/http"
|
|
import type { DB } from '@heygermany/sdk'
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
|
|
|
type UpdateDocumentVerificationInput = {
|
|
documentId: string
|
|
documentStatus: DB.DocumentStatus
|
|
}
|
|
|
|
export const useUpdateDocumentVerification = (candidateId: string) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation({
|
|
mutationFn: async ({ documentId, documentStatus }: UpdateDocumentVerificationInput) =>
|
|
await pikku().patch("/backoffice/candidate/:candidateId/document/:documentId", {
|
|
candidateId,
|
|
documentId,
|
|
documentStatus
|
|
}),
|
|
onSuccess: () => {
|
|
// Invalidate and refetch the candidate data
|
|
queryClient.invalidateQueries({
|
|
queryKey: ['backoffice', 'candidate', candidateId]
|
|
})
|
|
}
|
|
})
|
|
}
|