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(web): Multiple updates for grants #17488

Merged
merged 34 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
59d403d
fix: init
thorkellmani Jan 14, 2025
3ebf8b9
fix: stuff
thorkellmani Jan 14, 2025
7dafb92
feat: add card sorting in slice
thorkellmani Jan 14, 2025
f737a18
fix: date parsing
thorkellmani Jan 14, 2025
9c78001
feat: add new rich text field 'answering questions'
thorkellmani Jan 14, 2025
e6d206d
chore: cleanup
thorkellmani Jan 15, 2025
484e968
feat: lots of stuff
thorkellmani Jan 17, 2025
1bcf771
chore: revert bank info form change
thorkellmani Jan 17, 2025
3a80614
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 17, 2025
fb15977
fix: search quicklinks
thorkellmani Jan 20, 2025
b64a2ec
fix: conditional deadline display2
thorkellmani Jan 20, 2025
d713f26
feat: change search indexer
thorkellmani Jan 21, 2025
1171644
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 21, 2025
e966931
feat: filtering works
thorkellmani Jan 23, 2025
9ff26d0
fix: filtering worskga .ga .
thorkellmani Jan 23, 2025
b38ca0d
chore: revert dev changes
thorkellmani Jan 23, 2025
92db5c5
fix: orgaization filtering
thorkellmani Jan 23, 2025
3e7830e
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 23, 2025
8655414
chore: remove extra lines2
thorkellmani Jan 23, 2025
750de38
Merge remote-tracking branch 'refs/remotes/origin/fix/grant-cards-lis…
thorkellmani Jan 23, 2025
80b67fd
chore: missing return
thorkellmani Jan 23, 2025
11b2632
chore: remove improt
thorkellmani Jan 23, 2025
9cbe61c
fix: translation strings
thorkellmani Jan 23, 2025
1c4e698
fix: wrong dates in filtering
thorkellmani Jan 23, 2025
5731066
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 24, 2025
fe97698
fix: mobile ui
thorkellmani Jan 24, 2025
9b743af
chore: remove hardcoded value
thorkellmani Jan 24, 2025
b7a1164
chore: remove import
thorkellmani Jan 24, 2025
2272ea9
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 24, 2025
4ffe6e2
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 24, 2025
ed961ca
Merge branch 'main' into fix/grant-cards-list
disaerna Jan 24, 2025
36fe94a
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 24, 2025
ddfb04e
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 24, 2025
1e86640
Merge branch 'main' into fix/grant-cards-list
thorkellmani Jan 24, 2025
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
71 changes: 54 additions & 17 deletions apps/web/components/GrantCardsList/GrantCardsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import localeEN from 'date-fns/locale/en-GB'
import localeIS from 'date-fns/locale/is'
import { useRouter } from 'next/router'

