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

feat(ojoi): add Cases in progress screen for OJOI #16492

Merged
merged 8 commits into from
Oct 22, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { ReactNode } from 'react'

import {
Box,
GridColumn,
Expand All @@ -17,7 +15,7 @@ import * as s from './OJOIHomeIntro.css'

export type OJOIHomeIntroProps = {
organization?: Organization
breadCrumbs: ReactNode
breadCrumbs: React.ReactNode
searchPlaceholder: string
quickLinks: Array<{ title: string; href: string; variant?: TagVariant }>
searchUrl: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import format from 'date-fns/format'
import is from 'date-fns/locale/is'

import { LinkV2, Table as T, Text } from '@island.is/island-ui/core'
import { Locale } from '@island.is/shared/types'
import { OfficialJournalOfIcelandAdvertsResponse } from '@island.is/web/graphql/schema'
import { useLinkResolver } from '@island.is/web/hooks'

import { formatDate } from './OJOIUtils'

export const OJOISearchListView = ({
adverts,
locale,
Expand All @@ -31,9 +30,7 @@ export const OJOISearchListView = ({
<T.Row key={ad.id}>
<T.Data>
<Text variant="small" whiteSpace="nowrap">
{format(new Date(ad.publicationDate), 'dd.MM.yyyy', {
locale: is,
})}
{formatDate(ad.publicationDate)}
</Text>
</T.Data>
<T.Data>
Expand Down
46 changes: 45 additions & 1 deletion apps/web/components/OfficialJournalOfIceland/OJOIWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
BreadCrumbItem,
Breadcrumbs,
Button,
GridColumn,
GridContainer,
GridRow,
LinkV2,
Text,
} from '@island.is/island-ui/core'
Expand All @@ -28,6 +31,7 @@ type WrapperProps = {
sidebarContent?: ReactNode
goBackUrl?: string
hideTitle?: boolean
isHomePage?: boolean
}

export const OJOIWrapper = ({
Expand All @@ -40,6 +44,7 @@ export const OJOIWrapper = ({
sidebarContent,
goBackUrl,
hideTitle,
isHomePage,
}: WrapperProps) => {
const { width } = useWindowSize()
const [isMobile, setIsMobile] = useState<boolean | undefined>()
Expand Down Expand Up @@ -133,7 +138,46 @@ export const OJOIWrapper = ({
</SidebarLayout>
)}

{!sidebarContent && children}
{!sidebarContent && !isHomePage && (
<GridContainer>
<GridRow>
<GridColumn span="12/12">
{breadcrumbItems && (
<Breadcrumbs
items={breadcrumbItems ?? []}
renderLink={(link, item) => {
return item?.href ? (
<NextLink href={item?.href} legacyBehavior>
{link}
</NextLink>
) : (
link
)
}}
/>
)}

{!hideTitle && (
<Text as="h1" variant="h1" marginTop={2} marginBottom={3}>
{pageTitle}
</Text>
)}

{pageDescription && (
<Box className="rs_read" marginTop={3} paddingBottom={4}>
<Text variant="default">{pageDescription}</Text>
</Box>
)}

<Box className="rs_read" marginBottom={'containerGutter'}>
{children}
</Box>
</GridColumn>
</GridRow>
</GridContainer>
)}

{!sidebarContent && isHomePage && children}

<Box className="rs_read" background="blue100">
<WebFooter
Expand Down
11 changes: 11 additions & 0 deletions apps/web/pages/stjornartidindi/mal-i-vinnslu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import withApollo from '@island.is/web/graphql/withApollo'
import { withLocale } from '@island.is/web/i18n'
import OJOICasesInProgress from '@island.is/web/screens/OfficialJournalOfIceland/OJOICasesInProgress'
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')(OJOICasesInProgress))
Valur marked this conversation as resolved.
Show resolved Hide resolved

export default Screen

export const getServerSideProps = getServerSidePropsWrapper(Screen)
170 changes: 170 additions & 0 deletions apps/web/screens/OfficialJournalOfIceland/OJOICasesInProgress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import { useIntl } from 'react-intl'

import { Table as T } from '@island.is/island-ui/core'
import { Locale } from '@island.is/shared/types'
import {
ContentLanguage,
CustomPageUniqueIdentifier,
OfficialJournalOfIcelandCase,
Query,
QueryGetOrganizationArgs,
QueryOfficialJournalOfIcelandCasesInProgressArgs,
} from '@island.is/web/graphql/schema'
import { useLinkResolver } from '@island.is/web/hooks'
import { withMainLayout } from '@island.is/web/layouts/main'
import { CustomNextError } from '@island.is/web/units/errors'

import {
formatDate,
OJOIWrapper,
} from '../../components/OfficialJournalOfIceland'
import {
CustomScreen,
withCustomPageWrapper,
} from '../CustomPage/CustomPageWrapper'
import { GET_ORGANIZATION_QUERY } from '../queries'
import { CASES_IN_PROGRESS_QUERY } from '../queries/OfficialJournalOfIceland'
import { m } from './messages'

const OJOICasesInProgressPage: CustomScreen<OJOICasesInProgressProps> = ({
cases,
organization,
locale,
}) => {
const { formatMessage } = useIntl()
const { linkResolver } = useLinkResolver()

const baseUrl = linkResolver('ojoihome', [], locale).href

const breadcrumbItems = [
{
title: 'Ísland.is',
href: linkResolver('homepage', [], locale).href,
},
Valur marked this conversation as resolved.
Show resolved Hide resolved
{
title: organization?.title ?? '',
href: baseUrl,
},
{
title: 'Mál í vinnslu',
},
]
Valur marked this conversation as resolved.
Show resolved Hide resolved

return (
<OJOIWrapper
pageTitle={formatMessage(m.casesInProgress.title)}
pageDescription={formatMessage(m.casesInProgress.description)}
organization={organization ?? undefined}
pageFeaturedImage={formatMessage(m.home.featuredImage)}
goBackUrl={baseUrl}
breadcrumbItems={breadcrumbItems}
>
{!cases || cases.length === 0 ? (
<p>{formatMessage(m.casesInProgress.notFoundMessage)}</p>
) : (
<T.Table>
<T.Head>
<T.Row>
<T.HeadData>
{formatMessage(m.casesInProgress.createdAt)}
</T.HeadData>
<T.HeadData>
{formatMessage(m.casesInProgress.requestedPublicationDate)}
</T.HeadData>
<T.HeadData>
{formatMessage(m.casesInProgress.advertTitle)}
</T.HeadData>
<T.HeadData>
{formatMessage(m.casesInProgress.involvedParty)}
</T.HeadData>
</T.Row>
</T.Head>
<T.Body>
{cases.map((c) => (
<T.Row key={c.id}>
<T.Data>{formatDate(c.createdAt)}</T.Data>
<T.Data>{formatDate(c.requestedPublicationDate)}</T.Data>
<T.Data>{c.advertType.title + ' ' + c.advertTitle}</T.Data>
<T.Data>{c.involvedParty.title}</T.Data>
</T.Row>
))}
</T.Body>
</T.Table>
)}
</OJOIWrapper>
)
}

interface OJOICasesInProgressProps {
cases?: Array<OfficialJournalOfIcelandCase>
organization?: Query['getOrganization']
locale: Locale
}

const OJOICasesInProgress: CustomScreen<OJOICasesInProgressProps> = ({
cases,
organization,
customPageData,
locale,
}) => {
return (
<OJOICasesInProgressPage
cases={cases}
organization={organization}
locale={locale}
customPageData={customPageData}
/>
)
}

OJOICasesInProgress.getProps = async ({ apolloClient, locale }) => {
const organizationSlug = 'stjornartidindi'

const [
{
data: { officialJournalOfIcelandCasesInProgress },
},
{
data: { getOrganization },
},
] = await Promise.all([
apolloClient.query<Query, QueryOfficialJournalOfIcelandCasesInProgressArgs>(
{
query: CASES_IN_PROGRESS_QUERY,
variables: {
params: {},
},
},
),
apolloClient.query<Query, QueryGetOrganizationArgs>({
query: GET_ORGANIZATION_QUERY,
variables: {
input: {
slug: organizationSlug,
lang: locale as ContentLanguage,
Valur marked this conversation as resolved.
Show resolved Hide resolved
},
Valur marked this conversation as resolved.
Show resolved Hide resolved
},
}),
])

if (!getOrganization?.hasALandingPage) {
throw new CustomNextError(404, 'Organization page not found')
}

return {
cases: officialJournalOfIcelandCasesInProgress?.cases,
organization: getOrganization,
locale: locale as Locale,
showSearchInHeader: false,
themeConfig: {
footerVersion: 'organization',
},
}
}

export default withMainLayout(
withCustomPageWrapper(
CustomPageUniqueIdentifier.OfficialJournalOfIceland,
OJOICasesInProgress,
),
)
1 change: 1 addition & 0 deletions apps/web/screens/OfficialJournalOfIceland/OJOIHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const OJOIHomePage: CustomScreen<OJOIHomeProps> = ({
pageDescription={formatMessage(m.home.description)}
organization={organization ?? undefined}
pageFeaturedImage={formatMessage(m.home.featuredImage)}
isHomePage
>
<Stack space={SLICE_SPACING}>
<OJOIHomeIntro
Expand Down
31 changes: 31 additions & 0 deletions apps/web/screens/OfficialJournalOfIceland/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,35 @@ export const m = {
defaultMessage: 'Sækja PDF',
},
}),

casesInProgress: defineMessages({
title: {
id: 'web.ojoi:casesInProgress.title',
defaultMessage: 'Mál í vinnslu',
},
description: {
id: 'web.ojoi:casesInProgress.description',
defaultMessage: 'Listi yfir mál sem hafa ekki verið gefin út.',
},
notFoundMessage: {
id: 'web.ojoi:casesInProgress.notFoundMessage',
defaultMessage: 'Engin mál í vinnslu',
},
createdAt: {
id: 'web.ojoi:casesInProgress.createdAt',
defaultMessage: 'Innsending',
},
requestedPublicationDate: {
id: 'web.ojoi:casesInProgress.requestedPublicationDate',
defaultMessage: 'Áætl. útgáfud.',
},
advertTitle: {
id: 'web.ojoi:casesInProgress.advertTitle',
defaultMessage: 'Heiti',
},
involvedParty: {
id: 'web.ojoi:casesInProgress.involvedParty',
defaultMessage: 'Stofnun',
},
}),
}
29 changes: 29 additions & 0 deletions apps/web/screens/queries/OfficialJournalOfIceland.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,32 @@ export const MAIN_CATEGORIES_QUERY = gql`
}
}
`

export const CASES_IN_PROGRESS_QUERY = gql`
query CasesInProgress($params: OfficialJournalOfIcelandQueryInput!) {
officialJournalOfIcelandCasesInProgress(params: $params) {
cases {
id
advertType {
title
}
advertTitle
involvedParty {
title
}
createdAt
requestedPublicationDate
}
paging {
page
pageSize
totalPages
totalItems
hasNextPage
hasPreviousPage
nextPage
previousPage
}
}
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export class AdvertsInput {
involvedParty?: string[]

@Field(() => Date, { nullable: true })
dateFrom?: Date
dateFrom?: string

@Field(() => Date, { nullable: true })
dateTo?: Date
dateTo?: string
Valur marked this conversation as resolved.
Show resolved Hide resolved
}

@InputType('OfficialJournalOfIcelandTypesInput')
Expand Down
Loading
Loading