Changes in expense filter panel.

This commit is contained in:
Kartik Sharma 2025-10-15 15:58:59 +05:30
parent bd6332fa61
commit b23518f796
3 changed files with 74 additions and 78 deletions

View File

@ -43,7 +43,7 @@ const ExpenseFilterPanel = forwardRef(({ onApply, handleGroupBy, setFilterdata }
return { return {
...defaultFilter, ...defaultFilter,
statusIds: status ? [status] : defaultFilter.statusIds || [], statusIds: status ? [status] : defaultFilter.statusIds || [],
projectIds: selectedProjectId ? [selectedProjectId] : [], projectIds: defaultFilter.projectIds || [],
createdByIds: defaultFilter.createdByIds || [], createdByIds: defaultFilter.createdByIds || [],
paidById: defaultFilter.paidById || [], paidById: defaultFilter.paidById || [],
ExpenseTypeIds: defaultFilter.ExpenseTypeIds || [], ExpenseTypeIds: defaultFilter.ExpenseTypeIds || [],
@ -51,7 +51,7 @@ const ExpenseFilterPanel = forwardRef(({ onApply, handleGroupBy, setFilterdata }
startDate: defaultFilter.startDate, startDate: defaultFilter.startDate,
endDate: defaultFilter.endDate, endDate: defaultFilter.endDate,
}; };
}, [status,selectedProjectId]); }, [status]);
const methods = useForm({ const methods = useForm({
resolver: zodResolver(SearchSchema), resolver: zodResolver(SearchSchema),
@ -119,12 +119,12 @@ const ExpenseFilterPanel = forwardRef(({ onApply, handleGroupBy, setFilterdata }
const [appliedStatusId, setAppliedStatusId] = useState(null); const [appliedStatusId, setAppliedStatusId] = useState(null);
useEffect(() => { useEffect(() => {
if (!status) return; if (!status || !data) return;
if (status !== appliedStatusId && data) { if (status !== appliedStatusId) {
const filterWithStatus = { const filterWithStatus = {
...dynamicDefaultFilter, ...dynamicDefaultFilter,
projectIds: selectedProjectId ? [selectedProjectId] : [], // include project ID projectIds: selectedProjectId ? [selectedProjectId] : dynamicDefaultFilter.projectIds || [],
startDate: dynamicDefaultFilter.startDate startDate: dynamicDefaultFilter.startDate
? moment.utc(dynamicDefaultFilter.startDate, "DD-MM-YYYY").toISOString() ? moment.utc(dynamicDefaultFilter.startDate, "DD-MM-YYYY").toISOString()
: undefined, : undefined,
@ -135,7 +135,6 @@ const ExpenseFilterPanel = forwardRef(({ onApply, handleGroupBy, setFilterdata }
onApply(filterWithStatus); onApply(filterWithStatus);
handleGroupBy(selectedGroup.id); handleGroupBy(selectedGroup.id);
setAppliedStatusId(status); setAppliedStatusId(status);
} }
}, [ }, [
@ -146,7 +145,7 @@ const ExpenseFilterPanel = forwardRef(({ onApply, handleGroupBy, setFilterdata }
handleGroupBy, handleGroupBy,
selectedGroup.id, selectedGroup.id,
appliedStatusId, appliedStatusId,
selectedProjectId, // added dependency selectedProjectId, // Added dependency
]); ]);

View File

@ -36,17 +36,13 @@ const Header = () => {
const isProjectPath = /^\/projects$/.test(location.pathname); const isProjectPath = /^\/projects$/.test(location.pathname);
const showProjectDropdown = (pathname) => { const showProjectDropdown = (pathname) => {
const isDirectoryPath = /^\/directory$/.test(pathname); // Paths where we DON'T want to show the project dropdown
const excludedPaths = ["/directory", "/expenses", "/employee"];
// const isProfilePage = /^\/employee$/.test(location.pathname); // Check if pathname starts with any of the excluded paths
const isProfilePage = return !excludedPaths.some((path) => pathname.startsWith(path));
/^\/employee\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(
pathname
);
const isExpensePage = /^\/expenses$/.test(pathname);
return !(isDirectoryPath || isProfilePage || isExpensePage);
}; };
const allowedProjectStatusIds = [ const allowedProjectStatusIds = [
"603e994b-a27f-4e5d-a251-f3d69b0498ba", "603e994b-a27f-4e5d-a251-f3d69b0498ba",
"cdad86aa-8a56-4ff4-b633-9c629057dfef", "cdad86aa-8a56-4ff4-b633-9c629057dfef",

View File

@ -95,6 +95,7 @@ const router = createBrowserRouter(
{ path: "/activities/reports", element: <Reports /> }, { path: "/activities/reports", element: <Reports /> },
{ path: "/gallary", element: <ImageGalleryPage /> }, { path: "/gallary", element: <ImageGalleryPage /> },
{ path: "/expenses/:status?/:project?", element: <ExpensePage /> }, { path: "/expenses/:status?/:project?", element: <ExpensePage /> },
{ path: "/expenses", element: <ExpensePage /> },
{ path: "/masters", element: <MasterPage /> }, { path: "/masters", element: <MasterPage /> },
{ path: "/tenants", element: <TenantPage /> }, { path: "/tenants", element: <TenantPage /> },
{ path: "/tenants/new-tenant", element: <CreateTenant /> }, { path: "/tenants/new-tenant", element: <CreateTenant /> },