Skip to content

Commit

Permalink
Merge branch 'main' into feat/accident-notification-procure
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 12, 2024
2 parents facbaf8 + 37fe92b commit e2bb3d7
Show file tree
Hide file tree
Showing 26 changed files with 394 additions and 77 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Text } from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'
import { m } from '@island.is/portals/my-pages/core'

import { useBff } from '@island.is/react-spa/bff'
import { useAuth } from '@island.is/react-spa/bff'
import * as styles from './AuthOverlay.css'

const AuthOverlay = () => {
const { authState } = useBff()
const { authState } = useAuth()
const { formatMessage } = useLocale()

if (authState === 'switching')
Expand Down
4 changes: 4 additions & 0 deletions apps/services/bff/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ Runs tests with Jest and outputs coverage to `coverage/apps/services/bff`.
## Code owners and maintainers

- [Aranja](https://github.com/orgs/island-is/teams/aranja/members)

## Troubleshooting

If you encounter any issues while setting up or running the BFF service, please refer to the [Troubleshooting Guide](TROUBLESHOOT_GUIDE.md)
37 changes: 37 additions & 0 deletions apps/services/bff/TROUBLESHOOT_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# BFF Service Troubleshooting Guide

## Common Issues and Solutions

- Make sure that you are running the `dev` script and not `start` script. For example when running the service portal you should run:
`yarn dev service-portal` and not `yarn start service-portal`.

- Make sure to install dependencies and run code generation with the following command:
`yarn install && yarn codegen`.

- Make sure to login to the correct AWS account and region:

- Run `aws sso login --profile islandis-dev` to login to the correct AWS account.

- Not necessary but a nice to have is to have Redis server running:

- Run `yarn dev-services services-bff` to start Redis server.
- This is necessary if you want the sessions to persist.

- Make sure that you are not running the same service twice, since you could already be running a service like API.
Lets take `yarn dev application-system-form` as an example. This script starts the following services:

- `yarn get-secrets application-system-api`
- `yarn nx run application-system-api:dev-services`
- `yarn nx run application-system-api:migrate`
- `yarn nx codegen/backend-schema api`
- `yarn nx run services-user-profile:dev-init`
- `yarn nx run service-portal:start-bff`
- `yarn start application-system-form`
So make sure that you are not running the same service twice.

- If you are running the service on Windows, we recommend using [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) for running the services within the repo.
This is because all of the scripts generated by the `infra` package are not tested on Windows and may not work as expected.

- On macOS, the AirPlay Receiver is listening on the same port as the Redis server, e.g. 7000. Either change the port or disable the AirPlay Receiver.

- If everything fails, then a good old computer restart might do the trick.
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
Loading

0 comments on commit e2bb3d7

Please sign in to comment.