-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(service-portal-core): Conditial org query in tab navigation (#16166)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
94ab9ec
commit b78609d
Showing
2 changed files
with
48 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
libs/service-portal/core/src/components/TabNavigation/TabNavigationInstitutionPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { GridColumn } from '@island.is/island-ui/core' | ||
import { useOrganization } from '@island.is/service-portal/graphql' | ||
import InstitutionPanel from '../InstitutionPanel/InstitutionPanel' | ||
import { MessageDescriptor } from 'react-intl' | ||
import { OrganizationSlugType } from '@island.is/shared/constants' | ||
import { useLocale } from '@island.is/localization' | ||
import { useWindowSize } from 'react-use' | ||
import { theme } from '@island.is/island-ui/theme' | ||
|
||
interface Props { | ||
serviceProvider: OrganizationSlugType | ||
tooltipText?: MessageDescriptor | ||
} | ||
|
||
export const TabNavigationInstitutionPanel = ({ | ||
tooltipText, | ||
serviceProvider, | ||
}: Props) => { | ||
const { formatMessage } = useLocale() | ||
const { data: organization, loading } = useOrganization(serviceProvider) | ||
const { width } = useWindowSize() | ||
|
||
const isMobile = width < theme.breakpoints.md | ||
|
||
return ( | ||
<GridColumn span="1/8" offset="1/8"> | ||
{organization?.logo && ( | ||
<InstitutionPanel | ||
loading={loading} | ||
linkHref={organization.link ?? ''} | ||
linkLabel={organization.title} | ||
img={organization.logo?.url ?? ''} | ||
tooltipText={tooltipText ? formatMessage(tooltipText) : ''} | ||
imgContainerDisplay={isMobile ? 'block' : 'flex'} | ||
/> | ||
)} | ||
</GridColumn> | ||
) | ||
} |