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 e37a95b3976..34345657d30 100644 --- a/src/components/Users/UserHome.tsx +++ b/src/components/Users/UserHome.tsx @@ -84,18 +84,28 @@ export default function UserHome(props: UserHomeProps) { } const SelectedTab = TABS[currentTab].body; + const userUrl = props.facilityId + ? `/facility/${props.facilityId}/users/${username}` + : `/users/${username}`; + + const usernameCrumb = { + [username]: { name: loggedInUser ? "Profile" : username }, + }; + + const hideUsersCrumb = { users: { hide: true } }; + + const crumbsReplacements = { + ...usernameCrumb, + ...(!props.facilityId && hideUsersCrumb), + }; return ( <> { @@ -120,7 +130,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 f88eb77e771..b70b79711d2 100644 --- a/src/components/ui/sidebar/app-sidebar.tsx +++ b/src/components/ui/sidebar/app-sidebar.tsx @@ -126,7 +126,13 @@ 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..426ec8b5bee 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 | undefined; +}) { 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); }