import { ActionCard, Box, InfoCardGrid } from '@island.is/island-ui/core'
import { ActionCard, Box, InfoCardGrid, Text } from '@island.is/island-ui/core'
import { Locale } from '@island.is/shared/types'
import { isDefined } from '@island.is/shared/utils'
import {
Expand All @@ -20,6 +20,12 @@ interface SliceProps {
slice: GrantCardsListSchema
}

const OPEN_GRANT_STATUSES = [
GrantStatus.AlwaysOpen,
GrantStatus.Open,
GrantStatus.OpenWithNote,
]

const formatDate = (
date: Date,
locale: Locale,
Expand Down Expand Up @@ -108,24 +114,48 @@ const GrantCardsList = ({ slice }: SliceProps) => {
}
}

if (slice.resolvedGrantsList?.items.length === 1) {
const grant = slice.resolvedGrantsList.items[0]
const grantItems = slice.resolvedGrantsList?.items ?? []

if (grantItems.length === 1) {
const grant = grantItems[0]

const cardText = `${getTranslationString(
grant?.status && OPEN_GRANT_STATUSES.includes(grant.status)
? 'applicationOpen'
: 'applicationClosed',
)} / ${parseStatus(grant)}`

return (
<ActionCard
heading={grant.name}
backgroundColor="blue"
cta={{
disabled: !grant.applicationUrl?.slug,
label: grant.applicationButtonLabel ?? getTranslationString('apply'),
onClick: () => router.push(grant.applicationUrl?.slug ?? ''),
icon: 'open',
iconType: 'outline',
}}
/>
<>
{slice.displayTitle && (
<Box marginBottom={2}>
<Text variant="h3" as="span" color="dark400">
{slice.title}
</Text>
</Box>
)}
<ActionCard
heading={grant.name}
text={cardText}
backgroundColor="blue"
cta={{
disabled:
!grant?.status ||
grant.status === GrantStatus.Closed ||
grant.status === GrantStatus.Unknown,
size: 'small',
label:
grant.applicationButtonLabel ?? getTranslationString('apply'),
onClick: () => router.push(grant.applicationUrl?.slug ?? ''),
icon: 'open',
iconType: 'outline',
}}
/>
</>
)
}

const cards = slice.resolvedGrantsList?.items
const cards = grantItems
?.map((grant) => {
if (grant.id) {
return {
Expand Down Expand Up @@ -183,14 +213,21 @@ const GrantCardsList = ({ slice }: SliceProps) => {
.filter(isDefined)

return (
<Box padding={1} borderColor="blue100" borderRadius="large">
<>
{slice.displayTitle && (
<Box marginBottom={2}>
<Text variant="h3" as="span" color="dark400">
{slice.title}
</Text>
</Box>
)}
<InfoCardGrid
columns={1}
cardsBorder="blue200"
variant="detailed"
cards={cards ?? []}
/>
</Box>
</>
)
}

Expand Down
34 changes: 29 additions & 5 deletions apps/web/screens/Grants/Grant/Grant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ const GrantSinglePage: CustomScreen<GrantSingleProps> = ({ grant, locale }) => {
return null
}

const applicationStatusLabel = status?.applicationStatus
? generateStatusTag(status.applicationStatus, formatMessage)?.label
: undefined

return (
<GrantWrapper
pageTitle={grant.name}
Expand Down Expand Up @@ -117,11 +121,13 @@ const GrantSinglePage: CustomScreen<GrantSingleProps> = ({ grant, locale }) => {
<ActionCard
heading={grant.name}
text={
status
? generateStatusTag(status.applicationStatus, formatMessage)
?.label +
(status.deadlineStatus ? ' / ' + status.deadlineStatus : '')
: ''
applicationStatusLabel
? `${applicationStatusLabel}${
status?.deadlineStatus
? ' / ' + status.deadlineStatus
: ''
}`
: undefined
}
backgroundColor="blue"
cta={{
Expand Down Expand Up @@ -181,6 +187,24 @@ const GrantSinglePage: CustomScreen<GrantSingleProps> = ({ grant, locale }) => {
</>
) : undefined}

{grant.answeringQuestions?.length ? (
<>
<Box>
<Text variant="h3">
{formatMessage(m.single.answeringQuestions)}
</Text>
<Box className="rs_read">
{webRichText(
grant.answeringQuestions as SliceType[],
undefined,
locale,
)}
</Box>
</Box>
<Divider />
</>
) : undefined}

{grant.applicationHints?.length ? (
<Box className="rs_read">
{webRichText(
Expand Down
89 changes: 56 additions & 33 deletions apps/web/screens/Grants/Home/GrantsHome.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo } from 'react'
import { useIntl } from 'react-intl'
import NextLink from 'next/link'

Expand All @@ -13,6 +14,7 @@ import {
Text,
} from '@island.is/island-ui/core'
import { Locale } from '@island.is/shared/types'
import { isDefined } from '@island.is/shared/utils'
import { GrantSearchSection } from '@island.is/web/components'
import { SLICE_SPACING } from '@island.is/web/constants'
import {
Expand Down Expand Up @@ -61,6 +63,22 @@ const GrantsHomePage: CustomScreen<GrantsHomeProps> = ({
},
]

const categorySlugs: Array<CategorySlug> = useMemo(() => {
const ordering: Array<string> | null =
customPageData?.configJson?.categoryOrdering ?? null
if (!ordering) {
return [...CATEGORY_TAG_SLUGS]
}

return ordering
.map((slug) => {
if (CATEGORY_TAG_SLUGS.includes(slug as CategorySlug)) {
return slug as CategorySlug
}
})
.filter(isDefined)
}, [customPageData?.configJson?.categoryOrdering])

return (
<Box>
<Stack space={SLICE_SPACING}>
Expand All @@ -76,29 +94,26 @@ const GrantsHomePage: CustomScreen<GrantsHomeProps> = ({
customPageData?.ogImage?.url ?? formatMessage(m.home.featuredImage)
}
featuredImageAlt={formatMessage(m.home.featuredImageAlt)}
//TODO - do when the categories are ready
quickLinks={[
{
title: 'Listamannalaun',
href: searchUrl + '?category=menning-og-listir',
title: formatMessage(m.bullets.open),
href: searchUrl + '?status=open',
},
{
title: 'Barnamenningarsjóður',
href: searchUrl + '?category=nam-og-kennsla',
title: formatMessage(m.bullets.nativeFunds),
href: searchUrl + '?category=grant-category-native',
},
{
title: 'Tónlistarsjóður',
href: searchUrl + '?category=nyskopun',
title: formatMessage(m.bullets.technologyDevelopmentFund),
href: searchUrl + '?query=tækniþróunar',
},
{
title: 'Rannís',
href: searchUrl + '?organization=rannis',
variant: 'purple',
title: formatMessage(m.bullets.financing),
href: searchUrl + '?type=grant-type-financing',
},
{
title: 'Erasmus',
href: searchUrl + '?organization=erasmus',
variant: 'purple',
title: formatMessage(m.bullets.companies),
href: searchUrl + '?query=fyrirtæki',
},
]}
breadcrumbs={
Expand Down Expand Up @@ -135,26 +150,34 @@ const GrantsHomePage: CustomScreen<GrantsHomeProps> = ({
</Box>

<GridRow>
{categories?.map((c) => (
<GridColumn
key={c.slug}
span={['1/1', '1/2', '1/2', '1/3']}
paddingTop={3}
paddingBottom={3}
>
<CategoryCard
href={`${searchUrl}?category=${c.slug}`}
heading={c.title}
text={
CATEGORY_TAG_SLUGS.includes(c.slug as CategorySlug)
? formatMessage(
mapTagToMessageId(c.slug as CategorySlug),
)
: ''
}
/>
</GridColumn>
))}
{categorySlugs
?.map((c) => {
const category = categories?.find((ct) => c === ct.slug)

if (!category) {
return undefined
}

return (
<GridColumn
key={c}
span={['1/1', '1/2', '1/2', '1/3']}
paddingTop={3}
paddingBottom={3}
>
<CategoryCard
href={`${searchUrl}?category=${c}`}
heading={category.title}
text={
CATEGORY_TAG_SLUGS.includes(c)
? formatMessage(mapTagToMessageId(c))
: ''
}
/>
</GridColumn>
)
})
.filter(isDefined)}
</GridRow>
</GridContainer>
</Box>
Expand Down
Loading
Loading