diff --git a/src/components/Documents/ViewDocument.jsx b/src/components/Documents/ViewDocument.jsx
index 95b673b8..cd84fe78 100644
--- a/src/components/Documents/ViewDocument.jsx
+++ b/src/components/Documents/ViewDocument.jsx
@@ -2,6 +2,7 @@ import React, { useState } from "react";
import {
useDocumentDetails,
useDocumentVersionList,
+ useVerifyDocument,
} from "../../hooks/useDocument";
import { getDocuementsStatus, useDocumentContext } from "./Documents";
import { formatUTCToLocalTime } from "../../utils/dateUtils";
@@ -12,7 +13,7 @@ import VersionListSkeleton from "./VersionListSkeleton";
import DocumentDetailsSkeleton from "./DocumentDetailsSkeleton ";
const ViewDocument = () => {
- const { viewDoc, setViewDoc,setOpenDocument } = useDocumentContext();
+ const { viewDoc, setViewDoc, setOpenDocument } = useDocumentContext();
const [currentPage, setCurrentPage] = useState(1);
const { data, isLoading, isError, error } = useDocumentDetails(
viewDoc?.document
@@ -33,13 +34,17 @@ const ViewDocument = () => {
}
};
- if (isLoading) return ;
+ const { mutate: VerifyDoc, isPending } = useVerifyDocument();
+ const VerifyDocument = () => {
+ VerifyDoc({ documentId: viewDoc?.document, isVerify: true });
+ };
+
+ if (isLoading) return ;
if (isError) return
{error.message}
;
return (
Document Details
-
@@ -166,11 +171,11 @@ const ViewDocument = () => {
Documents
- {versionLoding &&
}
- {!versionLoding &&()}
+
+ )}
{!versionLoding && versionList?.data?.length > 0 && (
{
},
});
};
+
+export const useVerifyDocument = ()=>{
+ const queryClient = useQueryClient();
+ return useMutation({
+ mutationFn:async({documentId,isVerify}) => await DocumentRepository.verifyDocument(documentId,isVerify),
+ onSuccess: (data, variables) => {
+ queryClient.invalidateQueries({ queryKey: ["DocumentVersionList"] });
+ queryClient.invalidateQueries({ queryKey: ["DocumentList"] });
+ showToast(
+ data.response.data.message ||
+ "Document Successfully Verified !",
+ "success"
+ );
+ },
+ onError: (error) => {
+ showToast(
+ error.response.data.message ||
+ "Something went wrong please try again !",
+ "error"
+ );
+ },
+
+ })
+}
\ No newline at end of file
diff --git a/src/repositories/DocumentRepository.jsx b/src/repositories/DocumentRepository.jsx
index b26a5fa3..31da97cb 100644
--- a/src/repositories/DocumentRepository.jsx
+++ b/src/repositories/DocumentRepository.jsx
@@ -16,7 +16,7 @@ export const DocumentRepository = {
getDocumentVersion:(id)=>api.get(`/api/Document/get/version/${id}`),
- verifyDocument:(id)=>api.post(`/api/Document/verify/${id}`),
+ verifyDocument:(id,isVerify)=>api.post(`/api/Document/verify/${id}/?isVerify=${isVerify}`),
deleteDocument:(id)=>api.delete(`/api/Document/delete/${id}`)