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

panel:Add an extensionSlot for lab tab panels #28

Merged
merged 11 commits into from
Jan 16, 2024
34 changes: 21 additions & 13 deletions src/queue-list/laboratory-tabs.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const labPanelSlot = "lab-panels-slot";
const LaboratoryQueueTabs: React.FC = () => {
const { t } = useTranslation();
const [selectedTab, setSelectedTab] = useState(0);
const extensions = useConnectedExtensions(
const tabExtensions = useConnectedExtensions(
labPanelSlot
) as AssignedExtension[];

Expand All @@ -48,18 +48,26 @@ const LaboratoryQueueTabs: React.FC = () => {
<Tab>{t("referredTests", "Referred tests")}</Tab>
<Tab>{t("reviewList", "Review")}</Tab>
<Tab>{t("approveList", "Approved")}</Tab>
{extensions.map((extension, index) => (
<Tab
key={index}
className={styles.tab}
id={`${extension.meta.title || index}-tab`}
>
{t(extension.meta.title, {
ns: extension.moduleName,
defaultValue: extension.meta.title,
})}
</Tab>
))}
{tabExtensions
Copy link
Member

Choose a reason for hiding this comment

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

Please add the check here as well. Refer to previous comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hello @pirupius i added a check that makes sure that the title and name values of the extension.meta object are truthy before rendering the Tab which is automatically mapped to the corresponding TabPanel .
Kindly see the updated screenshot

.filter((extension) => Object.keys(extension.meta).length > 0)
.map((extension, index) => {
const { name, title } = extension.meta;

if (name && title) {
return (
<Tab
key={index}
className={styles.tab}
id={`${title || index}-tab`}
>
{t(title, {
ns: extension.moduleName,
defaultValue: title,
})}
</Tab>
);
}
})}
</TabList>
<TabPanels>
<TabPanel style={{ padding: 0 }}>
Expand Down
Loading