Skip to content

Commit

Permalink
Merge branch 'main' into rental-agreement-application
Browse files Browse the repository at this point in the history
  • Loading branch information
addi authored Dec 12, 2024
2 parents 887b460 + 37fe92b commit 1b22da7
Show file tree
Hide file tree
Showing 20 changed files with 340 additions and 64 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
6 changes: 3 additions & 3 deletions apps/native/app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ react {
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
reactNativeDir = file("../../../../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
codegenDir = file("../../../../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
cliFile = file("../../../../../node_modules/react-native/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand Down
4 changes: 2 additions & 2 deletions apps/native/app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
url("$rootDir/../../../../../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
url("$rootDir/../../../../../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
Expand Down
5 changes: 1 addition & 4 deletions apps/native/app/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ applyNativeModulesSettingsGradle(settings)
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../../../../node_modules/react-native-code-push/android/app')

include ':react-native-clipboard'
project(':react-native-clipboard').projectDir = new File(rootProject.projectDir, '../../node_modules/@react-native-clipboard/clipboard/android')

include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
includeBuild('../../../../node_modules/@react-native/gradle-plugin')

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()
2 changes: 1 addition & 1 deletion apps/native/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"react-native-pdf": "6.7.5",
"react-native-quick-actions": "0.3.13",
"react-native-quick-base64": "2.1.2",
"react-native-reanimated": "3.12.1",
"react-native-reanimated": "3.16.5",
"react-native-share": "10.2.1",
"react-native-spotlight-search": "2.0.0",
"react-native-svg": "15.2.0",
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
2 changes: 1 addition & 1 deletion codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ workflows:
- island-upload-keystore
groups:
- google_credentials
- firebase_credentials
- firebase_credentials_dev
vars:
<<: *shared_envs
PACKAGE_NAME: 'is.island.app.dev'
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
Loading

0 comments on commit 1b22da7

Please sign in to comment.