-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat(j-s): Table for reviewed cases (#14778)
* feat(j-s): Table for reviewed cases * Update CasesReviewed.tsx * cleanup * chore: nx format:write update dirty files --------- Co-authored-by: andes-it <builders@andes.is> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e84c270
commit a0a26e1
Showing
7 changed files
with
176 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.strings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { defineMessages } from 'react-intl' | ||
|
||
export const strings = defineMessages({ | ||
title: { | ||
id: 'judicial.system.core:public_prosecutor.tables.cases_reviewed.title', | ||
defaultMessage: 'Yfirlesin mál', | ||
description: 'Notaður sem titill á yfirlesin mál málalista', | ||
}, | ||
reviewTagAppealed: { | ||
id: 'judicial.system.core:public_prosecutor.tables.cases_reviewed.review_tag_appealed', | ||
defaultMessage: 'Áfrýjun', | ||
description: | ||
'Notað sem texti á tagg fyrir "Áfrýjun" tillögu í yfirlesin mál málalista', | ||
}, | ||
reviewTagAccepted: { | ||
id: 'judicial.system.core:public_prosecutor.tables.cases_reviewed.review_tag_completed', | ||
defaultMessage: 'Unun', | ||
description: | ||
'Notað sem texti á tagg fyrir "Unun" tillögu í yfirlesin mál málalista', | ||
}, | ||
infoContainerMessage: { | ||
id: 'judicial.system.core:public_prosecutor.tables.cases_reviewed.info_container_message', | ||
defaultMessage: 'Engin yfirlesin mál.', | ||
description: | ||
'Notaður sem skilaboð í upplýsingaglugga ef engin yfirlesin mál eru til.', | ||
}, | ||
infoContainerTitle: { | ||
id: 'judicial.system.core:public_prosecutor.tables.cases_reviewed.info_container_title', | ||
defaultMessage: 'Engin mál', | ||
description: | ||
'Notaður sem titill á upplýsingaglugga ef engin yfirlesin mál eru til.', | ||
}, | ||
}) |
107 changes: 107 additions & 0 deletions
107
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesReviewed.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import React, { FC } from 'react' | ||
import { useIntl } from 'react-intl' | ||
import { AnimatePresence } from 'framer-motion' | ||
|
||
import { Tag, Text } from '@island.is/island-ui/core' | ||
import { capitalize } from '@island.is/judicial-system/formatters' | ||
import { core, tables } from '@island.is/judicial-system-web/messages' | ||
import { SectionHeading } from '@island.is/judicial-system-web/src/components' | ||
import { useContextMenu } from '@island.is/judicial-system-web/src/components/ContextMenu/ContextMenu' | ||
import { | ||
CourtCaseNumber, | ||
DefendantInfo, | ||
} from '@island.is/judicial-system-web/src/components/Table' | ||
import Table, { | ||
TableWrapper, | ||
} from '@island.is/judicial-system-web/src/components/Table/Table' | ||
import TableInfoContainer from '@island.is/judicial-system-web/src/components/Table/TableInfoContainer/TableInfoContainer' | ||
import { | ||
CaseListEntry, | ||
IndictmentCaseReviewDecision, | ||
} from '@island.is/judicial-system-web/src/graphql/schema' | ||
|
||
import { strings } from './CasesReviewed.strings' | ||
|
||
interface Props { | ||
loading: boolean | ||
cases: CaseListEntry[] | ||
} | ||
|
||
const CasesReviewed: FC<Props> = ({ loading, cases }) => { | ||
const { formatMessage } = useIntl() | ||
const { openCaseInNewTabMenuItem } = useContextMenu() | ||
|
||
const decisionMapping = { | ||
[IndictmentCaseReviewDecision.ACCEPT]: formatMessage( | ||
strings.reviewTagAccepted, | ||
), | ||
[IndictmentCaseReviewDecision.APPEAL]: formatMessage( | ||
strings.reviewTagAppealed, | ||
), | ||
} | ||
|
||
return ( | ||
<> | ||
<SectionHeading title={formatMessage(strings.title)} /> | ||
<AnimatePresence initial={false}> | ||
<TableWrapper loading={loading}> | ||
{cases.length > 0 ? ( | ||
<Table | ||
thead={[ | ||
{ | ||
title: formatMessage(tables.caseNumber), | ||
}, | ||
{ | ||
title: capitalize( | ||
formatMessage(core.defendant, { suffix: 'i' }), | ||
), | ||
sortable: { isSortable: true, key: 'defendant' }, | ||
}, | ||
{ title: formatMessage(tables.reviewDecision) }, | ||
{ title: formatMessage(tables.prosecutorName) }, | ||
]} | ||
data={cases} | ||
generateContextMenuItems={(row) => { | ||
return [openCaseInNewTabMenuItem(row.id)] | ||
}} | ||
columns={[ | ||
{ | ||
cell: (row) => ( | ||
<CourtCaseNumber | ||
courtCaseNumber={row.courtCaseNumber ?? ''} | ||
policeCaseNumbers={row.policeCaseNumbers ?? []} | ||
appealCaseNumber={row.appealCaseNumber ?? ''} | ||
/> | ||
), | ||
}, | ||
{ | ||
cell: (row) => <DefendantInfo defendants={row.defendants} />, | ||
}, | ||
{ | ||
cell: (row) => ( | ||
<Tag variant="darkerBlue" outlined disabled truncate> | ||
{row.indictmentReviewDecision && | ||
decisionMapping[row.indictmentReviewDecision]} | ||
</Tag> | ||
), | ||
}, | ||
{ | ||
cell: (row: CaseListEntry) => ( | ||
<Text>{row.indictmentReviewer?.name}</Text> | ||
), | ||
}, | ||
]} | ||
/> | ||
) : ( | ||
<TableInfoContainer | ||
title={formatMessage(strings.infoContainerTitle)} | ||
message={formatMessage(strings.infoContainerMessage)} | ||
/> | ||
)} | ||
</TableWrapper> | ||
</AnimatePresence> | ||
</> | ||
) | ||
} | ||
|
||
export default CasesReviewed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,7 @@ query Cases { | |
id | ||
name | ||
} | ||
indictmentReviewDecision | ||
indictmentAppealDeadline | ||
} | ||
} |