diff --git a/src/components/Expenses/ViewExpense.jsx b/src/components/Expenses/ViewExpense.jsx index e4778df3..e535495e 100644 --- a/src/components/Expenses/ViewExpense.jsx +++ b/src/components/Expenses/ViewExpense.jsx @@ -30,7 +30,7 @@ import moment from "moment"; import ExpenseStatusLogs from "./ExpenseStatusLogs"; const ViewExpense = ({ ExpenseId }) => { - const { data, isLoading, isError, error } = useExpense(ExpenseId); + const { data, isLoading, isError, error, isFetching } = useExpense(ExpenseId); const [IsPaymentProcess, setIsPaymentProcess] = useState(false); const [clickedStatusId, setClickedStatusId] = useState(null); @@ -435,7 +435,7 @@ const ViewExpense = ({ ExpenseId }) => { setValue("statusId", status.id); handleSubmit(onSubmit)(); }} - disabled={isPending} + disabled={isPending || isFetching} className="btn btn-primary btn-sm cursor-pointer mx-2 border-0" > {isPending && clickedStatusId === status.id diff --git a/src/hooks/useExpense.js b/src/hooks/useExpense.js index cdb36605..233a796c 100644 --- a/src/hooks/useExpense.js +++ b/src/hooks/useExpense.js @@ -168,27 +168,27 @@ export const useActionOnExpense = (onSuccessCallBack) => { onSuccess: (updatedExpense, variables) => { showToast("Request processed successfully.", "success"); - queryClient.setQueriesData( - { - queryKey: ["Expenses"], - exact: false, - }, - (oldData) => { - if (!oldData) return oldData; - return { - ...oldData, - data: oldData.data.map((item) => - item.id === updatedExpense.id - ? { - ...item, - nextStatus: updatedExpense.nextStatus, - status: updatedExpense.status, - } - : item - ), - }; - } - ); + // queryClient.setQueriesData( + // { + // queryKey: ["Expenses"], + // exact: false, + // }, + // (oldData) => { + // if (!oldData) return oldData; + // return { + // ...oldData, + // data: oldData.data.map((item) => + // item.id === updatedExpense.id + // ? { + // ...item, + // nextStatus: updatedExpense.nextStatus, + // status: updatedExpense.status, + // } + // : item + // ), + // }; + // } + // ); // queryClient.setQueriesData( // { queryKey: ["Expense", updatedExpense.id] }, // (oldData) => { @@ -200,6 +200,7 @@ export const useActionOnExpense = (onSuccessCallBack) => { // } // ); queryClient.invalidateQueries({queryKey:["Expense",updatedExpense.id]}) + queryClient.invalidateQueries({queryKey:["Expenses",updatedExpense.id]}) if (onSuccessCallBack) onSuccessCallBack(); },