navigate(`/expenses/${item.status}`)}
+ onClick={()=>handleNavigate(item.status)}
>
diff --git a/src/components/Expenses/ExpenseFilterPanel.jsx b/src/components/Expenses/ExpenseFilterPanel.jsx
index c3e2db23..7a47ec6d 100644
--- a/src/components/Expenses/ExpenseFilterPanel.jsx
+++ b/src/components/Expenses/ExpenseFilterPanel.jsx
@@ -16,7 +16,7 @@ import { ExpenseFilterSkeleton } from "./ExpenseSkeleton";
import { useLocation, useNavigate, useParams } from "react-router-dom";
const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
- const { status } = useParams();
+ const { status, project } = useParams();
const navigate = useNavigate();
const selectedProjectId = useSelector(
(store) => store.localVariables.projectId
@@ -43,7 +43,7 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
return {
...defaultFilter,
statusIds: status ? [status] : defaultFilter.statusIds || [],
- projectIds: defaultFilter.projectIds || [],
+ projectIds: project ? [project] : defaultFilter.projectIds || [],
createdByIds: defaultFilter.createdByIds || [],
paidById: defaultFilter.paidById || [],
isTransactionDate: defaultFilter.isTransactionDate ?? true,
@@ -99,7 +99,7 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
const [appliedStatusId, setAppliedStatusId] = useState(null);
useEffect(() => {
- if (!status) return;
+ if (!status && !project) return;
if (status !== appliedStatusId && data) {
const filterWithStatus = {
@@ -121,6 +121,7 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
}
}, [
status,
+ project,
data,
dynamicDefaultFilter,
onApply,
diff --git a/src/hooks/useDashboard_Data.jsx b/src/hooks/useDashboard_Data.jsx
index 5d11705a..747d2f5b 100644
--- a/src/hooks/useDashboard_Data.jsx
+++ b/src/hooks/useDashboard_Data.jsx
@@ -268,7 +268,10 @@ export const useExpenseAnalysis = (projectId, startDate, endDate) => {
const resp = await GlobalRepository.getExpenseData(projectId, startDate, endDate);
return resp.data;
},
- enabled:shouldFetch
+ enabled:shouldFetch,
+ refetchOnWindowFocus: true, // refetch when you come back
+ refetchOnMount: "always", // always refetch on remount
+ staleTime: 0,
});
};
export const useExpenseStatus = (projectId)=>{
diff --git a/src/router/AppRoutes.jsx b/src/router/AppRoutes.jsx
index 78574732..24e98921 100644
--- a/src/router/AppRoutes.jsx
+++ b/src/router/AppRoutes.jsx
@@ -94,7 +94,7 @@ const router = createBrowserRouter(
{ path: "/activities/task", element: },
{ path: "/activities/reports", element: },
{ path: "/gallary", element: },
- { path: "/expenses/:status?", element: },
+ { path: "/expenses/:status?/:project?", element: },
{ path: "/masters", element: },
{ path: "/tenants", element: },
{ path: "/tenants/new-tenant", element: },
diff --git a/src/utils/appUtils.js b/src/utils/appUtils.js
index 775ac756..bbfd3636 100644
--- a/src/utils/appUtils.js
+++ b/src/utils/appUtils.js
@@ -97,7 +97,7 @@ export const formatCurrency = (amount, currency = "INR", locale = "en-US") => {
return new Intl.NumberFormat(locale, {
style: "currency",
currency: currency,
- minimumFractionDigits: 2,
+ minimumFractionDigits: 0,
maximumFractionDigits: 2,
}).format(amount);
};