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

fix(web): Connect language toggler for standalone organization pages #17055

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/web/layouts/organization/standalone/standalone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SkipToMainContent,
} from '@island.is/web/components'
import { PRELOADED_FONTS } from '@island.is/web/constants'
import { GlobalContextProvider } from '@island.is/web/context'
import { OrganizationPage } from '@island.is/web/graphql/schema'
import { useLinkResolver } from '@island.is/web/hooks'
import { useI18n } from '@island.is/web/i18n'
Expand Down Expand Up @@ -87,7 +88,7 @@ export const StandaloneLayout = ({
const featuredImage = seo?.image ?? organizationPage.featuredImage

return (
<>
<GlobalContextProvider>
<Head>
{PRELOADED_FONTS.map((href, index) => {
return (
Expand Down Expand Up @@ -270,6 +271,6 @@ export const StandaloneLayout = ({
url('/fonts/ibm-plex-sans-v7-latin-600.woff') format('woff');
}
`}</style>
</>
</GlobalContextProvider>
)
}
7 changes: 7 additions & 0 deletions apps/web/screens/Organization/Standalone/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
QueryGetOrganizationPageArgs,
} from '@island.is/web/graphql/schema'
import { useNamespace } from '@island.is/web/hooks'
import useContentfulId from '@island.is/web/hooks/useContentfulId'
import { StandaloneLayout } from '@island.is/web/layouts/organization/standalone'
import type { Screen, ScreenContext } from '@island.is/web/types'
import { CustomNextError } from '@island.is/web/units/errors'
Expand All @@ -27,6 +28,11 @@ export interface StandaloneHomeProps {
namespace: Record<string, string>
}

const LanguageToggleSetup = (props: { id: string }) => {
useContentfulId(props.id)
return null
}
RunarVestmann marked this conversation as resolved.
Show resolved Hide resolved

const StandaloneHome: Screen<
StandaloneHomeProps,
StandaloneHomeScreenContext
Expand All @@ -43,6 +49,7 @@ const StandaloneHome: Screen<
isFrontpage={true}
bannerTitle={n('bannerTitle', '')}
>
<LanguageToggleSetup id={organizationPage.id} />
<Stack space={SLICE_SPACING}>
<Stack space={SLICE_SPACING}>
{organizationPage.slices.map((slice) => {
Expand Down
9 changes: 9 additions & 0 deletions apps/web/screens/Organization/Standalone/ParentSubpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
QueryGetOrganizationSubpageArgs,
} from '@island.is/web/graphql/schema'
import { useLinkResolver } from '@island.is/web/hooks'
import useContentfulId from '@island.is/web/hooks/useContentfulId'
import { useI18n } from '@island.is/web/i18n'
import { StandaloneLayout } from '@island.is/web/layouts/organization/standalone'
import type { Screen, ScreenContext } from '@island.is/web/types'
Expand Down Expand Up @@ -52,6 +53,11 @@ export interface StandaloneParentSubpageProps {
namespace: Record<string, string>
}

const LanguageToggleSetup = (props: { ids: string[] }) => {
useContentfulId(...props.ids)
return null
}

const StandaloneParentSubpage: Screen<
StandaloneParentSubpageProps,
StandaloneParentSubpageScreenContext
Expand All @@ -69,6 +75,9 @@ const StandaloneParentSubpage: Screen<

return (
<StandaloneLayout organizationPage={organizationPage}>
<LanguageToggleSetup
ids={[organizationPage.id, parentSubpage.id, subpage.id]}
/>
<GridContainer>
<GridRow>
<GridColumn span={['9/9', '9/9', '7/9']} offset={['0', '0', '1/9']}>
Expand Down
1 change: 1 addition & 0 deletions apps/web/screens/queries/Organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ export const GET_ORGANIZATION_PARENT_SUBPAGE_QUERY = gql`
$input: GetOrganizationParentSubpageInput!
) {
getOrganizationParentSubpage(input: $input) {
id
title
childLinks {
label
Expand Down
Loading