-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbb109e
commit b7e2298
Showing
9 changed files
with
293 additions
and
96 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
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
apps/web/pages/en/[slug]/[subSlug]/[genericListItemSlug]/index.ts
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,12 @@ | ||
import withApollo from '@island.is/web/graphql/withApollo' | ||
import { withLocale } from '@island.is/web/i18n' | ||
import GenericListItem from '@island.is/web/screens/GenericList/GenericListItem' | ||
import { getServerSidePropsWrapper } from '@island.is/web/utils/getServerSidePropsWrapper' | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore make web strict | ||
const Screen = withApollo(withLocale('en')(GenericListItem)) | ||
|
||
export default Screen | ||
|
||
export const getServerSideProps = getServerSidePropsWrapper(Screen) |
12 changes: 12 additions & 0 deletions
12
apps/web/pages/en/o/[slug]/[subSlug]/[genericListItemSlug]/index.ts
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,12 @@ | ||
import withApollo from '@island.is/web/graphql/withApollo' | ||
import { withLocale } from '@island.is/web/i18n' | ||
import { Component } from '@island.is/web/pages/s/[slug]/[subSlug]/[genericListItemSlug]' | ||
import { getServerSidePropsWrapper } from '@island.is/web/utils/getServerSidePropsWrapper' | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore make web strict | ||
const Screen = withApollo(withLocale('en')(Component)) | ||
|
||
export default Screen | ||
|
||
export const getServerSideProps = getServerSidePropsWrapper(Screen) |
12 changes: 12 additions & 0 deletions
12
apps/web/pages/en/p/[slug]/[subSlug]/[genericListItemSlug]/index.ts
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,12 @@ | ||
import withApollo from '@island.is/web/graphql/withApollo' | ||
import { withLocale } from '@island.is/web/i18n' | ||
import GenericListItem from '@island.is/web/screens/GenericList/GenericListItem' | ||
import { getServerSidePropsWrapper } from '@island.is/web/utils/getServerSidePropsWrapper' | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore make web strict | ||
const Screen = withApollo(withLocale('en')(GenericListItem)) | ||
|
||
export default Screen | ||
|
||
export const getServerSideProps = getServerSidePropsWrapper(Screen) |
98 changes: 98 additions & 0 deletions
98
apps/web/pages/s/[slug]/[subSlug]/[genericListItemSlug]/index.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,98 @@ | ||
import { useMemo } from 'react' | ||
import { useRouter } from 'next/router' | ||
|
||
import withApollo from '@island.is/web/graphql/withApollo' | ||
import { useLinkResolver } from '@island.is/web/hooks' | ||
import { useI18n, withLocale } from '@island.is/web/i18n' | ||
import { LayoutProps } from '@island.is/web/layouts/main' | ||
import GenericListItemPage, { | ||
type GenericListItemPageProps, | ||
} from '@island.is/web/screens/GenericList/GenericListItem' | ||
import SubPageLayout, { | ||
type SubPageProps, | ||
} from '@island.is/web/screens/Organization/SubPage' | ||
import type { Screen as ScreenType } from '@island.is/web/types' | ||
import { CustomNextError } from '@island.is/web/units/errors' | ||
import { getServerSidePropsWrapper } from '@island.is/web/utils/getServerSidePropsWrapper' | ||
|
||
interface ComponentProps { | ||
parentProps: { | ||
layoutProps: LayoutProps | ||
componentProps: SubPageProps | ||
} | ||
genericListItemProps: GenericListItemPageProps | ||
} | ||
|
||
export const Component: ScreenType<ComponentProps> = ({ | ||
parentProps, | ||
genericListItemProps, | ||
}) => { | ||
const { activeLocale } = useI18n() | ||
const router = useRouter() | ||
const { linkResolver } = useLinkResolver() | ||
const backLinkUrl = useMemo(() => { | ||
const pathname = new URL(router.asPath, 'https://island.is').pathname | ||
return pathname.slice(0, pathname.lastIndexOf('/')) | ||
}, [router.asPath]) | ||
|
||
return ( | ||
<SubPageLayout | ||
layoutProps={parentProps.layoutProps} | ||
componentProps={{ | ||
...parentProps.componentProps, | ||
customContent: <GenericListItemPage item={genericListItemProps.item} />, | ||
customBreadcrumbItems: [ | ||
{ | ||
title: 'Ísland.is', | ||
href: linkResolver('homepage').href, | ||
}, | ||
{ | ||
title: parentProps.componentProps.organizationPage?.title ?? '', | ||
href: linkResolver('organizationpage', [ | ||
parentProps.componentProps.organizationPage?.slug ?? '', | ||
]).href, | ||
}, | ||
{ | ||
title: parentProps.componentProps.subpage?.title ?? '', | ||
href: backLinkUrl, | ||
isTag: true, | ||
}, | ||
], | ||
backLink: { | ||
text: activeLocale === 'is' ? 'Til baka' : 'Go back', // TODO: perhaps read this value from contentful | ||
url: backLinkUrl, | ||
}, | ||
}} | ||
/> | ||
) | ||
} | ||
|
||
Component.getProps = async (ctx) => { | ||
const [parentProps, genericListItemProps] = await Promise.all([ | ||
SubPageLayout.getProps?.(ctx), | ||
GenericListItemPage.getProps?.(ctx), | ||
]) | ||
|
||
if (!parentProps) { | ||
throw new CustomNextError( | ||
404, | ||
'Could not fetch subpage layout for generic list item', | ||
) | ||
} | ||
if (!genericListItemProps) { | ||
throw new CustomNextError(404, 'Could not fetch generic list item props') | ||
} | ||
|
||
return { | ||
parentProps, | ||
genericListItemProps, | ||
} | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore make web strict | ||
const Screen = withApollo(withLocale('is')(Component)) | ||
|
||
export default Screen | ||
|
||
export const getServerSideProps = getServerSidePropsWrapper(Screen) |
12 changes: 12 additions & 0 deletions
12
apps/web/pages/v/[slug]/[subSlug]/[genericListItemSlug]/index.ts
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,12 @@ | ||
import withApollo from '@island.is/web/graphql/withApollo' | ||
import { withLocale } from '@island.is/web/i18n' | ||
import GenericListItem from '@island.is/web/screens/GenericList/GenericListItem' | ||
import { getServerSidePropsWrapper } from '@island.is/web/utils/getServerSidePropsWrapper' | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore make web strict | ||
const Screen = withApollo(withLocale('is')(GenericListItem)) | ||
|
||
export default Screen | ||
|
||
export const getServerSideProps = getServerSidePropsWrapper(Screen) |
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
Oops, something went wrong.