Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP DetailPage uber component #432

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

WIP DetailPage uber component #432

wants to merge 11 commits into from

Conversation

ir4y
Copy link
Member

@ir4y ir4y commented Jan 21, 2025

No description provided.

}
return (
<PageContainer title={getTitle(resource!)}>
<PageTabs tabs={tabs} basePath={basePath} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To proper display tabs on the page you need to place it to headerContent of PageContainer

<PageContainer
  title={getTitle(resource!)}
  layoutVariant="with-tabs"
  headerContent={
    <PageTabs tabs={tabs} basePath={basePath} />
  }
>


interface DetailPageProps<R extends Resource> {
resourceType: R['resourceType'];
getSearchParams: (params: Readonly<Params<string>>) => SearchParams;
Copy link
Member

@ruscoder ruscoder Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Params should be more specific because you're hard-coded to id below

const menuItems: RouteItem[] = tabs.map(({ label, path }) => ({
        label,
        path: `/${basePath}/${params.id}/${path}`,
});

I suggest using at least. Params & {id: string}

I think something like

getSearchParams: (params: Readonly<Params<string>>) => SearchParams;
getTitle: (resource: R) => string | undefined;
tabs: Array<Tab<R>>;
basePath: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need basePath here? Maybe we can use relative paths in links? e.g. ../path

export interface Tab<R extends Resource> {
label: string;
path?: string;
component: (resource: R) => JSX.Element;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about having uniform interface like in the ResourceListPage, when we pass {resource:R , bundle: Bundle} to the component. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also getTitle might have the similar interface ({resource,bundle}) for some use-cases (e.g. when we load Patient and we need to display it's managing organization)

path: `/${basePath}/${params.id}/${path}`,
}));

const [currentPath, setCurrentPath] = useState(location?.pathname);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should store currentPath in the state if we have location and we subscribed to it using useLocation. Just use location.pathname instead of currentPath

@pavlushkin
Copy link
Member

@pavlushkin
Copy link
Member

I suggest to add a new prop getHeaderActions for DetailPage.
A real feature I'd like to implement is to add a navigation action like:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants