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): Complete Cancellation #15154

Merged
merged 64 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
4b82fdf
Add POSTPONED_TO_VERDICT radio button
oddsson May 28, 2024
538eead
Change Radio to Checkbox
oddsson May 28, 2024
be28358
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 28, 2024
43c515a
Add column to Case table -- IndictmentDecision
oddsson May 29, 2024
4a3ec3f
Update IndictmentDecision
oddsson May 29, 2024
dfc970e
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 30, 2024
9061138
Postponed until verdict tag in cases
oddsson May 30, 2024
d0ff81b
Disable subpoena screen if a case is postponed until verdict
oddsson May 30, 2024
f9119f8
Add a postpone until verdict tag for defenders
oddsson May 30, 2024
c5e92f5
Checkpoint
oddsson May 30, 2024
d75eeba
Checkpoint
oddsson May 30, 2024
2091f6a
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 31, 2024
e73e037
Merge
oddsson May 31, 2024
ed6ba89
Determining when step is valid when postponing until verdict
oddsson May 31, 2024
bffb3f0
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 31, 2024
7cf3da0
Checkpoint
oddsson May 31, 2024
2b5c478
Change all instances of Array<something> to something[]
oddsson May 31, 2024
7d24529
Merge branch 'main' into j-s/array-ref
kodiakhq[bot] May 31, 2024
3bc2eda
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 31, 2024
44e3501
Merge branch 'j-s/array-ref' of github.com:island-is/island.is into j…
oddsson May 31, 2024
164ea33
Only show InfoCard on summary page if indictment decison is POSTPONIN…
oddsson May 31, 2024
8b6c049
Wipe courtDate out when postponing until verdict
oddsson Jun 3, 2024
a01f34c
Move scheduled info card to overview page
oddsson Jun 3, 2024
048ff3a
Save court date when postponing until verdict
oddsson Jun 3, 2024
68a4de4
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson Jun 3, 2024
1dc584d
Checkpoint
oddsson Jun 3, 2024
ab03621
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson Jun 3, 2024
8649b7b
Fixing update functionality
oddsson Jun 3, 2024
d08c1e3
Fix case state on cases page
oddsson Jun 3, 2024
4bdf63a
Fix migration
oddsson Jun 3, 2024
5ec53d6
Add location to verdict date
oddsson Jun 3, 2024
743cb81
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson Jun 3, 2024
9e77317
Cleanup
oddsson Jun 4, 2024
35feba7
Allow judges to remove set court date
oddsson Jun 4, 2024
fc6b01e
Added test
oddsson Jun 4, 2024
f86f930
Merge branch 'main' of github.com:island-is/island.is into j-s/cancel…
gudjong Jun 4, 2024
36dc8a9
Merge branch 'main' of github.com:island-is/island.is into j-s/cancel…
gudjong Jun 5, 2024
47afac6
Allows prosecutors to cancel submitted indictments
gudjong Jun 5, 2024
74176d6
Hides buttons when prosecutor has asked for cancellation
gudjong Jun 5, 2024
dbab11d
Adds unit tests
gudjong Jun 5, 2024
971cc83
Updates unit tests
gudjong Jun 5, 2024
9cada7e
Merge branch 'main' of github.com:island-is/island.is into j-s/cancel…
gudjong Jun 7, 2024
29d12ac
Fixes unit tests
gudjong Jun 7, 2024
32f8b76
Rewrite open case
gudjong Jun 7, 2024
2df8f90
Adds modal for cancelling case
gudjong Jun 7, 2024
cdad57d
Fixes back navigation
gudjong Jun 7, 2024
e2497c7
Update apps/judicial-system/web/src/routes/Prosecutor/Indictments/Ove…
gudjong Jun 7, 2024
c783160
Refactors code
gudjong Jun 7, 2024
53c4972
Merge branch 'j-s/cancel-submitted-case' of github.com:island-is/isla…
gudjong Jun 7, 2024
b1309f5
Rewrites condition
gudjong Jun 7, 2024
a82a5af
Merge branch 'j-s/cancel-submitted-case' of github.com:island-is/isla…
gudjong Jun 8, 2024
7fcdd3e
Completes cancellation
gudjong Jun 9, 2024
f07c7fc
Removes obsolete unit tests
gudjong Jun 10, 2024
ecb6b5a
Fixes test helpers
gudjong Jun 10, 2024
42664ca
Merge branch 'main' of github.com:island-is/island.is into j-s/comple…
gudjong Jun 10, 2024
6cc32e2
Simplifies code
gudjong Jun 11, 2024
bbcc493
Simplifies code
gudjong Jun 11, 2024
604b402
Improves imports
gudjong Jun 11, 2024
ab3f1fc
Improves imports
gudjong Jun 11, 2024
6ee56d5
Improves imports
gudjong Jun 11, 2024
3efe030
Simplifies type
gudjong Jun 11, 2024
5902776
Simplifies expressions
gudjong Jun 11, 2024
2e49084
Correct function declaration
gudjong Jun 11, 2024
3efa337
Merge branch 'main' into j-s/complete-cancellation
kodiakhq[bot] Jun 11, 2024
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 @@ -554,7 +554,10 @@ describe('Transition Case', () => {
)

describe.each(indictmentCases)('complete %s', (type) => {
const allowedFromStates = [CaseState.RECEIVED]
const allowedFromStates = [
CaseState.WAITING_FOR_CANCELLATION,
CaseState.RECEIVED,
]

describe.each(allowedFromStates)(
'state %s - should complete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ const indictmentCaseStateMachine: Map<
[
IndictmentCaseTransition.COMPLETE,
{
fromStates: [IndictmentCaseState.RECEIVED],
fromStates: [
IndictmentCaseState.WAITING_FOR_CANCELLATION,
IndictmentCaseState.RECEIVED,
],
to: { state: IndictmentCaseState.COMPLETED },
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const caseEvent = {
ACCEPT: ':white_check_mark: Samþykkt',
REJECT: ':negative_squared_cross_mark: Hafnað',
DISMISS: ':woman-shrugging: Vísað frá',
COMPLETE: ':white_check_mark: Lokað',
COMPLETE: ':white_check_mark: Lokið',
gudjong marked this conversation as resolved.
Show resolved Hide resolved
DELETE: ':fire: Afturkallað',
SCHEDULE_COURT_DATE: ':timer_clock: Fyrirtökutíma úthlutað',
ARCHIVE: ':file_cabinet: Sett í geymslu',
Expand Down
5 changes: 5 additions & 0 deletions apps/judicial-system/web/messages/Core/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,9 @@ export const tables = defineMessages({
description:
'Notaður sem titill fyrir birtingarstaða dálk í lista yfir mál.',
},
postponed: {
oddsson marked this conversation as resolved.
Show resolved Hide resolved
id: 'judicial.system.core:tables.postponed',
defaultMessage: 'Frestað',
description: 'Notaður sem texti þegar mál er frestað.',
},
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {
createContext,
ReactNode,
useCallback,
useContext,
useEffect,
useState,
Expand All @@ -18,8 +19,11 @@ import { api } from '@island.is/judicial-system-web/src/services'
import { TempCase as Case } from '@island.is/judicial-system-web/src/types'

import { UserContext } from '../UserProvider/UserProvider'
import { useCaseLazyQuery } from './case.generated'
import { useLimitedAccessCaseLazyQuery } from './limitedAccessCase.generated'
import { CaseQuery, useCaseLazyQuery } from './case.generated'
import {
LimitedAccessCaseQuery,
useLimitedAccessCaseLazyQuery,
} from './limitedAccessCase.generated'

type ProviderState =
| 'fetch'
Expand All @@ -36,6 +40,11 @@ interface FormProvider {
caseNotFound: boolean
isCaseUpToDate: boolean
refreshCase: () => void
getCase: (
id: string,
onCompleted: (theCase: Case) => void,
onError: () => void,
) => void
}

interface Props {
Expand All @@ -60,8 +69,12 @@ export const FormContext = createContext<FormProvider>({
isLoadingWorkingCase: true,
caseNotFound: false,
isCaseUpToDate: false,
// eslint-disable-next-line @typescript-eslint/no-empty-function
refreshCase: () => {},
refreshCase: () => {
return
},
getCase: () => {
return
},
})

const MaybeFormProvider = ({ children }: Props) => {
Expand Down Expand Up @@ -123,39 +136,37 @@ const FormProvider = ({ children }: Props) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [router.query.id, router.pathname])

const [getCase] = useCaseLazyQuery({
const [queryCase] = useCaseLazyQuery({
fetchPolicy: 'no-cache',
errorPolicy: 'all',
onCompleted: (caseData) => {
if (caseData && caseData.case) {
setWorkingCase(caseData.case)

// The case has been loaded from the server
setState('up-to-date')
}
},
onError: () => {
// The case was not found
setState('not-found')
},
})

const [getLimitedAccessCase] = useLimitedAccessCaseLazyQuery({
const [queryLimitedAccessCase] = useLimitedAccessCaseLazyQuery({
fetchPolicy: 'no-cache',
errorPolicy: 'all',
onCompleted: (caseData) => {
if (caseData && caseData.limitedAccessCase) {
setWorkingCase(caseData.limitedAccessCase)
})

// The case has been loaded from the server
setState('up-to-date')
}
},
onError: () => {
// The case was not found
setState('not-found')
const getCase = useCallback(
(id: string, onCompleted: (theCase: Case) => void, onError: () => void) => {
const promisedCase = limitedAccess
? queryLimitedAccessCase({ variables: { input: { id } } })
: queryCase({ variables: { input: { id } } })

promisedCase
.then((caseData) => {
if (caseData && caseData.data) {
const data = caseData.data as CaseQuery & LimitedAccessCaseQuery
const theCase = data[limitedAccess ? 'limitedAccessCase' : 'case']

if (theCase) {
onCompleted(theCase)
}
}
})
.catch(onError)
gudjong marked this conversation as resolved.
Show resolved Hide resolved
},
})
[limitedAccess, queryCase, queryLimitedAccessCase],
)

useEffect(() => {
if (!isAuthenticated && router.pathname !== '/') {
Expand All @@ -167,20 +178,29 @@ const FormProvider = ({ children }: Props) => {
id &&
(state === 'fetch' || state === 'refresh')
) {
if (limitedAccess) {
getLimitedAccessCase({ variables: { input: { id } } })
} else {
getCase({ variables: { input: { id } } })
}
getCase(
id,
(theCase: Case) => {
setWorkingCase(theCase)

// The case has been loaded from the server
setState('up-to-date')
},
() => {
// The case was not found
setState('not-found')
},
)
}
}, [
getCase,
getLimitedAccessCase,
queryCase,
queryLimitedAccessCase,
id,
isAuthenticated,
limitedAccess,
router.pathname,
state,
getCase,
])

useEffect(() => {
Expand All @@ -207,6 +227,7 @@ const FormProvider = ({ children }: Props) => {
isCaseUpToDate:
!replacingCase && !replacingPath && state === 'up-to-date',
refreshCase: () => setState('refresh'),
getCase,
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { FC } from 'react'
import { useIntl } from 'react-intl'
import format from 'date-fns/format'
import localeIS from 'date-fns/locale/is'
import parseISO from 'date-fns/parseISO'

import { Box, Text } from '@island.is/island-ui/core'
import { capitalize } from '@island.is/judicial-system/formatters'
import { tables } from '@island.is/judicial-system-web/messages'

interface Props {
courtDate?: string | null
postponedIndefinitelyExplanation?: string | null
}

const CourtDate: FC<Props> = (props) => {
const { courtDate, postponedIndefinitelyExplanation } = props
const { formatMessage } = useIntl()

if (!courtDate && !postponedIndefinitelyExplanation) {
return null
}

return postponedIndefinitelyExplanation ? (
<Text>{formatMessage(tables.postponed)}</Text>
) : (
courtDate && (
<>
<Text>
<Box component="span">
{capitalize(
format(parseISO(courtDate), 'EEEE d. LLLL y', {
locale: localeIS,
}),
).replace('dagur', 'd.')}
</Box>
</Text>
<Text as="span" variant="small">
kl. {format(parseISO(courtDate), 'kk:mm')}
</Text>
</>
)
)
gudjong marked this conversation as resolved.
Show resolved Hide resolved
}
gudjong marked this conversation as resolved.
Show resolved Hide resolved
export default CourtDate
57 changes: 33 additions & 24 deletions apps/judicial-system/web/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface TableProps {
data: CaseListEntry[]
columns: { cell: (row: CaseListEntry) => ReactNode }[]
generateContextMenuItems?: (row: CaseListEntry) => ContextMenuItem[]
onClick?: (row: CaseListEntry) => boolean
gudjong marked this conversation as resolved.
Show resolved Hide resolved
}

interface TableWrapperProps {
Expand Down Expand Up @@ -80,7 +81,7 @@ export const useTable = () => {
}

const Table: React.FC<TableProps> = (props) => {
const { thead, data, columns, generateContextMenuItems } = props
const { thead, data, columns, generateContextMenuItems, onClick } = props
const { isOpeningCaseId, handleOpenCase, LoadingIndicator, showLoading } =
useCaseList()
const { sortConfig, requestSort, getClassNamesFor } = useTable()
Expand Down Expand Up @@ -122,7 +123,11 @@ const Table: React.FC<TableProps> = (props) => {
{data.map((theCase: CaseListEntry) => (
<Box marginTop={2} key={theCase.id}>
<MobileCase
onClick={() => handleOpenCase(theCase.id)}
onClick={() => {
if (!onClick?.(theCase)) {
handleOpenCase(theCase.id)
}
}}
gudjong marked this conversation as resolved.
Show resolved Hide resolved
theCase={theCase}
isCourtRole={isDistrictCourtUser(user)}
isLoading={isOpeningCaseId === theCase.id && showLoading}
Expand Down Expand Up @@ -185,7 +190,9 @@ const Table: React.FC<TableProps> = (props) => {
aria-disabled={isOpeningCaseId === row.id || isTransitioningCase}
className={styles.tableRowContainer}
onClick={() => {
handleOpenCase(row.id)
if (!onClick?.(row)) {
handleOpenCase(row.id)
}
}}
>
{columns.map((td) => (
Expand All @@ -195,27 +202,29 @@ const Table: React.FC<TableProps> = (props) => {
))}
{generateContextMenuItems && (
<td className={styles.td}>
<AnimatePresence exitBeforeEnter initial={false}>
{isOpeningCaseId === row.id && showLoading ? (
<Box padding={1}>
<LoadingIndicator />
</Box>
) : (
<ContextMenu
menuLabel={`Valmynd fyrir mál ${row.courtCaseNumber}`}
items={generateContextMenuItems(row)}
disclosure={
<IconButton
icon="ellipsisVertical"
colorScheme="transparent"
onClick={(evt) => {
evt.stopPropagation()
}}
/>
}
/>
)}
</AnimatePresence>
{generateContextMenuItems(row).length > 0 && (
<AnimatePresence exitBeforeEnter initial={false}>
{isOpeningCaseId === row.id && showLoading ? (
<Box padding={1}>
<LoadingIndicator />
</Box>
) : (
<ContextMenu
menuLabel={`Valmynd fyrir mál ${row.courtCaseNumber}`}
items={generateContextMenuItems(row)}
disclosure={
<IconButton
icon="ellipsisVertical"
colorScheme="transparent"
onClick={(evt) => {
evt.stopPropagation()
}}
/>
}
/>
)}
</AnimatePresence>
)}
</td>
)}
</tr>
Expand Down
1 change: 1 addition & 0 deletions apps/judicial-system/web/src/components/Table/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export {
export { default as CreatedDate } from './CreatedDate/CreatedDate'
export { default as AppealCasesTable } from './AppealCasesTable/AppealCasesTable'
export { default as PastCasesTable } from './PastCasesTable/PastCasesTable'
export { default as CourtDate } from './CourtDate/CourtDate'
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineMessages } from 'react-intl'

export const strings = defineMessages({
title: {
id: 'judicial.system.core:court.cases_in_progress.title',
defaultMessage: 'Mál í vinnslu',
description: 'Notaður sem titill í málalista',
},
noCasesTitle: {
id: 'judicial.system.core:court.cases_in_progress.no_cases_title',
defaultMessage: 'Engin mál í vinnslu.',
description: 'Notaður sem titill þegar engin mál eru til vinnslu',
},
noCasesMessage: {
id: 'judicial.system.core:court.cases_in_progress.no_cases_message',
defaultMessage: 'Öll mál hafa verið afgreidd.',
description: 'Notað sem skilaboð þegar engin mál eru til vinnslu',
},
cancelCaseModalTitle: {
id: 'judicial.system.core:cases.active_requests.cancel_case_modal_title',
defaultMessage: 'Mál afturkallað',
description: 'Notaður sem titill í Afturkalla mál dómstóla modal.',
},
cancelCaseModalText: {
id: 'judicial.system.core:cases.active_requests.cancel_case_modal_text',
defaultMessage:
'Ákæruvaldið hefur afturkallað ákæruna. Hægt er að skrá málsnúmer og ljúka málinu hér.',
description: 'Notaður sem texti í Afturkalla mál dómstóla modal.',
},
cancelCaseModalPrimaryButtonText: {
id: 'judicial.system.core:cases.active_requests.cancel_case_modal_primary_button_text',
defaultMessage: 'Ljúka máli',
description:
'Notaður sem texti á Ljúka máli takka í Afturkalla mál dómstóla modal.',
},
cancelCaseModalSecondaryButtonText: {
id: 'judicial.system.core:cases.active_requests.delete_case_modal_secondary_button_text',
defaultMessage: 'Hætta við',
description:
'Notaður sem texti á Hætta við takka í Afturkalla mál dómstóla modal.',
},
})
Loading
Loading