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(j-s): Allow multiple subtypes in indictments #17192

Merged
merged 98 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
1e67325
Add frontend changes for selecting indictment subtypes in indictment …
oddsson Dec 4, 2024
adf5ded
Create migration
oddsson Dec 4, 2024
94e59f3
Update DB on change
oddsson Dec 4, 2024
1bfcb96
Merge branch 'main' of github.com:island-is/island.is into j-s/select…
oddsson Dec 4, 2024
9532708
Refactor
oddsson Dec 4, 2024
e5ea1e2
Refactor
oddsson Dec 4, 2024
853dea2
chore: nx format:write update dirty files
andes-it Dec 4, 2024
d0b5c60
Add feature flag
oddsson Dec 4, 2024
42e47bb
Merge branch 'j-s/select-indictment-subtype' of github.com:island-is/…
oddsson Dec 4, 2024
d31e20d
Refactor
oddsson Dec 4, 2024
026eaf6
Refactor
oddsson Dec 4, 2024
124668c
Add featur flag
oddsson Dec 5, 2024
9289780
Merge branch 'main' of github.com:island-is/island.is into j-s/select…
oddsson Dec 5, 2024
45499db
Merge branch 'main' of github.com:island-is/island.is into j-s/select…
oddsson Dec 7, 2024
6ebec56
Merge branch 'main' of github.com:island-is/island.is into j-s/select…
oddsson Dec 9, 2024
e144cdf
Merge branch 'j-s/select-indictment-subtype' of github.com:island-is/…
oddsson Dec 9, 2024
bb9bf5b
Remove console.log()
oddsson Dec 9, 2024
90d2ee7
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 9, 2024
5e20628
Checkpoint
oddsson Dec 9, 2024
4af03fa
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 9, 2024
4112929
Refactor
oddsson Dec 9, 2024
f19e818
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 9, 2024
09bc0c3
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 10, 2024
1e63b1e
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 10, 2024
c010234
Refactor
oddsson Dec 10, 2024
632e121
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 10, 2024
ecdd5f2
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 10, 2024
38acc59
Fix tests
oddsson Dec 10, 2024
6b5fa2e
Fix lint
oddsson Dec 10, 2024
e400b2c
Add hasOnlyOneItemInSubArrays to utils
oddsson Dec 10, 2024
209c06f
Add hasOnlyOneItemInSubArrays to utils
oddsson Dec 10, 2024
199283e
Strip offence when removing traffic violation
oddsson Dec 10, 2024
48d491e
Add headings
oddsson Dec 10, 2024
173a393
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 10, 2024
8120201
Fixes
oddsson Dec 11, 2024
6de9edf
Refactor
oddsson Dec 11, 2024
acd60ce
Remove all indictmentCountSubtypes on remove
oddsson Dec 11, 2024
512a011
Refactor
oddsson Dec 12, 2024
344c480
Fix lint
oddsson Dec 12, 2024
be33b29
Cleanup
oddsson Dec 12, 2024
73b5604
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 12, 2024
eed65d9
Refactor
oddsson Dec 12, 2024
eb8eaf0
Refactor
oddsson Dec 12, 2024
edf70e2
Refactor
oddsson Dec 12, 2024
0dbb8d7
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 12, 2024
47589f0
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 13, 2024
7f7ccf4
Merge branch 'j-s/multi-subtype-2' of github.com:island-is/island.is …
oddsson Dec 13, 2024
382158f
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 16, 2024
d4d15b2
Merge branch 'j-s/multi-subtype-2' of github.com:island-is/island.is …
oddsson Dec 16, 2024
203f638
Rename import -- stepHelper to utils
oddsson Dec 16, 2024
290c4bf
Break down a complex ternary statement into if statemetns
oddsson Dec 16, 2024
2cc996f
Improve validation on indictment screen
oddsson Dec 16, 2024
4fd40c2
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 17, 2024
9d93668
Merge branch 'j-s/multi-subtype-2' of github.com:island-is/island.is …
oddsson Dec 17, 2024
ebabc90
Improve type safety
oddsson Dec 17, 2024
4dd6cd3
Remove unused code
oddsson Dec 17, 2024
7903f24
Refactor util
oddsson Dec 17, 2024
0927926
Cleanup state on remove traffic violation
oddsson Dec 17, 2024
b3c2681
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 17, 2024
d489b56
Improve validation
oddsson Dec 17, 2024
a983633
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 17, 2024
94a2aa0
Merge branch 'j-s/multi-subtype-2' of github.com:island-is/island.is …
oddsson Dec 17, 2024
ac1525e
Refactor validation
oddsson Dec 17, 2024
2328bea
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 17, 2024
e6f1bc5
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 18, 2024
89208e0
Merge branch 'j-s/multi-subtype-2' of github.com:island-is/island.is …
oddsson Dec 18, 2024
42e57cd
Fix imports
oddsson Dec 18, 2024
cc95172
Fix imports
oddsson Dec 18, 2024
629ba49
Remove console.log
oddsson Dec 18, 2024
3c1a7b4
Fix issue with rendering traffic violation fields
oddsson Dec 18, 2024
0a7061b
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 18, 2024
f0d558a
Fix issues with autofill
oddsson Dec 18, 2024
29098fb
Fix validation
oddsson Dec 18, 2024
fdf230e
Add tests
oddsson Dec 18, 2024
fb149c3
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 18, 2024
c5a28a5
Add tests for isTrafficViolationStepValidIndictments validation function
oddsson Dec 18, 2024
7dc1a63
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 19, 2024
22af2b7
Merge branch 'j-s/multi-subtype-2' of github.com:island-is/island.is …
oddsson Dec 19, 2024
0b7a452
Add tests
oddsson Dec 19, 2024
3b4b00a
Merge branch 'main' into j-s/multi-subtype-2
gudjong Dec 20, 2024
6e4449a
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 23, 2024
678eef2
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 23, 2024
15073d7
Merge branch 'j-s/multi-subtype-2' of github.com:island-is/island.is …
oddsson Dec 23, 2024
746edf5
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 23, 2024
9afc55f
Refactor validation functionality
oddsson Dec 23, 2024
6f5ec34
Refactor validation functionality
oddsson Dec 23, 2024
e7264b0
Refactor validation functionality
oddsson Dec 23, 2024
a20095d
Refactor variable setup
oddsson Dec 23, 2024
e2cff3b
Rename variables
oddsson Dec 23, 2024
5d17851
Refactor validation
oddsson Dec 23, 2024
013f7b0
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Dec 27, 2024
f5af0fd
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Jan 7, 2025
5e7d360
Merge
oddsson Jan 7, 2025
3e9ab55
Always use traffic violation description if traffic violation is sele…
oddsson Jan 7, 2025
3945618
Merge branch 'main' into j-s/multi-subtype-2
oddsson Jan 9, 2025
a4a3bca
Merge branch 'main' of github.com:island-is/island.is into j-s/multi-…
oddsson Jan 10, 2025
20281b3
Fix tests
oddsson Jan 10, 2025
982bf34
Merge branch 'j-s/multi-subtype-2' of github.com:island-is/island.is …
oddsson Jan 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const caseEvent: Record<CaseEvent, string> = {
[CaseTransition.ACCEPT]: ':white_check_mark: Samþykkt',
[CaseTransition.APPEAL]: ':judge: Kæra',
ARCHIVE: ':file_cabinet: Sett í geymslu',
[CaseTransition.ASK_FOR_CANCELLATION]: ':interrobang: Beðið um aftuköllun',
[CaseTransition.ASK_FOR_CANCELLATION]: ':interrobang: Beðið um afturköllun',
[CaseTransition.ASK_FOR_CONFIRMATION]: ':question: Beðið um staðfestingu',
[CaseTransition.COMPLETE]: ':white_check_mark: Lokið',
[CaseTransition.COMPLETE_APPEAL]: ':white_check_mark: Kæru lokið',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IconMapIcon } from '@island.is/island-ui/core'
import { Box, Icon, StatusColor, Text } from '@island.is/island-ui/core'
import { Colors } from '@island.is/island-ui/theme'

