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

chore(j-s): adding new client logic for offenses #17857

Merged
merged 64 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
afcfe45
fix(j-s): tooltip with correct defender label
thorhildurt Jan 22, 2025
4a9f6c3
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Jan 23, 2025
d3b89bb
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Jan 24, 2025
b5e651c
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Jan 27, 2025
273e69f
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Jan 28, 2025
8da3e9f
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Jan 28, 2025
93b0d62
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Jan 29, 2025
7ccc0e7
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Jan 30, 2025
652371c
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Jan 31, 2025
a4f08bb
Merge branch 'main' of https://github.com/island-is/island.is
thorhildurt Feb 3, 2025
07024f7
chore(j-s): rename field that we are deprecating
thorhildurt Feb 3, 2025
eb47bfd
fix(j-s): finish rename and fix migration
thorhildurt Feb 3, 2025
ff7ef78
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 3, 2025
02ff3b9
chore(j-s): migration for new table + bakend model
thorhildurt Feb 3, 2025
9308659
chore(j-s): add three new controller methods in the backend
thorhildurt Feb 3, 2025
26f9378
chore(j-s): add api input models and resolver
thorhildurt Feb 3, 2025
9a2b7f7
fix(j-s): imports
thorhildurt Feb 3, 2025
8ff4c41
fix(j-s): format
thorhildurt Feb 4, 2025
feb5065
fix(j-s): format
thorhildurt Feb 4, 2025
d91d46a
Merge branch 'j-s/offense/rename' of https://github.com/island-is/isl…
thorhildurt Feb 4, 2025
cc7ef4a
chore(j-s): implement offense hooks
thorhildurt Feb 6, 2025
490fcc1
chore(j-s): deprecating old offense sturcture and adding new behind a…
thorhildurt Feb 6, 2025
992fd2d
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 6, 2025
bc9199a
fix(j-s): refactor offense exists guard
thorhildurt Feb 6, 2025
dfb2a11
fix(j-s): refactor shared models and fix imports
thorhildurt Feb 6, 2025
a1c3275
fix(j-s): reference indictment count guards on new offense endpoints
thorhildurt Feb 6, 2025
ef578be
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 6, 2025
0da82e6
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 7, 2025
c7f46a9
fix(j-s): format
thorhildurt Feb 7, 2025
2804cad
chore(j-s): add create offense test
thorhildurt Feb 7, 2025
5daa30f
chore(j-s): add test for update and delete offense endpoints
thorhildurt Feb 7, 2025
7d7e8fe
Merge branch 'j-s/create-new-offenses-structure' of https://github.co…
thorhildurt Feb 7, 2025
e9bdbc0
fix(j-s): format
thorhildurt Feb 7, 2025
9ff7073
Merge branch 'j-s/create-new-offenses-structure' of https://github.co…
thorhildurt Feb 7, 2025
c7fab0b
Merge branch 'j-s/offense/backend-and-api-follow-ups' of https://gith…
thorhildurt Feb 7, 2025
8d70f6d
fix(j-s): minor tweaks on logic that was inconsistent
thorhildurt Feb 7, 2025
47a5007
fix(j-s): offense exists guard
thorhildurt Feb 7, 2025
df524ba
fix(j-s): fix copy paste bugs
thorhildurt Feb 7, 2025
1cd2ad2
fix(j-s): unit test
thorhildurt Feb 7, 2025
488f5a6
Merge branch 'j-s/create-new-offenses-structure' of https://github.co…
thorhildurt Feb 7, 2025
89a128a
fix(j-s): ensure we delete offenses before deleting indictment
thorhildurt Feb 7, 2025
ea99e6e
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 7, 2025
30734d9
Merge branch 'j-s/create-new-offenses-structure' of https://github.co…
thorhildurt Feb 7, 2025
b857cd0
fix(j-s): substance map type
thorhildurt Feb 7, 2025
2cdc1fc
fix(j-s): type for substance map
thorhildurt Feb 7, 2025
1474c01
Merge branch 'j-s/create-new-offenses-structure' of https://github.co…
thorhildurt Feb 7, 2025
0243f37
Merge branch 'j-s/offense/backend-and-api-follow-ups' of https://gith…
thorhildurt Feb 7, 2025
6d1c4a0
fix(j-s): add offense error strings
thorhildurt Feb 7, 2025
f03a7ac
Merge branch 'j-s/offense/backend-and-api-follow-ups' of https://gith…
thorhildurt Feb 7, 2025
06ff54c
fix(j-s): resolve merge conflicts
thorhildurt Feb 10, 2025
76d7ec2
fix(j-s): unit tests
thorhildurt Feb 10, 2025
cd78241
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 10, 2025
8e83a2b
Merge branch 'j-s/offense/backend-and-api-follow-ups' of https://gith…
thorhildurt Feb 10, 2025
dc78f14
fix(j-s): refactor and fix feature flag
thorhildurt Feb 10, 2025
9526e2d
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 10, 2025
7c7b9fd
fix(j-s): small fixes post pre-review
thorhildurt Feb 11, 2025
e082b9c
fix(j-s): remove spread
thorhildurt Feb 11, 2025
0dd683f
fix(j-s): small fixes when feature flag is disabled
thorhildurt Feb 11, 2025
c23b3c3
fix(j-s): format fix
thorhildurt Feb 11, 2025
d1fadf7
fix(j-s): feature flag in form helper
thorhildurt Feb 12, 2025
300d667
Merge branch 'main' into j-s/offense/supporting-offense-property-in-c…
unakb Feb 12, 2025
e8f380d
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 13, 2025
e99cbb2
Merge branch 'j-s/offense/supporting-offense-property-in-client' of h…
thorhildurt Feb 13, 2025
3dcb43f
Merge branch 'main' of https://github.com/island-is/island.is into j-…
thorhildurt Feb 14, 2025
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
6 changes: 3 additions & 3 deletions apps/judicial-system/api/infra/judicial-system-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export const serviceSetup = (services: {
prod: 'master',
},
HIDDEN_FEATURES: {
dev: '',
staging: '',
prod: '',
dev: 'OFFENSE_ENDPOINTS',
staging: 'OFFENSE_ENDPOINTS',
prod: 'OFFENSE_ENDPOINTS',
},
})
.secrets({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import * as constants from '@island.is/judicial-system/consts'
import {
CrimeScene,
CrimeSceneMap,
Feature,
IndictmentSubtype,
IndictmentSubtypeMap,
} from '@island.is/judicial-system/types'
import { core, errors, titles } from '@island.is/judicial-system-web/messages'
import {
FeatureContext,
FormContentContainer,
FormContext,
FormFooter,
Expand All @@ -38,7 +40,7 @@ import { isDefendantStepValidIndictments } from '@island.is/judicial-system-web/

import { DefendantInfo } from '../../components'
import { getIndictmentIntroductionAutofill } from '../Indictment/Indictment'
import { getIncidentDescription } from '../Indictment/IndictmentCount'
import { getIncidentDescription } from '../Indictment/lib/getIncidentDescription'
import { LokeNumberList } from './LokeNumberList/LokeNumberList'
import { PoliceCaseInfo } from './PoliceCaseInfo/PoliceCaseInfo'
import { usePoliceCaseInfoQuery } from './policeCaseInfo.generated'
Expand Down Expand Up @@ -102,6 +104,9 @@ const getPoliceCasesForUpdate = (
)

const Defendant = () => {
const { features } = useContext(FeatureContext)
const isOffenseEndpointEnabled = features.includes(Feature.OFFENSE_ENDPOINTS)

const { workingCase, setWorkingCase, isLoadingWorkingCase, caseNotFound } =
useContext(FormContext)
const { formatMessage } = useIntl()
Expand Down Expand Up @@ -297,12 +302,13 @@ const Defendant = () => {
...indictmentCount,
indictmentCountSubtypes: subtypes?.[policeCaseNumber],
}
const incidentDescription = getIncidentDescription(
updatedIndictmentCount,
const incidentDescription = getIncidentDescription({
indictmentCount: updatedIndictmentCount,
formatMessage,
crimeScene,
subtypes,
)
subtypesRecord: subtypes,
isOffenseEndpointEnabled,
})

updateIndictmentCount(workingCase.id, indictmentCount.id, {
incidentDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import router from 'next/router'
import { Box, Button, Checkbox, Input } from '@island.is/island-ui/core'
import * as constants from '@island.is/judicial-system/consts'
import { formatNationalId } from '@island.is/judicial-system/formatters'
import { Feature } from '@island.is/judicial-system/types'
import { titles } from '@island.is/judicial-system-web/messages'
import {
BlueBox,
FeatureContext,
FormContentContainer,
FormContext,
FormFooter,
Expand All @@ -26,6 +28,7 @@ import {
IndictmentCountOffense,
Institution,
Maybe,
Offense,
PoliceCaseInfo,
} from '@island.is/judicial-system-web/src/graphql/schema'
import { TempIndictmentCount as TIndictmentCount } from '@island.is/judicial-system-web/src/types'
Expand Down Expand Up @@ -78,13 +81,17 @@ export const getIndictmentIntroductionAutofill = (
}

const Indictment = () => {
const { features } = useContext(FeatureContext)
const isOffenseEndpointEnabled = features.includes(Feature.OFFENSE_ENDPOINTS)

const {
workingCase,
setWorkingCase,
isLoadingWorkingCase,
caseNotFound,
isCaseUpToDate,
} = useContext(FormContext)

const { formatMessage } = useIntl()
const { updateCase, setAndSendCaseToServer } = useCase()
const {
Expand Down Expand Up @@ -129,16 +136,25 @@ const Indictment = () => {
// If the case has:
// at least one count with the offense driving under the influence of alcohol, illegal drugs or prescription drugs
// then by default the prosecutor requests a suspension of the driver's licence.
const requestDriversLicenseSuspension = indictmentCounts?.some((count) =>
count.deprecatedOffenses?.some((offense) =>
[
IndictmentCountOffense.DRUNK_DRIVING,
IndictmentCountOffense.ILLEGAL_DRUGS_DRIVING,
IndictmentCountOffense.PRESCRIPTION_DRUGS_DRIVING,
].includes(offense),
),
)

const requestDriversLicenseSuspension = isOffenseEndpointEnabled
? indictmentCounts?.some((count) => {
return count.offenses?.some((o) =>
[
IndictmentCountOffense.DRUNK_DRIVING,
IndictmentCountOffense.ILLEGAL_DRUGS_DRIVING,
IndictmentCountOffense.PRESCRIPTION_DRUGS_DRIVING,
].includes(o.offense),
)
})
: indictmentCounts?.some((count) =>
count.deprecatedOffenses?.some((offense) =>
[
IndictmentCountOffense.DRUNK_DRIVING,
IndictmentCountOffense.ILLEGAL_DRUGS_DRIVING,
IndictmentCountOffense.PRESCRIPTION_DRUGS_DRIVING,
].includes(offense),
),
)
if (
requestDriversLicenseSuspension !==
workingCase.requestDriversLicenseSuspension
Expand All @@ -158,7 +174,13 @@ const Indictment = () => {
)
}
},
[formatMessage, setAndSendCaseToServer, setWorkingCase, workingCase],
[
isOffenseEndpointEnabled,
formatMessage,
setAndSendCaseToServer,
setWorkingCase,
workingCase,
],
)

const handleCreateIndictmentCount = useCallback(async () => {
Expand Down Expand Up @@ -191,6 +213,7 @@ const Indictment = () => {
async (
indictmentCountId: string,
updatedIndictmentCount: UpdateIndictmentCount,
updatedOffenses?: Offense[],
) => {
if (
updatedIndictmentCount.policeCaseNumber &&
Expand Down Expand Up @@ -218,14 +241,17 @@ const Indictment = () => {

setDriversLicenseSuspensionRequest(
workingCase.indictmentCounts?.map((count) =>
count.id === indictmentCountId ? returnedIndictmentCount : count,
count.id === indictmentCountId
? { ...returnedIndictmentCount, offenses: updatedOffenses }
: count,
),
)

updateIndictmentCountState(
indictmentCountId,
returnedIndictmentCount,
setWorkingCase,
updatedOffenses,
)
},
[
Expand Down
Loading
Loading