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): Gopro verdicts #17215

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions apps/api/infra/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ export const serviceSetup = (services: {
'/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL',
VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY:
'/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY',
// TODO: Add to AWS param store
VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME',
VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD',
})
.xroad(
AdrAndMachine,
Expand Down
6 changes: 5 additions & 1 deletion apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ import { SyslumennClientConfig } from '@island.is/clients/syslumenn'
import { HuntingLicenseClientConfig } from '@island.is/clients/hunting-license'
import { VehiclesClientConfig } from '@island.is/clients/vehicles'
import { WorkMachinesClientConfig } from '@island.is/clients/work-machines'
import { CmsModule, Form, PowerBiConfig } from '@island.is/cms'
import { CmsModule, PowerBiConfig } from '@island.is/cms'
import { CmsTranslationsModule } from '@island.is/cms-translations'
import { FileStorageConfig } from '@island.is/file-storage'
import { AuditModule } from '@island.is/nest/audit'
Expand Down Expand Up @@ -204,6 +204,8 @@ import { UmbodsmadurSkuldaraModule } from '@island.is/api/domains/umbodsmadur-sk
import { UmbodsmadurSkuldaraClientConfig } from '@island.is/clients/ums-cost-of-living-calculator'
import { emailModuleConfig } from '@island.is/email-service'
import { ZendeskServiceConfig } from '@island.is/clients/zendesk'
import { VerdictsClientConfig } from '@island.is/clients/verdicts'
import { VerdictsModule } from '@island.is/api/domains/verdicts'

const environment = getConfig

Expand Down Expand Up @@ -342,6 +344,7 @@ const environment = getConfig
LawAndOrderModule,
UmbodsmadurSkuldaraModule,
HealthDirectorateModule,
VerdictsModule,
ConfigModule.forRoot({
isGlobal: true,
load: [
Expand Down Expand Up @@ -442,6 +445,7 @@ const environment = getConfig
WorkAccidentClientConfig,
ZendeskServiceConfig,
emailModuleConfig,
VerdictsClientConfig,
],
}),
],
Expand Down
12 changes: 12 additions & 0 deletions apps/web/pages/domar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import withApollo from '@island.is/web/graphql/withApollo'
import { withLocale } from '@island.is/web/i18n'
import VerdictsList from '@island.is/web/screens/Verdicts/VerdictsList'
import { getServerSidePropsWrapper } from '@island.is/web/utils/getServerSidePropsWrapper'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore make web strict
const Screen = withApollo(withLocale('is')(VerdictsList))

export default Screen

export const getServerSideProps = getServerSidePropsWrapper(Screen)
136 changes: 136 additions & 0 deletions apps/web/screens/Verdicts/VerdictsList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { parseAsString, useQueryState } from 'next-usequerystate'

import {
Box,
FocusableBox,
GridColumn,
GridContainer,
GridRow,
Input,
Stack,
Text,
} from '@island.is/island-ui/core'
import {
GetVerdictsQuery,
GetVerdictsQueryVariables,
} from '@island.is/web/graphql/schema'
import { useDateUtils } from '@island.is/web/i18n/useDateUtils'
import { withMainLayout } from '@island.is/web/layouts/main'
import type { Screen } from '@island.is/web/types'

import { GET_VERDICTS_QUERY } from '../queries/Verdicts'

interface VerdictsListProps {
items: GetVerdictsQuery['webVerdicts']['items']
}

const VerdictsList: Screen<VerdictsListProps> = ({ items }) => {
const { format } = useDateUtils()

const [searchTerm, setSearchTerm] = useQueryState(
'q',
parseAsString
.withOptions({
clearOnDefault: true,
shallow: false,
})
.withDefault(''),
)

return (
<Box paddingBottom={5}>
<GridContainer>
<Stack space={3}>
<Text variant="h1" as="h1">
Dómar og úrskurðir
</Text>
<Text>Dómar frá öllum dómstigum á Íslandi</Text>
<Input
value={searchTerm}
onChange={(ev) => {
setSearchTerm(ev.target.value)
}}
name="verdict-search-input"
backgroundColor="blue"
placeholder="Sláðu inn orð, málsnúmer, málsaðila"
icon={{
name: 'search',
type: 'outline',
}}
/>
<GridRow rowGap={3}>
{items.map((item) => (
<GridColumn key={item.title} span="1/1">
<FocusableBox
height="full"
href={'/test'}
background="white"
borderRadius="large"
borderColor="blue200"
borderWidth="standard"
paddingX={3}
paddingY={2}
>
<GridContainer>
<Stack space={2}>
<GridRow rowGap={3}>
<GridColumn span={['7/12', '7/12', '9/12']}>
<Text color="blue400" fontWeight="semiBold">
{item.caseNumber}
</Text>
</GridColumn>
<GridColumn span={['5/12', '5/12', '3/12']}>
{item.verdictDate && (
<Text textAlign="right">
{format(
new Date(item.verdictDate),
'd. MMM yyyy',
)}
</Text>
)}
</GridColumn>
</GridRow>

<Stack space={0}>
<GridRow>
<GridColumn>
<Text>{item.court}</Text>
</GridColumn>
<GridColumn>
<Text>{item.title}</Text>
</GridColumn>
</GridRow>
</Stack>
</Stack>
</GridContainer>
</FocusableBox>
</GridColumn>
))}
</GridRow>
</Stack>
</GridContainer>
</Box>
)
}

