From 08bb708b9ca15e7c723ac4959b9fe96b2dce7b82 Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan Date: Thu, 9 Jan 2025 12:02:25 +0530 Subject: [PATCH 1/4] facilityId to nav-user/footer --- src/components/ui/sidebar/app-sidebar.tsx | 4 +++- src/components/ui/sidebar/nav-user.tsx | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/ui/sidebar/app-sidebar.tsx b/src/components/ui/sidebar/app-sidebar.tsx index f88eb77e771..150000315b7 100644 --- a/src/components/ui/sidebar/app-sidebar.tsx +++ b/src/components/ui/sidebar/app-sidebar.tsx @@ -126,7 +126,9 @@ export function AppSidebar({ - {(facilitySidebar || selectedOrganization) && } + {(facilitySidebar || selectedOrganization) && ( + + )} {patientSidebar && } diff --git a/src/components/ui/sidebar/nav-user.tsx b/src/components/ui/sidebar/nav-user.tsx index 9a36b79a8ae..f7acf866abd 100644 --- a/src/components/ui/sidebar/nav-user.tsx +++ b/src/components/ui/sidebar/nav-user.tsx @@ -27,7 +27,11 @@ import useAuthUser, { useAuthContext } from "@/hooks/useAuthUser"; import { usePatientSignOut } from "@/hooks/usePatientSignOut"; import { usePatientContext } from "@/hooks/usePatientUser"; -export function FacilityNavUser() { +export function FacilityNavUser({ + selectedFacilityId, +}: { + selectedFacilityId?: string; +}) { const { t } = useTranslation(); const user = useAuthUser(); const { isMobile, open, setOpenMobile } = useSidebar(); @@ -94,7 +98,10 @@ export function FacilityNavUser() { { - navigate(`/users/${user.username}`); + const profileUrl = selectedFacilityId + ? `/facility/${selectedFacilityId}/users/${user.username}` + : `/users/${user.username}`; + navigate(profileUrl); if (isMobile) { setOpenMobile(false); } From 45792064ead58db4a0b2927c94b3dd9d3195613b Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan Date: Sat, 11 Jan 2025 12:41:54 +0530 Subject: [PATCH 2/4] userhome url fix --- src/components/Users/UserHome.tsx | 5 ++++- src/components/ui/sidebar/app-sidebar.tsx | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/Users/UserHome.tsx b/src/components/Users/UserHome.tsx index e37a95b3976..2629f81df34 100644 --- a/src/components/Users/UserHome.tsx +++ b/src/components/Users/UserHome.tsx @@ -84,6 +84,9 @@ export default function UserHome(props: UserHomeProps) { } const SelectedTab = TABS[currentTab].body; + const userUrl = props.facilityId + ? `/facility/${props.facilityId}/users/${username}` + : `/users/${username}`; return ( <> @@ -120,7 +123,7 @@ export default function UserHome(props: UserHomeProps) { ? "border-b-2 border-primary-500 text-primary-600 hover:border-secondary-300" : "text-secondary-700 hover:text-secondary-700", )} - href={`/facility/${props.facilityId}/users/${username}/${p.toLocaleLowerCase()}`} + href={`${userUrl}/${p.toLocaleLowerCase()}`} >
{t(`USERMANAGEMENT_TAB__${p}`)} diff --git a/src/components/ui/sidebar/app-sidebar.tsx b/src/components/ui/sidebar/app-sidebar.tsx index 150000315b7..43206261b6a 100644 --- a/src/components/ui/sidebar/app-sidebar.tsx +++ b/src/components/ui/sidebar/app-sidebar.tsx @@ -127,7 +127,11 @@ export function AppSidebar({ {(facilitySidebar || selectedOrganization) && ( - + )} {patientSidebar && } From 9299d11ab3d64dd5c8da1bbff3294895412a5ec8 Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan Date: Sat, 11 Jan 2025 13:18:01 +0530 Subject: [PATCH 3/4] breadcrumbs fix --- src/components/Common/Breadcrumbs.tsx | 8 +++++++- src/components/Common/PageTitle.tsx | 7 ++++++- src/components/Users/UserHome.tsx | 15 +++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/components/Common/Breadcrumbs.tsx b/src/components/Common/Breadcrumbs.tsx index 3ccc5494f75..5437db0336d 100644 --- a/src/components/Common/Breadcrumbs.tsx +++ b/src/components/Common/Breadcrumbs.tsx @@ -40,7 +40,12 @@ const capitalize = (string: string) => interface BreadcrumbsProps { replacements?: { - [key: string]: { name?: string; uri?: string; style?: string }; + [key: string]: { + name?: string; + uri?: string; + style?: string; + hide?: boolean; + }; }; className?: string; hideBack?: boolean; @@ -62,6 +67,7 @@ export default function Breadcrumbs({ const crumbs = path ?.slice(1) .split("/") + .filter((field) => replacements[field]?.hide !== true) .map((field, i) => ({ name: replacements[field]?.name || MENU_TAGS[field] || capitalize(field), uri: diff --git a/src/components/Common/PageTitle.tsx b/src/components/Common/PageTitle.tsx index 6c7d9abc38d..97fca6ba7e5 100644 --- a/src/components/Common/PageTitle.tsx +++ b/src/components/Common/PageTitle.tsx @@ -11,7 +11,12 @@ export interface PageTitleProps { componentRight?: ReactNode; breadcrumbs?: boolean; crumbsReplacements?: { - [key: string]: { name?: string; uri?: string; style?: string }; + [key: string]: { + name?: string; + uri?: string; + style?: string; + hide?: boolean; + }; }; focusOnLoad?: boolean; isInsidePage?: boolean; diff --git a/src/components/Users/UserHome.tsx b/src/components/Users/UserHome.tsx index 2629f81df34..06d0bdc2555 100644 --- a/src/components/Users/UserHome.tsx +++ b/src/components/Users/UserHome.tsx @@ -88,17 +88,20 @@ export default function UserHome(props: UserHomeProps) { ? `/facility/${props.facilityId}/users/${username}` : `/users/${username}`; + const crumbsReplacements = { + ...(loggedInUser + ? { [username]: { name: "Profile" } } + : { [username]: { name: username } }), + ...(!props.facilityId && { users: { hide: true } }), + }; + return ( <> { From e75c9dbcb1e6e9c98593646fb88543b0fbb6d4a0 Mon Sep 17 00:00:00 2001 From: Jacob John Jeevan Date: Mon, 13 Jan 2025 22:02:31 +0530 Subject: [PATCH 4/4] minor tweaks per feedback --- src/components/Users/UserHome.tsx | 12 ++++++++---- src/components/ui/sidebar/app-sidebar.tsx | 6 +++--- src/components/ui/sidebar/nav-user.tsx | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/Users/UserHome.tsx b/src/components/Users/UserHome.tsx index 06d0bdc2555..34345657d30 100644 --- a/src/components/Users/UserHome.tsx +++ b/src/components/Users/UserHome.tsx @@ -88,11 +88,15 @@ export default function UserHome(props: UserHomeProps) { ? `/facility/${props.facilityId}/users/${username}` : `/users/${username}`; + const usernameCrumb = { + [username]: { name: loggedInUser ? "Profile" : username }, + }; + + const hideUsersCrumb = { users: { hide: true } }; + const crumbsReplacements = { - ...(loggedInUser - ? { [username]: { name: "Profile" } } - : { [username]: { name: username } }), - ...(!props.facilityId && { users: { hide: true } }), + ...usernameCrumb, + ...(!props.facilityId && hideUsersCrumb), }; return ( diff --git a/src/components/ui/sidebar/app-sidebar.tsx b/src/components/ui/sidebar/app-sidebar.tsx index 43206261b6a..b70b79711d2 100644 --- a/src/components/ui/sidebar/app-sidebar.tsx +++ b/src/components/ui/sidebar/app-sidebar.tsx @@ -128,9 +128,9 @@ export function AppSidebar({ {(facilitySidebar || selectedOrganization) && ( )} {patientSidebar && } diff --git a/src/components/ui/sidebar/nav-user.tsx b/src/components/ui/sidebar/nav-user.tsx index f7acf866abd..426ec8b5bee 100644 --- a/src/components/ui/sidebar/nav-user.tsx +++ b/src/components/ui/sidebar/nav-user.tsx @@ -30,7 +30,7 @@ import { usePatientContext } from "@/hooks/usePatientUser"; export function FacilityNavUser({ selectedFacilityId, }: { - selectedFacilityId?: string; + selectedFacilityId: string | undefined; }) { const { t } = useTranslation(); const user = useAuthUser();