From ee1887de8f2f309c54642c17033e1f03184317aa Mon Sep 17 00:00:00 2001 From: pramod mahajan Date: Mon, 1 Sep 2025 18:51:23 +0530 Subject: [PATCH] fixed reduant api calling --- src/components/Documents/Documents.jsx | 14 ++++++++++---- src/hooks/masterHook/useMaster.js | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/Documents/Documents.jsx b/src/components/Documents/Documents.jsx index bd74ca16..44c95195 100644 --- a/src/components/Documents/Documents.jsx +++ b/src/components/Documents/Documents.jsx @@ -19,7 +19,7 @@ export const DocumentContext = createContext(); export const useDocumentContext = () => { const context = useContext(DocumentContext); if (!context) { - throw new Error("useExpenseContext must be used within an ExpenseProvider"); + throw new Error("useDocumentContext must be used within an DocumentProvider"); } return context; }; @@ -29,6 +29,7 @@ const Documents = ({ Document_Entity, Entity }) => { const [filters, setFilter] = useState(); const [isRefetching, setIsRefetching] = useState(false); const [refetchFn, setRefetchFn] = useState(null); + const [DocumentEntity,setDocumentEntity] = useState(Document_Entity) const { employeeId } = useParams(); const [ManageDoc, setManageDoc] = useState({ document: null, @@ -54,7 +55,7 @@ const Documents = ({ Document_Entity, Entity }) => { setShowTrigger(true); setOffcanvasContent( "Document Filters", - + ); return () => { @@ -68,6 +69,11 @@ const Documents = ({ Document_Entity, Entity }) => { setManageDoc, } + useEffect(()=>{ + if(Document_Entity){ + setDocumentEntity(Document_Entity) + } + },[Document_Entity]) return ( @@ -118,7 +124,7 @@ const Documents = ({ Document_Entity, Entity }) => { { isOpen: false, }) } - Document_Entity={Document_Entity} + Document_Entity={DocumentEntity} Entity={Entity} /> diff --git a/src/hooks/masterHook/useMaster.js b/src/hooks/masterHook/useMaster.js index 9a31dcf8..6aa261de 100644 --- a/src/hooks/masterHook/useMaster.js +++ b/src/hooks/masterHook/useMaster.js @@ -203,7 +203,7 @@ const { isError, isLoading } = useQuery({ - queryKey: ["Document Category"], + queryKey: ["Document Category",EntityType], queryFn: async () => { const res = await MasterRespository.getDocumentCategories(EntityType) return res.data;