From 59d403df7d8ebc54b4ff24d4070ffe9776f3dd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Eorkell=20M=C3=A1ni=20=C3=9Eorkelsson?= Date: Tue, 14 Jan 2025 11:18:18 +0000 Subject: [PATCH] fix: init --- .../GrantCardsList/GrantCardsList.tsx | 67 ++++++++++++++----- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/apps/web/components/GrantCardsList/GrantCardsList.tsx b/apps/web/components/GrantCardsList/GrantCardsList.tsx index 9f992da72daf..85ce3941bff4 100644 --- a/apps/web/components/GrantCardsList/GrantCardsList.tsx +++ b/apps/web/components/GrantCardsList/GrantCardsList.tsx @@ -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 { @@ -20,6 +20,12 @@ interface SliceProps { slice: GrantCardsListSchema } +const OPEN_GRANT_STATUSES = [ + GrantStatus.AlwaysOpen, + GrantStatus.Open, + GrantStatus.OpenWithNote, +] + const formatDate = ( date: Date, locale: Locale, @@ -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 ( - router.push(grant.applicationUrl?.slug ?? ''), - icon: 'open', - iconType: 'outline', - }} - /> + <> + {slice.displayTitle && ( + + + {slice.title} + + + )} + router.push(grant.applicationUrl?.slug ?? ''), + icon: 'open', + iconType: 'outline', + }} + /> + ) } - const cards = slice.resolvedGrantsList?.items + const cards = grantItems ?.map((grant) => { if (grant.id) { return { @@ -184,6 +214,13 @@ const GrantCardsList = ({ slice }: SliceProps) => { return ( + {slice.displayTitle && ( + + + {slice.title} + + + )}