22 lines
676 B
JavaScript
22 lines
676 B
JavaScript
|
|
|
|
//----------------------- MUTATION -------------------------
|
|
|
|
import { useMutation } from "@tanstack/react-query"
|
|
import showToast from "../services/toastService";
|
|
import { DocumentRepository } from "../repositories/DocumentRepository";
|
|
|
|
export const useUploadDocument =(onSuccessCallBack)=>{
|
|
return useMutation(({
|
|
mutationFn:async(DocumentPayload)=>DocumentRepository.uploadDocument(DocumentPayload),
|
|
onSuccess:(data,variables)=>{
|
|
if(onSuccessCallBack) onSuccessCallBack()
|
|
},
|
|
onError: (error) => {
|
|
showToast(
|
|
error.message || "Something went wrong please try again !",
|
|
"error"
|
|
);
|
|
},
|
|
}))
|
|
} |