Resloved the delay in expense action.
This commit is contained in:
parent
e4058a9cb4
commit
bc3b543015
@ -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
|
||||
|
@ -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();
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user