-
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.
feat(ojoi): add Cases in progress screen for OJOI
- Loading branch information
Showing
15 changed files
with
929 additions
and
14 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
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
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
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,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)) | ||
|
||
export default Screen | ||
|
||
export const getServerSideProps = getServerSidePropsWrapper(Screen) |
170 changes: 170 additions & 0 deletions
170
apps/web/screens/OfficialJournalOfIceland/OJOICasesInProgress.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,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, | ||
}, | ||
{ | ||
title: organization?.title ?? '', | ||
href: baseUrl, | ||
}, | ||
{ | ||
title: 'Mál í vinnslu', | ||
}, | ||
] | ||
|
||
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, | ||
}, | ||
}, | ||
}), | ||
]) | ||
|
||
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, | ||
), | ||
) |
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
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
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
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.