Skip to content

Commit

Permalink
breadcrumbs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan committed Jan 11, 2025
1 parent 4579206 commit 9299d11
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/components/Common/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion src/components/Common/PageTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 9 additions & 6 deletions src/components/Users/UserHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<Page
title={formatName(userData) || userData.username || t("manage_user")}
crumbsReplacements={
loggedInUser
? { [username]: { name: "Profile" } }
: { [username]: { name: username } }
}
crumbsReplacements={crumbsReplacements}
focusOnLoad={true}
backUrl="/users"
backUrl={props.facilityId ? `/users` : "/"}
hideTitleOnPage
>
{
Expand Down

0 comments on commit 9299d11

Please sign in to comment.