Changes in OnField Work.

This commit is contained in:
Kartik Sharma 2025-10-15 16:52:27 +05:30
parent 73534226e3
commit b318d469f6
3 changed files with 10 additions and 10 deletions

View File

@ -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, selectedProjectId]);
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,10 +145,9 @@ const ExpenseFilterPanel = forwardRef(({ onApply, handleGroupBy, setFilterdata }
handleGroupBy, handleGroupBy,
selectedGroup.id, selectedGroup.id,
appliedStatusId, appliedStatusId,
selectedProjectId, // added dependency selectedProjectId, // Added dependency
]); ]);
if (isLoading || isFetching) return <ExpenseFilterSkeleton />; if (isLoading || isFetching) return <ExpenseFilterSkeleton />;
if (isError && isFetched) if (isError && isFetched)
return <div>Something went wrong Here- {error.message} </div>; return <div>Something went wrong Here- {error.message} </div>;

View File

@ -36,16 +36,17 @@ const Header = () => {
const pathname = location.pathname; const pathname = location.pathname;
// ======= MEMO CHECKS ======= // ======= MEMO CHECKS =======
const isDashboardPath = pathname === "/" || pathname === "/dashboard"; const isDashboardPath = pathname === "/" || pathname === "/dashboard";
const isProjectPath = pathname === "/projects"; const isProjectPath = pathname === "/projects";
const isDirectory = pathname === "/directory"; const isDirectory = pathname === "/directory";
const isEmployeeList = pathname === "/employees"; const isEmployeeList = pathname === "/employees";
const isMasters = pathname === "/masters";
// const isExpense = pathname === "/expenses";
const isEmployeeProfile = UUID_REGEX.test(pathname); const isEmployeeProfile = UUID_REGEX.test(pathname);
const isMasters = pathname === "/masters";
const isExpensePath = pathname.startsWith("/expenses");
const hideDropPaths = const hideDropPaths =
isDirectory || isEmployeeList || isMasters || isEmployeeProfile; isDirectory || isEmployeeList || isMasters || isEmployeeProfile || isExpensePath;
const showProjectDropdown = !hideDropPaths; const showProjectDropdown = !hideDropPaths;

View File

@ -95,6 +95,7 @@ const router = createBrowserRouter(
{ path: "/activities/reports", element: <Reports /> }, { path: "/activities/reports", element: <Reports /> },
{ path: "/gallary", element: <ComingSoonPage /> }, { path: "/gallary", element: <ComingSoonPage /> },
{ 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 /> },