Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-app-sys-changes-from-fa-back-in
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 12, 2024
2 parents 8ab2f13 + 32a256e commit 67b3017
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ export class InternalCaseService {
? {
name: theCase.prosecutor.name,
nationalId: theCase.prosecutor.nationalId,
email: theCase.prosecutor.email,
}
: undefined,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ describe('InternalCaseController - Deliver indictment info to court', () => {
{ eventType: EventType.INDICTMENT_CONFIRMED, created: indictmentDate },
],
defendants: [{ name: 'Test Ákærði', nationalId: '1234567890' }],
prosecutor: { name: 'Test Sækjandi', nationalId: '0101010101' },
prosecutor: {
name: 'Test Sækjandi',
nationalId: '0101010101',
email: '[email protected]',
},
} as Case

let mockCourtService: CourtService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ export class CourtService {
)

const isIndictment = isIndictmentCase(type)
const policeCaseNumber = policeCaseNumbers[0]
? policeCaseNumbers[0].replace(/-/g, '')
: ''

return await this.courtClientService.createCase(courtId, {
caseType: isIndictment ? 'S - Ákærumál' : 'R - Rannsóknarmál',
Expand All @@ -344,7 +347,7 @@ export class CourtService {
receivalDate: formatISO(receivalDate, { representation: 'date' }),
basedOn: isIndictment ? 'Sakamál' : 'Rannsóknarhagsmunir',
// TODO: pass in all policeCaseNumbers when CourtService supports it
sourceNumber: policeCaseNumbers[0] ? policeCaseNumbers[0] : '',
sourceNumber: policeCaseNumber,
})
} catch (reason) {
if (reason instanceof ServiceUnavailableException) {
Expand Down Expand Up @@ -569,14 +572,17 @@ export class CourtService {
policeCaseNumber?: string,
subtypes?: string[],
defendants?: { name?: string; nationalId?: string }[],
prosecutor?: { name?: string; nationalId?: string },
prosecutor?: { name?: string; nationalId?: string; email?: string },
): Promise<unknown> {
try {
const subject = `${courtName} - ${courtCaseNumber} - upplýsingar`

const sanitizedPoliceCaseNumber = policeCaseNumber?.replace(/-/g, '')

const content = JSON.stringify({
receivedByCourtDate,
indictmentDate,
policeCaseNumber,
sanitizedPoliceCaseNumber,
subtypes,
defendants,
prosecutor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('CourtService - Create court case', () => {
status: 'Skráð',
receivalDate: formatISO(receivalDate, { representation: 'date' }),
basedOn: 'Rannsóknarhagsmunir',
sourceNumber: policeCaseNumbers[0],
sourceNumber: policeCaseNumbers[0].replace(/-/g, ''),
},
)
})
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('CourtService - Create court case', () => {
status: 'Skráð',
receivalDate: formatISO(receivalDate, { representation: 'date' }),
basedOn: 'Sakamál',
sourceNumber: policeCaseNumbers[0],
sourceNumber: policeCaseNumbers[0].replace(/-/g, ''),
},
)
})
Expand Down Expand Up @@ -183,7 +183,7 @@ describe('CourtService - Create court case', () => {
status: 'Skráð',
receivalDate: formatISO(receivalDate, { representation: 'date' }),
basedOn: 'Rannsóknarhagsmunir',
sourceNumber: policeCaseNumbers[0],
sourceNumber: policeCaseNumbers[0].replace(/-/g, ''),
})
})
})
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('CourtService - Create court case', () => {
status: 'Skráð',
receivalDate: formatISO(receivalDate, { representation: 'date' }),
basedOn: 'Rannsóknarhagsmunir',
sourceNumber: policeCaseNumbers[0],
sourceNumber: policeCaseNumbers[0].replace(/-/g, ''),
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ const strings = defineMessages({
description:
'Notaður sem texti í valmöguleika fyrir það þegar ekki skal birta dómdfellda dóminn.',
},
serviceRequirementNotRequiredTooltip: {
id: 'judicial.system.core:court.indictments.completed.service_requirement_not_required_tooltip',
defaultMessage:
'Ekki þarf að birta dóm þar sem sektarfjárhæð er lægri en sem nemur áfrýjunarfjárhæð í einkamáli kr. 1.355.762. Gildir frá 01.01.2024',
description:
'Notað sem tooltip í valmöguleika fyrir það þegar ekki skal birta dómdfellda dóminn.',
},
serviceRequirementNotApplicable: {
id: 'judicial.system.core:court.indictments.completed.service_requirement_not_applicable',
defaultMessage: 'Dómfelldi var viðstaddur dómsuppkvaðningu',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ const Completed: FC = () => {
large
backgroundColor="white"
label={formatMessage(strings.serviceRequirementNotRequired)}
tooltip={formatMessage(
strings.serviceRequirementNotRequiredTooltip,
)}
/>
</BlueBox>
</Box>
Expand Down
22 changes: 16 additions & 6 deletions apps/services/bff/src/app/modules/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,24 @@ export class AuthService {
})
}

let loginAttemptData: LoginAttemptData | undefined
const loginAttemptCacheKey = this.cacheService.createSessionKeyType(
'attempt',
query.state,
)
// Get login attempt data from the cache
const loginAttemptData = await this.cacheService.get<LoginAttemptData>(
loginAttemptCacheKey,
// Do not throw an error if the key is not found
false,
)

try {
// Get login attempt from cache
loginAttemptData = await this.cacheService.get<LoginAttemptData>(
this.cacheService.createSessionKeyType('attempt', query.state),
)
if (!loginAttemptData) {
this.logger.warn(this.cacheService.createKeyError(loginAttemptCacheKey))

return this.redirectWithError(res)
}

try {
// Get tokens and user information from the authorization code
const tokenResponse = await this.idsService.getTokens({
code: query.code,
Expand Down
68 changes: 56 additions & 12 deletions apps/web/screens/Grants/Grant/GrantSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { useMemo } from 'react'

import { Box, Button, LinkV2, Stack, Text } from '@island.is/island-ui/core'
import {
Box,
BoxProps,
Button,
LinkV2,
Stack,
Text,
} from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'
import { Locale } from '@island.is/shared/types'
import { isDefined } from '@island.is/shared/utils'
import { InstitutionPanel } from '@island.is/web/components'
import { Grant } from '@island.is/web/graphql/schema'
import { LinkType, useLinkResolver } from '@island.is/web/hooks'

import { m } from '../messages'
import { useLocale } from '@island.is/localization'
import { generateStatusTag } from '../utils'

interface Props {
Expand All @@ -30,6 +37,20 @@ const generateLine = (heading: string, content?: React.ReactNode) => {
)
}

const generateSidebarPanel = (
data: Array<React.ReactElement>,
background: BoxProps['background'],
) => {
if (!data) {
return undefined
}
return (
<Box background={background} padding={3} borderRadius="standard">
<Stack space={2}>{data}</Stack>
</Box>
)
}

export const GrantSidebar = ({ grant, locale }: Props) => {
const { linkResolver } = useLinkResolver()
const { formatMessage } = useLocale()
Expand Down Expand Up @@ -100,6 +121,7 @@ export const GrantSidebar = ({ grant, locale }: Props) => {
return (
<LinkV2
key={`${f.url}-${index}`}
newTab
href={f.url}
underlineVisibility="hover"
>
Expand All @@ -113,6 +135,35 @@ export const GrantSidebar = ({ grant, locale }: Props) => {
[grant.files],
)

const supportLinksPanelData = useMemo(
() =>
grant.supportLinks
?.map((link) => {
if (!link.url || !link.text || !link.id) {
return null
}
return (
<LinkV2
newTab
key={link.id}
href={link.url}
underlineVisibility="hover"
>
<Button
size="medium"
icon="link"
iconType="outline"
variant="text"
>
{link.text}
</Button>
</LinkV2>
)
})
.filter(isDefined) ?? [],
[grant.supportLinks],
)

return (
<Stack space={3}>
<InstitutionPanel
Expand All @@ -124,16 +175,9 @@ export const GrantSidebar = ({ grant, locale }: Props) => {
img={grant.fund?.parentOrganization.logo?.url}
locale={locale}
/>
{detailPanelData.length ? (
<Box background="blue100" padding={3} borderRadius="standard">
<Stack space={2}>{detailPanelData}</Stack>
</Box>
) : undefined}
{filesPanelData.length ? (
<Box background="red100" padding={3} borderRadius="standard">
<Stack space={2}>{filesPanelData}</Stack>
</Box>
) : undefined}
{generateSidebarPanel(detailPanelData, 'blue100')}
{generateSidebarPanel(filesPanelData, 'red100')}
{generateSidebarPanel(supportLinksPanelData, 'purple100')}
</Stack>
)
}
6 changes: 6 additions & 0 deletions apps/web/screens/queries/Grants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export const GET_GRANT_QUERY = gql`
id
title
}
supportLinks {
id
text
url
date
}
files {
...AssetFields
}
Expand Down
3 changes: 3 additions & 0 deletions libs/cms/src/lib/generated/contentfulTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,9 @@ export interface IGrantFields {
/** Files */
grantFiles?: Asset[] | undefined

/** Support links */
grantSupportLinks?: ILink[] | undefined

/** Category tags */
grantCategoryTags?: IGenericTag[] | undefined

Expand Down
7 changes: 6 additions & 1 deletion libs/cms/src/lib/models/grant.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { mapDocument, SliceUnion } from '../unions/slice.union'
import { Asset, mapAsset } from './asset.model'
import { ReferenceLink, mapReferenceLink } from './referenceLink.model'
import { Fund, mapFund } from './fund.model'
import { Link, mapLink } from './link.model'

export enum GrantStatus {
CLOSED,
Expand Down Expand Up @@ -66,6 +67,9 @@ export class Grant {
@CacheField(() => [Asset], { nullable: true })
files?: Array<Asset>

@CacheField(() => [Link], { nullable: true })
supportLinks?: Array<Link>

@CacheField(() => [GenericTag], { nullable: true })
categoryTags?: Array<GenericTag>

Expand All @@ -85,7 +89,6 @@ export const mapGrant = ({ fields, sys }: IGrant): Grant => ({
applicationUrl: fields.granApplicationUrl?.fields
? mapReferenceLink(fields.granApplicationUrl)
: undefined,

specialEmphasis: fields.grantSpecialEmphasis
? mapDocument(fields.grantSpecialEmphasis, sys.id + ':special-emphasis')
: [],
Expand Down Expand Up @@ -117,6 +120,8 @@ export const mapGrant = ({ fields, sys }: IGrant): Grant => ({
: undefined,
fund: fields.grantFund ? mapFund(fields.grantFund) : undefined,
files: (fields.grantFiles ?? []).map((file) => mapAsset(file)) ?? [],
supportLinks:
(fields.grantSupportLinks ?? []).map((link) => mapLink(link)) ?? [],
categoryTags: fields.grantCategoryTags
? fields.grantCategoryTags.map((tag) => mapGenericTag(tag))
: undefined,
Expand Down
4 changes: 3 additions & 1 deletion libs/react-spa/bff/src/lib/BffPoller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const BffPoller = ({
const { signIn, bffUrlGenerator } = useAuth()
const userInfo = useUserInfo()
const { postMessage } = useBffBroadcaster()
const bffBaseUrl = bffUrlGenerator()

const url = useMemo(
() => bffUrlGenerator('/user', { refresh: 'true' }),
Expand Down Expand Up @@ -86,12 +87,13 @@ export const BffPoller = ({
postMessage({
type: BffBroadcastEvents.NEW_SESSION,
userInfo: newUser,
bffBaseUrl,
})

newSessionCb()
}
}
}, [newUser, error, userInfo, signIn, postMessage, newSessionCb])
}, [newUser, error, userInfo, signIn, postMessage, newSessionCb, bffBaseUrl])

return children
}
Loading

0 comments on commit 67b3017

Please sign in to comment.