import { fileSize } from '../../utils/stepHelper'
import { fileSize } from '../../utils/utils'
import IconButton from '../IconButton/IconButton'
import * as styles from './CaseFile.css'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
UpdateCase,
useCase,
} from '@island.is/judicial-system-web/src/utils/hooks'
import { hasSentNotification } from '@island.is/judicial-system-web/src/utils/stepHelper'
import { hasSentNotification } from '@island.is/judicial-system-web/src/utils/utils'

import { strings } from './CourtArrangements.string'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CaseType,
} from '@island.is/judicial-system-web/src/graphql/schema'
import { TempCase as Case } from '@island.is/judicial-system-web/src/types'
import { getRestrictionTagVariant } from '@island.is/judicial-system-web/src/utils/stepHelper'
import { getRestrictionTagVariant } from '@island.is/judicial-system-web/src/utils/utils'

interface Props {
workingCase: Case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
useCase,
useOnceOn,
} from '@island.is/judicial-system-web/src/utils/hooks'
import { hasSentNotification } from '@island.is/judicial-system-web/src/utils/stepHelper'
import { hasSentNotification } from '@island.is/judicial-system-web/src/utils/utils'
import { isCourtHearingArrangementsStepValidIC } from '@island.is/judicial-system-web/src/utils/validate'