VerdictsList.getProps = async ({ apolloClient, query }) => {
const searchTerm = parseAsString.withDefault('').parseServerSide(query.q)

const verdictListResponse = await apolloClient.query<
GetVerdictsQuery,
GetVerdictsQueryVariables
>({
query: GET_VERDICTS_QUERY,
variables: {
input: {
searchTerm,
},
},
})

return {
items: verdictListResponse.data.webVerdicts.items,
}
}

export default withMainLayout(VerdictsList)
17 changes: 17 additions & 0 deletions apps/web/screens/queries/Verdicts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import gql from 'graphql-tag'

export const GET_VERDICTS_QUERY = gql`
query GetVerdicts($input: WebVerdictsInput!) {
webVerdicts(input: $input) {
items {
title
court
caseNumber
verdictDate
}
input {
searchTerm
}
}
}
`
2 changes: 2 additions & 0 deletions charts/islandis/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ api:
UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL'
UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY'
VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS'
VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD'
VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME'
VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY'
VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY'
WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY'
Expand Down
2 changes: 2 additions & 0 deletions charts/islandis/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ api:
UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL'
UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY'
VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS'
VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD'
VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME'
VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY'
VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY'
WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY'
Expand Down
2 changes: 2 additions & 0 deletions charts/islandis/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ api:
UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL'
UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY'
VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS'
VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD'
VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME'
VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY'
VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY'
WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY'
Expand Down
2 changes: 2 additions & 0 deletions charts/services/api/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ secrets:
UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL'
UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY'
VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS'
VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD'
VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME'
VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY'
VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY'
WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY'
Expand Down
2 changes: 2 additions & 0 deletions charts/services/api/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ secrets:
UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL'
UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY'
VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS'
VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD'
VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME'
VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY'
VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY'
WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY'
Expand Down
2 changes: 2 additions & 0 deletions charts/services/api/values.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ secrets:
UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL: '/k8s/api/UMBODSMADUR_SKULDARA_COST_OF_LIVING_CALCULATOR_API_URL'
UST_PKPASS_API_KEY: '/k8s/api/UST_PKPASS_API_KEY'
VEHICLES_ALLOW_CO_OWNERS: '/k8s/api/VEHICLES_ALLOW_CO_OWNERS'
VERDICTS_GOPRO_PASSWORD: '/k8s/api/VERDICTS_GORPO_PASSWORD'
VERDICTS_GOPRO_USERNAME: '/k8s/api/VERDICTS_GORPO_USERNAME'
VE_PKPASS_API_KEY: '/k8s/api/VE_PKPASS_API_KEY'
VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY: '/k8s/api/VINNUEFTIRLITID_CAMPAIGN_MONITOR_API_KEY'
WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY: '/k8s/api/WATSON_ASSISTANT_CHAT_FEEDBACK_API_KEY'
Expand Down
18 changes: 18 additions & 0 deletions libs/api/domains/verdicts/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/api/domains/verdicts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# api-domains-verdicts

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test api-domains-verdicts` to execute the unit tests via [Jest](https://jestjs.io).
11 changes: 11 additions & 0 deletions libs/api/domains/verdicts/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'api-domains-verdicts',
preset: '../../../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../../coverage/libs/api/domains/verdicts',
}
19 changes: 19 additions & 0 deletions libs/api/domains/verdicts/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "api-domains-verdicts",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/api/domains/verdicts/src",
"projectType": "library",
"tags": ["lib:api", "scope:api"],
"targets": {
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/api/domains/verdicts/jest.config.ts"
}
}
}
}
1 change: 1 addition & 0 deletions libs/api/domains/verdicts/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/verdicts.module'
10 changes: 10 additions & 0 deletions libs/api/domains/verdicts/src/lib/dto/verdicts.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Field, InputType, ObjectType } from '@nestjs/graphql'

@InputType('WebVerdictsInput')
@ObjectType('WebVerdictsInputResponse')
export class VerdictsInput {
@Field(() => String, { nullable: true })
searchTerm?: string

// TODO: Add more fields
}
31 changes: 31 additions & 0 deletions libs/api/domains/verdicts/src/lib/dto/verdicts.response.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { CacheField } from '@island.is/nest/graphql'
import { Field, ObjectType } from '@nestjs/graphql'
import { VerdictsInput } from './verdicts.input'

@ObjectType()
class VerdictItem {
@Field(() => String)
title!: string

@Field(() => String)
court!: string

@Field(() => String)
caseNumber!: string

@Field(() => Date)
verdictDate!: Date

// TODO: Add more fields
}

@ObjectType('WebVerdictsResponse')
export class VerdictsResponse {
@CacheField(() => [VerdictItem])
items!: VerdictItem[]

@CacheField(() => VerdictsInput)
input!: VerdictsInput

// TODO: Add total?
}
10 changes: 10 additions & 0 deletions libs/api/domains/verdicts/src/lib/verdicts.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common'
import { VerdictsClientModule } from '@island.is/clients/verdicts'
import { VerdictsResolver } from './verdicts.resolver'
import { VerdictsService } from './verdicts.service'

@Module({
imports: [VerdictsClientModule],
providers: [VerdictsResolver, VerdictsService],
})
export class VerdictsModule {}
Loading
Loading