Changes in expense filter panel.
This commit is contained in:
parent
bd6332fa61
commit
b23518f796
@ -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
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,27 +26,23 @@ const Header = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { data, loading } = useMaster();
|
const { data, loading } = useMaster();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const {onOpen} = useAuthModal()
|
const { onOpen } = useAuthModal()
|
||||||
const { onOpen:changePass } = useModal("ChangePassword");
|
const { onOpen: changePass } = useModal("ChangePassword");
|
||||||
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
|
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
|
||||||
const { mutate : logout,isPending:logouting} = useLogout()
|
const { mutate: logout, isPending: logouting } = useLogout()
|
||||||
|
|
||||||
const isDashboardPath =
|
const isDashboardPath =
|
||||||
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
|
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
|
||||||
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",
|
||||||
@ -59,9 +55,9 @@ const Header = () => {
|
|||||||
return role ? role.name : "User";
|
return role ? role.name : "User";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handleProfilePage = () => {
|
const handleProfilePage = () => {
|
||||||
navigate(`/employee/${profile?.employeeInfo?.id}`);
|
navigate(`/employee/${profile?.employeeInfo?.id}`);
|
||||||
@ -74,8 +70,8 @@ const Header = () => {
|
|||||||
const projectsForDropdown = isDashboardPath
|
const projectsForDropdown = isDashboardPath
|
||||||
? projectNames
|
? projectNames
|
||||||
: projectNames?.filter((project) =>
|
: projectNames?.filter((project) =>
|
||||||
allowedProjectStatusIds.includes(project.projectStatusId)
|
allowedProjectStatusIds.includes(project.projectStatusId)
|
||||||
);
|
);
|
||||||
|
|
||||||
let currentProjectDisplayName;
|
let currentProjectDisplayName;
|
||||||
if (projectLoading) {
|
if (projectLoading) {
|
||||||
@ -191,63 +187,63 @@ const Header = () => {
|
|||||||
>
|
>
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
{showProjectDropdown(location.pathname) && (
|
{showProjectDropdown(location.pathname) && (
|
||||||
<div className="align-items-center">
|
<div className="align-items-center">
|
||||||
<i className="rounded-circle bx bx-building-house bx-sm-lg bx-md me-2"></i>
|
<i className="rounded-circle bx bx-building-house bx-sm-lg bx-md me-2"></i>
|
||||||
<div className="btn-group">
|
<div className="btn-group">
|
||||||
{shouldShowDropdown ? (
|
{shouldShowDropdown ? (
|
||||||
<button
|
<button
|
||||||
className={`btn btn-sm-sm btn-xl dropdown-toggle px-1`}
|
className={`btn btn-sm-sm btn-xl dropdown-toggle px-1`}
|
||||||
type="button"
|
type="button"
|
||||||
data-bs-toggle="dropdown"
|
data-bs-toggle="dropdown"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
>
|
|
||||||
{currentProjectDisplayName}
|
|
||||||
</button>
|
|
||||||
) : (
|
|
||||||
<span className="btn btn-sm-sm btn-xl px-1">
|
|
||||||
{currentProjectDisplayName}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{shouldShowDropdown &&
|
|
||||||
projectsForDropdown &&
|
|
||||||
projectsForDropdown.length > 0 && (
|
|
||||||
<ul
|
|
||||||
className="dropdown-menu"
|
|
||||||
style={{ overflow: "auto", maxHeight: "300px" }}
|
|
||||||
>
|
>
|
||||||
{isDashboardPath && (
|
{currentProjectDisplayName}
|
||||||
<li>
|
</button>
|
||||||
<button
|
) : (
|
||||||
className="dropdown-item"
|
<span className="btn btn-sm-sm btn-xl px-1">
|
||||||
onClick={() => handleProjectChange(null)}
|
{currentProjectDisplayName}
|
||||||
>
|
</span>
|
||||||
All Projects
|
)}
|
||||||
</button>
|
|
||||||
</li>
|
{shouldShowDropdown &&
|
||||||
)}
|
projectsForDropdown &&
|
||||||
{[...projectsForDropdown]
|
projectsForDropdown.length > 0 && (
|
||||||
.sort((a, b) => a?.name?.localeCompare(b.name))
|
<ul
|
||||||
.map((project) => (
|
className="dropdown-menu"
|
||||||
<li key={project?.id}>
|
style={{ overflow: "auto", maxHeight: "300px" }}
|
||||||
|
>
|
||||||
|
{isDashboardPath && (
|
||||||
|
<li>
|
||||||
<button
|
<button
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
onClick={() => handleProjectChange(project?.id)}
|
onClick={() => handleProjectChange(null)}
|
||||||
>
|
>
|
||||||
{project?.name}
|
All Projects
|
||||||
{project?.shortName && (
|
|
||||||
<span className="text-primary fw-semibold ms-1">
|
|
||||||
({project?.shortName})
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
))}
|
)}
|
||||||
</ul>
|
{[...projectsForDropdown]
|
||||||
)}
|
.sort((a, b) => a?.name?.localeCompare(b.name))
|
||||||
|
.map((project) => (
|
||||||
|
<li key={project?.id}>
|
||||||
|
<button
|
||||||
|
className="dropdown-item"
|
||||||
|
onClick={() => handleProjectChange(project?.id)}
|
||||||
|
>
|
||||||
|
{project?.name}
|
||||||
|
{project?.shortName && (
|
||||||
|
<span className="text-primary fw-semibold ms-1">
|
||||||
|
({project?.shortName})
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul className="navbar-nav flex-row align-items-center ms-md-auto">
|
<ul className="navbar-nav flex-row align-items-center ms-md-auto">
|
||||||
@ -397,7 +393,7 @@ const Header = () => {
|
|||||||
<li>
|
<li>
|
||||||
<div className="dropdown-divider"></div>
|
<div className="dropdown-divider"></div>
|
||||||
</li>
|
</li>
|
||||||
<li onClick={()=>onOpen()}>
|
<li onClick={() => onOpen()}>
|
||||||
{" "}
|
{" "}
|
||||||
<a
|
<a
|
||||||
className="dropdown-item cusor-pointer"
|
className="dropdown-item cusor-pointer"
|
||||||
@ -435,7 +431,7 @@ const Header = () => {
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<div className="dropdown-divider"></div>
|
<div className="dropdown-divider"></div>
|
||||||
</li>
|
</li>
|
||||||
@ -443,10 +439,10 @@ const Header = () => {
|
|||||||
<a
|
<a
|
||||||
aria-label="click to log out"
|
aria-label="click to log out"
|
||||||
className="dropdown-item cusor-pointer"
|
className="dropdown-item cusor-pointer"
|
||||||
onClick={()=>logout()}
|
onClick={() => logout()}
|
||||||
>
|
>
|
||||||
{logouting ? "Please Wait":<> <i className="bx bx-log-out me-2"></i>
|
{logouting ? "Please Wait" : <> <i className="bx bx-log-out me-2"></i>
|
||||||
<span className="align-middle">SignOut</span></>}
|
<span className="align-middle">SignOut</span></>}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -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 /> },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user