import { icHearingArrangements as m } from './HearingArrangements.strings'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
useCase,
useOnceOn,
} from '@island.is/judicial-system-web/src/utils/hooks'
import { hasSentNotification } from '@island.is/judicial-system-web/src/utils/stepHelper'
import { hasSentNotification } from '@island.is/judicial-system-web/src/utils/utils'
import { isCourtHearingArrangemenstStepValidRC } from '@island.is/judicial-system-web/src/utils/validate'

import { rcHearingArrangements as m } from './HearingArrangements.strings'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
PageTitle,
} from '@island.is/judicial-system-web/src/components'
import { Gender } from '@island.is/judicial-system-web/src/graphql/schema'
import { getDefendantPleaText } from '@island.is/judicial-system-web/src/utils/stepHelper'
import { getDefendantPleaText } from '@island.is/judicial-system-web/src/utils/utils'
import { isReceptionAndAssignmentStepValid } from '@island.is/judicial-system-web/src/utils/validate'

import CourtCaseNumber from '../CourtCaseNumber/CourtCaseNumber'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { useCase } from '@island.is/judicial-system-web/src/utils/hooks'
import {
hasSentNotification,
isReopenedCOACase,
} from '@island.is/judicial-system-web/src/utils/stepHelper'
} from '@island.is/judicial-system-web/src/utils/utils'
import { isCourtOfAppealCaseStepValid } from '@island.is/judicial-system-web/src/utils/validate'

import CaseNumberInput from '../components/CaseNumberInput/CaseNumberInput'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
} from '@island.is/judicial-system-web/src/components'
import useInfoCardItems from '@island.is/judicial-system-web/src/components/InfoCard/useInfoCardItems'
import { useAppealAlertBanner } from '@island.is/judicial-system-web/src/utils/hooks'
import { shouldUseAppealWithdrawnRoutes } from '@island.is/judicial-system-web/src/utils/stepHelper'
import { titleForCase } from '@island.is/judicial-system-web/src/utils/titleForCase/titleForCase'
import { shouldUseAppealWithdrawnRoutes } from '@island.is/judicial-system-web/src/utils/utils'

import CaseFilesOverview from '../components/CaseFilesOverview/CaseFilesOverview'
import CaseOverviewHeader from '../components/CaseOverviewHeader/CaseOverviewHeader'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
CaseType,
} from '@island.is/judicial-system-web/src/graphql/schema'
import { mockTransitonCaseMutation } from '@island.is/judicial-system-web/src/utils/mocks'
import * as stepHelper from '@island.is/judicial-system-web/src/utils/stepHelper'
import {
FormContextWrapper,
IntlProviderWrapper,
} from '@island.is/judicial-system-web/src/utils/testHelpers'
import * as utils from '@island.is/judicial-system-web/src/utils/utils'

import Summary from './Summary'

