Skip to content

Commit

Permalink
fix(ojoi): Bug fixes and add adverts to web project. (#16388)
Browse files Browse the repository at this point in the history
* Fixed bugs found in testing phase.

* Changed to fetch five latest adverts and updated UI to wrap the categories

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
jonbjarnio and kodiakhq[bot] authored Oct 15, 2024
1 parent 4ab0c90 commit 5ce0312
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 37 deletions.
10 changes: 8 additions & 2 deletions apps/web/components/OfficialJournalOfIceland/OJOIAdvertCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ export const OJOIAdvertCard = ({
<Text>{title}</Text>
</Box>
)}
<Box display="flex" justifyContent="spaceBetween" marginTop={2}>
<Box
display="flex"
flexWrap="wrap"
justifyContent="spaceBetween"
marginTop={2}
rowGap={1}
>
{categories && categories.length && (
<Box display="flex" rowGap={1} columnGap={1}>
<Box display="flex" rowGap={1} columnGap={1} flexWrap="wrap">
{categories.map((cat) => {
return (
<Tag key={cat} variant="blue" outlined disabled>
Expand Down
30 changes: 30 additions & 0 deletions apps/web/components/OfficialJournalOfIceland/OJOIAdvertCards.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { OfficialJournalOfIcelandAdvertsResponse } from '@island.is/api/schema'
import { Stack } from '@island.is/island-ui/core'
import { Locale } from '@island.is/shared/types'
import { linkResolver } from '@island.is/web/hooks'

import { OJOIAdvertCard } from './OJOIAdvertCard'

type Props = {
adverts?: OfficialJournalOfIcelandAdvertsResponse['adverts']
locale: Locale
}

export const OJOIAdvertCards = ({ adverts, locale }: Props) => {
return (
<Stack space={3}>
{adverts?.map((ad) => (
<OJOIAdvertCard
key={ad.id}
institution={ad.involvedParty?.title}
department={ad.department?.title}
publicationNumber={ad.publicationNumber?.full}
publicationDate={ad.publicationDate}
title={ad.title}
categories={ad.categories?.map((cat) => cat.title)}
link={linkResolver('ojoiadvert', [ad.id], locale).href}
/>
))}
</Stack>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const OJOISearchListView = ({
adverts,
locale,
}: {
adverts: OfficialJournalOfIcelandAdvertsResponse['adverts']
adverts?: OfficialJournalOfIcelandAdvertsResponse['adverts']
locale: Locale
}) => {
const { linkResolver } = useLinkResolver()
Expand All @@ -27,7 +27,7 @@ export const OJOISearchListView = ({
</T.Row>
</T.Head>
<T.Body>
{adverts.map((ad) => (
{adverts?.map((ad) => (
<T.Row key={ad.id}>
<T.Data>
<Text variant="small" whiteSpace="nowrap">
Expand Down
1 change: 1 addition & 0 deletions apps/web/components/OfficialJournalOfIceland/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export { OJOIAdvertDisplay } from './OJOIAdvertDisplay'
export { OJOIAdvertCard } from './OJOIAdvertCard'
export { OJOISearchListView } from './OJOISearchListView'
export { OJOISearchGridView } from './OJOISearchGridView'
export { OJOIAdvertCards } from './OJOIAdvertCards'
export * from './OJOIUtils'
88 changes: 77 additions & 11 deletions apps/web/screens/OfficialJournalOfIceland/OJOIHome.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { useIntl } from 'react-intl'
import NextLink from 'next/link'
import { useQuery } from '@apollo/client'

import {
AlertMessage,
ArrowLink,
Box,
Breadcrumbs,
CategoryCard,
GridColumn,
GridContainer,
GridRow,
SkeletonLoader,
Stack,
Text,
} from '@island.is/island-ui/core'
Expand All @@ -18,24 +21,32 @@ import {
ContentLanguage,
CustomPageUniqueIdentifier,
OfficialJournalOfIcelandAdvertMainCategory,
OfficialJournalOfIcelandAdvertsResponse,
Query,
QueryGetOrganizationArgs,
QueryOfficialJournalOfIcelandAdvertsArgs,
QueryOfficialJournalOfIcelandMainCategoriesArgs,
} 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 {
OJOIAdvertCard,
OJOIAdvertCards,
OJOIHomeIntro,
OJOISearchListView,
OJOIWrapper,
} from '../../components/OfficialJournalOfIceland'
import {
CustomScreen,
withCustomPageWrapper,
} from '../CustomPage/CustomPageWrapper'
import { GET_ORGANIZATION_QUERY } from '../queries'
import { MAIN_CATEGORIES_QUERY } from '../queries/OfficialJournalOfIceland'
import {
ADVERTS_QUERY,
MAIN_CATEGORIES_QUERY,
} from '../queries/OfficialJournalOfIceland'
import { m } from './messages'

const OJOIHomePage: CustomScreen<OJOIHomeProps> = ({
Expand All @@ -61,6 +72,23 @@ const OJOIHomePage: CustomScreen<OJOIHomeProps> = ({
},
]

const { data, loading, error } = useQuery<
{
officialJournalOfIcelandAdverts: OfficialJournalOfIcelandAdvertsResponse
},
QueryOfficialJournalOfIcelandAdvertsArgs
>(ADVERTS_QUERY, {
variables: {
input: {
page: 1,
pageSize: 5,
},
},
fetchPolicy: 'no-cache',
})

const adverts = data?.officialJournalOfIcelandAdverts.adverts

return (
<OJOIWrapper
pageTitle={organization?.title ?? ''}
Expand Down Expand Up @@ -124,16 +152,54 @@ const OJOIHomePage: CustomScreen<OJOIHomeProps> = ({

<Box background="blue100" paddingTop={8} paddingBottom={8}>
<GridContainer>
<Box
display={'flex'}
justifyContent={'spaceBetween'}
alignItems="flexEnd"
>
<Text variant="h3">{formatMessage(m.home.mainCategories)}</Text>
<ArrowLink href={categoriesUrl}>
{formatMessage(m.home.allCategories)}
</ArrowLink>
</Box>
<GridRow>
<GridColumn span="12/12">
<Box
display={'flex'}
justifyContent={'spaceBetween'}
alignItems="flexEnd"
marginBottom={3}
>
<Text variant="h3">
{formatMessage(m.home.mainCategories)}
</Text>
<ArrowLink href={categoriesUrl}>
{formatMessage(m.home.allCategories)}
</ArrowLink>
</Box>
</GridColumn>
</GridRow>

<GridRow>
<GridColumn span="12/12">
<Text marginBottom={3} variant="h3">
{formatMessage(m.home.latestAdverts)}
</Text>

<Stack space={3}>
{loading && <SkeletonLoader repeat={4} height={200} />}
{error && (
<AlertMessage
type="warning"
message={formatMessage(
m.search.errorFetchingAdvertsMessage,
)}
title={formatMessage(m.search.errorFetchingAdvertsTitle)}
/>
)}
{!error && !adverts?.length && (
<AlertMessage
type="info"
message={formatMessage(m.search.emptySearchResult)}
/>
)}

{adverts && (
<OJOIAdvertCards adverts={adverts} locale={locale} />
)}
</Stack>
</GridColumn>
</GridRow>

<GridRow>
{mainCategories?.map((y, i) => (
Expand Down
17 changes: 17 additions & 0 deletions apps/web/screens/OfficialJournalOfIceland/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,30 @@ export const m = {
id: 'web.ojoi:home.mainCategories',
defaultMessage: 'Yfirflokkar',
},
latestAdverts: {
id: 'web.ojoi:home.latestAdverts',
defaultMessage: 'Nýjustu auglýsingar',
},
allCategories: {
id: 'web.ojoi:home.allCategories',
defaultMessage: 'Málaflokkar A-Ö',
},
}),

search: defineMessages({
emptySearchResult: {
id: 'web.ojoi:search.emptySearchResult',
defaultMessage: 'Engin mál fundust',
},
errorFetchingAdvertsTitle: {
id: 'web.ojoi:search.errorFetchingAdvertsTitle',
defaultMessage: 'Ekki tókst að sækja auglýsingar',
},
errorFetchingAdvertsMessage: {
id: 'web.ojoi:search.errorFetchingAdvertsMessage',
defaultMessage:
'Ekki náðist samband við vefþjónustur Stjórnartíðinda, reynið aftur síðar.',
},
title: {
id: 'web.ojoi:search.title',
defaultMessage: 'Leit í Stjórnartíðindum',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,24 @@ export const Chairman = ({ applicationId, member }: Props) => {
}
/>
<SignatureMember
name={`signature.comittee.member.after`}
label={f(signatures.inputs.after.label)}
defaultValue={member.after}
name={`signature.comittee.member.name`}
label={f(signatures.inputs.name.label)}
defaultValue={member.name}
onChange={(e) =>
debouncedOnUpdateApplicationHandler(
handleChairmanChange(e.target.value, 'after'),
handleChairmanChange(e.target.value, 'name'),
)
}
/>
</Box>
<Box className={styles.inputWrapper}>
<SignatureMember
name={`signature.comittee.member.name`}
label={f(signatures.inputs.name.label)}
defaultValue={member.name}
name={`signature.comittee.member.after`}
label={f(signatures.inputs.after.label)}
defaultValue={member.after}
onChange={(e) =>
debouncedOnUpdateApplicationHandler(
handleChairmanChange(e.target.value, 'name'),
handleChairmanChange(e.target.value, 'after'),
)
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ export const RegularMember = ({
}
/>
<SignatureMember
name={`signature.regular.member.after.${signatureIndex}.${memberIndex}`}
label={f(signatures.inputs.after.label)}
defaultValue={member.after}
name={`signature.regular.member.name.${signatureIndex}.${memberIndex}`}
label={f(signatures.inputs.name.label)}
defaultValue={member.name}
onChange={(e) =>
debouncedOnUpdateApplicationHandler(
handleMemberChange(
e.target.value,
'after',
'name',
signatureIndex,
memberIndex,
),
Expand All @@ -135,14 +135,14 @@ export const RegularMember = ({
</Box>
<Box className={styles.inputWrapper}>
<SignatureMember
name={`signature.regular.member.name.${signatureIndex}.${memberIndex}`}
label={f(signatures.inputs.name.label)}
defaultValue={member.name}
name={`signature.regular.member.after.${signatureIndex}.${memberIndex}`}
label={f(signatures.inputs.after.label)}
defaultValue={member.after}
onChange={(e) =>
debouncedOnUpdateApplicationHandler(
handleMemberChange(
e.target.value,
'name',
'after',
signatureIndex,
memberIndex,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const ALLOWED_FILE_TYPES = ['.pdf', '.doc', '.docx']

export const FILE_SIZE_LIMIT = 10000000

export const OJOI_DF = 'd. MMMM yyyy.'

export const VERDSKRA_LINK =
'https://www.stjornartidindi.is/PdfVersions.aspx?recordId=0f574646-eb9d-430b-bbe7-936e7c9389a0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const attachments = {
general: defineMessages({
title: {
id: 'ojoi.application:attachments.general.title',
defaultMessage: 'Viðaukar og fylgirit',
defaultMessage: 'Viðaukar og fylgiskjöl',
description: 'Title of the addition and documents form',
},
intro: {
Expand All @@ -15,7 +15,7 @@ export const attachments = {
},
section: {
id: 'ojoi.application:attachments.general.section',
defaultMessage: 'Viðaukar og fylgirit',
defaultMessage: 'Viðaukar og fylgiskjöl',
description: 'Title of the addition and documents section',
},
}),
Expand Down Expand Up @@ -55,7 +55,7 @@ export const attachments = {
documents: defineMessages({
label: {
id: 'ojoi.application:attachments.radio.documents.label',
defaultMessage: 'Fylgirit (I, II, III..)',
defaultMessage: 'Fylgiskjöl (I, II, III..)',
description: 'Label of the documents radio button',
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const publishing = {
communicationIntro: {
id: 'ojoi.application:publishing.general.communicationIntro',
defaultMessage:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sit amet mattis erat, eget dignissim lacus. Cras id enim ac urna bibendum gravida.',
'Hér getur þú skráð inn tölvupóstfang og/eða símanúmer þess sem best er að hafa samskipti við vegna málsins, hægt að skrá fleiri en einn.',
description: 'Intro of the communication section',
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { InputFields, OJOIApplication, RequiredInputFieldsNames } from './types'
import { HTMLText } from '@island.is/regulations-tools/types'
import format from 'date-fns/format'
import is from 'date-fns/locale/is'
import { SignatureTypes } from './constants'
import { SignatureTypes, OJOI_DF } from './constants'
import { MessageDescriptor } from 'react-intl'

export const countDaysAgo = (date: Date) => {
Expand Down Expand Up @@ -211,7 +211,7 @@ const signatureTemplate = (
}

const date = signature.date
? format(new Date(signature.date), 'dd. MMM yyyy.', { locale: is })
? format(new Date(signature.date), OJOI_DF, { locale: is })
: ''

const chairmanMarkup = chairman
Expand Down

0 comments on commit 5ce0312

Please sign in to comment.