-
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.
feat(j-s): Subpoena type decision on court overview screen (#15432)
* feat(j-s): Subpoena type decision on court overview screen * Update Subpoena.tsx --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: lommi <jonorn@gmail.com>
- Loading branch information
Showing
5 changed files
with
176 additions
and
67 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
22 changes: 22 additions & 0 deletions
22
apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.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,22 @@ | ||
import { defineMessages } from 'react-intl' | ||
|
||
export const strings = defineMessages({ | ||
title: { | ||
id: 'judicial.system.core:court.subpoena_type.title', | ||
defaultMessage: 'Tegund fyrirkalls', | ||
description: | ||
'Notaður sem titill fyrir Tegund fyrirkalls hluta á Fyrirkalls skjá í dómaraflæði í ákærum.', | ||
}, | ||
absence: { | ||
id: 'judicial.system.core:court.subpoena_type.absence', | ||
defaultMessage: 'Útivistarfyrirkall', | ||
description: | ||
'Notaður sem texti fyrir Útivistarfyrirkall valkost á Fyrirkalls skjá í dómaraflæði í ákærum.', | ||
}, | ||
arrest: { | ||
id: 'judicial.system.core:court.subpoena_type.arrest', | ||
defaultMessage: 'Handtökufyrirkall', | ||
description: | ||
'Notaður sem texti fyrir Handtökufyrirkall valkost á Fyrirkalls skjá í dómaraflæði í ákærum.', | ||
}, | ||
}) |
101 changes: 101 additions & 0 deletions
101
apps/judicial-system/web/src/routes/Court/components/SubpoenaType/SubpoenaType.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,101 @@ | ||
import React, { Dispatch, FC, SetStateAction } from 'react' | ||
import { useIntl } from 'react-intl' | ||
|
||
import { Box, RadioButton, Text } from '@island.is/island-ui/core' | ||
import { SubpoenaType as SubpoenaTypeEnum } from '@island.is/judicial-system/types' | ||
import { | ||
BlueBox, | ||
SectionHeading, | ||
} from '@island.is/judicial-system-web/src/components' | ||
import { | ||
Case, | ||
Defendant, | ||
UpdateDefendantInput, | ||
} from '@island.is/judicial-system-web/src/graphql/schema' | ||
|
||
import { strings } from './SubpoenaType.strings' | ||
import * as styles from '../../Indictments/Subpoena/Subpoena.css' | ||
|
||
interface SubpoenaTypeProps { | ||
defendants: Defendant[] | ||
workingCase: Case | ||
setWorkingCase: Dispatch<SetStateAction<Case>> | ||
updateDefendantState: ( | ||
update: UpdateDefendantInput, | ||
setWorkingCase: React.Dispatch<React.SetStateAction<Case>>, | ||
) => void | ||
required?: boolean | ||
} | ||
|
||
const SubpoenaType: FC<SubpoenaTypeProps> = ({ | ||
defendants, | ||
workingCase, | ||
setWorkingCase, | ||
updateDefendantState, | ||
required = true, | ||
}) => { | ||
const { formatMessage } = useIntl() | ||
const isArraignmentDone = Boolean(workingCase.indictmentDecision) | ||
return ( | ||
<> | ||
<SectionHeading | ||
title={formatMessage(strings.title)} | ||
required={required} | ||
/> | ||
{defendants.map((defendant, index) => ( | ||
<Box | ||
key={defendant.id} | ||
marginBottom={index === defendants.length ? 0 : 3} | ||
> | ||
<BlueBox> | ||
<Text as="h4" variant="h4" marginBottom={2}> | ||
{defendant.name} | ||
</Text> | ||
<Box className={styles.subpoenaTypeGrid}> | ||
<RadioButton | ||
large | ||
name="subpoenaType" | ||
id={`subpoenaTypeAbsence${defendant.id}`} | ||
backgroundColor="white" | ||
label={formatMessage(strings.absence)} | ||
checked={defendant.subpoenaType === SubpoenaTypeEnum.ABSENCE} | ||
onChange={() => { | ||
updateDefendantState( | ||
{ | ||
caseId: workingCase.id, | ||
defendantId: defendant.id, | ||
subpoenaType: SubpoenaTypeEnum.ABSENCE, | ||
}, | ||
setWorkingCase, | ||
) | ||
}} | ||
disabled={isArraignmentDone} | ||
/> | ||
<RadioButton | ||
large | ||
name="subpoenaType" | ||
id={`subpoenaTypeArrest${defendant.id}`} | ||
backgroundColor="white" | ||
label={formatMessage(strings.arrest)} | ||
checked={defendant.subpoenaType === SubpoenaTypeEnum.ARREST} | ||
onChange={() => { | ||
updateDefendantState( | ||
{ | ||
caseId: workingCase.id, | ||
defendantId: defendant.id, | ||
subpoenaType: SubpoenaTypeEnum.ARREST, | ||
}, | ||
setWorkingCase, | ||
) | ||
}} | ||
disabled={isArraignmentDone} | ||
/> | ||
</Box> | ||
</BlueBox> | ||
</Box> | ||
))} | ||
</> | ||
) | ||
} | ||
|
||
export default SubpoenaType |
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