Expand Down Expand Up @@ -70,7 +70,7 @@ describe('Summary', () => {
it('should show a modal window when the appeal ruling is modified', async () => {
const caseId = faker.datatype.uuid()
jest
.spyOn(stepHelper, 'hasSentNotification')
.spyOn(utils, 'hasSentNotification')
.mockReturnValue({ hasSent: true, date: null })

render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import {
hasSentNotification,
shouldUseAppealWithdrawnRoutes,
} from '@island.is/judicial-system-web/src/utils/stepHelper'
} from '@island.is/judicial-system-web/src/utils/utils'

import CaseNumbers from '../components/CaseNumbers/CaseNumbers'
import RulingModifiedModal from './RulingModifiedModal/RulingModifiedModal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
} from '@island.is/judicial-system-web/src/graphql/schema'
import { TempCase as Case } from '@island.is/judicial-system-web/src/types'
import {
UpdateIndictmentCount,
useCase,
useDefendants,
useIndictmentCounts,
Expand Down Expand Up @@ -115,7 +114,7 @@ const Defendant = () => {
} = useDefendants()
const router = useRouter()

const { updateIndictmentCount } = useIndictmentCounts()
const { updateIndictmentCount, deleteIndictmentCount } = useIndictmentCounts()

const [policeCases, setPoliceCases] = useState<PoliceCase[]>([])

Expand Down Expand Up @@ -249,6 +248,12 @@ const Defendant = () => {
workingCase,
setWorkingCase,
)

const indictmentCountId = workingCase.indictmentCounts?.[index]?.id

if (indictmentCountId) {
deleteIndictmentCount(workingCase.id, indictmentCountId)
}
}

const handleUpdatePoliceCase = (
Expand Down Expand Up @@ -279,20 +284,28 @@ const Defendant = () => {
const handleUpdateIndictmentCount = (
policeCaseNumber: string,
crimeScene: CrimeScene,
subtypes?: Record<string, IndictmentSubtype[]>,
) => {
if (workingCase.indictmentCounts) {
workingCase.indictmentCounts
.filter((ic) => ic.policeCaseNumber === policeCaseNumber)
.forEach((ic) => {
.filter(
(indictmentCount) =>
indictmentCount.policeCaseNumber === policeCaseNumber,
)
.forEach((indictmentCount) => {
const incidentDescription = getIncidentDescription(
ic,
indictmentCount,
formatMessage,
crimeScene,
subtypes,
)

updateIndictmentCount(workingCase.id, ic.id, {
updateIndictmentCount(workingCase.id, indictmentCount.id, {
incidentDescription,
} as UpdateIndictmentCount)
...(subtypes && {
indictmentCountSubtypes: subtypes[policeCaseNumber],
}),
})
})
}
}
Expand Down Expand Up @@ -506,6 +519,11 @@ const Defendant = () => {
workingCase.origin === CaseOrigin.LOKE && index === 0
}
updateIndictmentCount={handleUpdateIndictmentCount}
indictmentCount={workingCase.indictmentCounts?.find(
(indictmentCount) =>
indictmentCount.policeCaseNumber ===
workingCase.policeCaseNumbers?.[index],
)}
/>
)}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
DateTime,
UserContext,
} from '@island.is/judicial-system-web/src/components'
import { TempIndictmentCount } from '@island.is/judicial-system-web/src/types'
import {
removeErrorMessageIfValid,
validateAndSetErrorMessage,
Expand Down Expand Up @@ -53,8 +54,10 @@ interface Props {
updateIndictmentCount: (
policeCaseNumber: string,
crimeScene: CrimeScene,
subtypes?: Record<string, IndictmentSubtype[]>,
) => void
policeCaseNumberImmutable: boolean
indictmentCount?: TempIndictmentCount
}

export const PoliceCaseInfo: FC<Props> = ({
Expand All @@ -68,6 +71,7 @@ export const PoliceCaseInfo: FC<Props> = ({
updatePoliceCase,
policeCaseNumberImmutable = false,
updateIndictmentCount,
indictmentCount,
}) => {
const { formatMessage } = useIntl()

Expand All @@ -82,6 +86,8 @@ export const PoliceCaseInfo: FC<Props> = ({
const [policeCaseNumberErrorMessage, setPoliceCaseNumberErrorMessage] =
useState<string>('')

const subtypesArray = subtypes || []

useEffect(() => {
if (policeCaseNumbers[index] !== originalPoliceCaseNumber) {
// This component is now handling a new police case number
Expand Down Expand Up @@ -208,10 +214,15 @@ export const PoliceCaseInfo: FC<Props> = ({
label={formatMessage(policeCaseInfo.indictmentTypeLabel)}
placeholder={formatMessage(policeCaseInfo.indictmentTypePlaceholder)}
onChange={(selectedOption) => {
const indictmentSubtype = selectedOption?.value as IndictmentSubtype
updatePoliceCase(index, {
subtypes: [...(subtypes || []), indictmentSubtype],
})
const indictmentSubtype = selectedOption?.value

if (!indictmentSubtype) {
return
}

const subtypes = [...subtypesArray, indictmentSubtype]

updatePoliceCase(index, { subtypes })
}}
value={null}
required
Expand All @@ -231,8 +242,21 @@ export const PoliceCaseInfo: FC<Props> = ({
variant="darkerBlue"
onClick={() => {
updatePoliceCase(index, {
policeCaseNumber: policeCaseNumbers[index],
subtypes: subtypes.filter((s) => s !== subtype),
})

updateIndictmentCount(
policeCaseNumbers[index],
crimeScene || {},
{
[policeCaseNumbers[index]]: subtypes.filter(
(s) =>
s !== subtype &&
indictmentCount?.indictmentCountSubtypes?.includes(s),
thorhildurt marked this conversation as resolved.
Show resolved Hide resolved
),
},
)
}}
aria-label={formatMessage(policeCaseInfo.removeSubtype, {
subtype: indictmentSubtypes[subtypes[0]],
Expand Down Expand Up @@ -261,10 +285,11 @@ export const PoliceCaseInfo: FC<Props> = ({
}}
onBlur={(event) => {
updatePoliceCase()
updateIndictmentCount(policeCaseNumbers[index], {
...crimeScene,
place: event.target.value,
})
updateIndictmentCount(
policeCaseNumbers[index],
{ ...crimeScene, place: event.target.value },
{ [policeCaseNumbers[index]]: subtypesArray },
)
}}
/>
</Box>
Expand All @@ -280,10 +305,11 @@ export const PoliceCaseInfo: FC<Props> = ({
crimeScene: { ...crimeScene, date: date },
})

updateIndictmentCount(policeCaseNumbers[index], {
...crimeScene,
date: date,
})
updateIndictmentCount(
policeCaseNumbers[index],
{ ...crimeScene, date: date },
{ [policeCaseNumbers[index]]: subtypesArray },
)
}
}}
/>
Expand Down
Loading
Loading