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): Postponed Indefinitely Explanation #14655

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -1,40 +1,24 @@
import { defineMessages } from 'react-intl'

export const infoCardActiveIndictment = defineMessages({
indictmentCreated: {
id: 'judicial.system.core:info_card_active_indictment.indictment_created',
defaultMessage: 'Dagsetning ákæru',
description:
'Notaður sem titill á "dagsetningu ákæru" hluta af yfirliti ákæru.',
export const strings = defineMessages({
spokesperson: {
id: 'judicial.system.core:info_card.spokesperson',
defaultMessage: 'Talsmaður',
description: 'Notaður sem titill á "talsmanni" á upplýsingaspjaldi máls.',
},
prosecutor: {
id: 'judicial.system.core:info_card_active_indictment.prosecutor',
defaultMessage: 'Ákærandi',
description: 'Notaður sem titill á "ákærandi" hluta af yfirliti ákæru.',
defender: {
id: 'judicial.system.core:info_card.defender',
defaultMessage: 'Verjandi',
description: 'Notaður sem titill á "verjanda" á upplýsingaspjaldi máls.',
},
offence: {
id: 'judicial.system.core:info_card_active_indictment.offence',
defaultMessage: 'Brot',
description: 'Notaður sem titill á "brot" hluta af yfirliti ákæru.',
defenders: {
id: 'judicial.system.core:info_card.defenders',
defaultMessage: 'Verjendur',
description: 'Notaður sem titill á "verjendum" á upplýsingaspjaldi máls.',
},
})

export const infoCardCaseScheduled = defineMessages({
scheduled: {
id: 'judicial.system.core:info_card_case_scheduled.scheduled',
defaultMessage: 'Á dagskrá',
description: 'Notaður sem texti sem tilgreinir að málið sé á dagskrá',
},
postponed: {
id: 'judicial.system.core:info_card_case_scheduled.postponed',
defaultMessage: 'Frestað',
description:
'Notaður sem texti sem tilgreinir að málinu hafi verið sé frestað',
},
courtRoom: {
id: 'judicial.system.core:info_card_case_scheduled.court_room',
defaultMessage:
'{courtRoom, select, NONE {Dómsalur hefur ekki verið skráður} other {Dómsalur {courtRoom}}}',
description: 'Notaður sem texti sem tilgreinir hvaða dómsalur er skráður',
noDefender: {
id: 'judicial.system.core:info_card.no_defender',
defaultMessage: 'Hefur ekki verið skráður',
description: 'Notaður sem texti þegar enginn verjandi er skráður.',
},
})
12 changes: 9 additions & 3 deletions apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import { useIntl } from 'react-intl'

import { Box, Icon, IconMapIcon, LinkV2, Text } from '@island.is/island-ui/core'
import { formatDOB } from '@island.is/judicial-system/formatters'
Expand All @@ -7,6 +8,7 @@ import {
SessionArrangements,
} from '@island.is/judicial-system-web/src/graphql/schema'

import { strings } from './InfoCard.strings'
import { link } from '../MarkdownWrapper/MarkdownWrapper.css'
import * as styles from './InfoCard.css'

Expand Down Expand Up @@ -44,6 +46,8 @@ export const NameAndEmail = (name?: string | null, email?: string | null) => [
const UniqueDefenders: React.FC<
React.PropsWithChildren<UniqueDefendersProps>
> = (props) => {
const { formatMessage } = useIntl()

const { defenders } = props
const uniqueDefenders = defenders?.filter(
(defender, index, self) =>
Expand All @@ -55,8 +59,10 @@ const UniqueDefenders: React.FC<
<Text variant="h4">
{defenders[0].sessionArrangement ===
SessionArrangements.ALL_PRESENT_SPOKESPERSON
? 'Talsmaður'
: `Verj${uniqueDefenders.length > 1 ? 'endur' : 'andi'}`}
? formatMessage(strings.spokesperson)
: uniqueDefenders.length > 1
? formatMessage(strings.defenders)
: formatMessage(strings.defender)}
</Text>
{uniqueDefenders.map((defender, index) =>
defender?.name ? (
Expand All @@ -70,7 +76,7 @@ const UniqueDefenders: React.FC<
</Box>
) : (
<Text key={`defender_not_registered_${index}`}>
Hefur ekki verið skráður
{formatMessage(strings.noDefender)}
</Text>
),
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,30 @@ import { useIntl } from 'react-intl'
import { Text } from '@island.is/island-ui/core'
import {
capitalize,
formatCaseType,
formatDate,
readableIndictmentSubtypes,
} from '@island.is/judicial-system/formatters'
import { isIndictmentCase } from '@island.is/judicial-system/types'
import { core } from '@island.is/judicial-system-web/messages'

import { FormContext } from '../FormProvider/FormProvider'
import InfoCard, { NameAndEmail } from './InfoCard'
import { infoCardActiveIndictment as m } from './InfoCard.strings'
import { strings } from './InfoCardIndictment.strings'

const InfoCardActiveIndictment: React.FC<
React.PropsWithChildren<unknown>
> = () => {
const { workingCase } = useContext(FormContext)
const { formatMessage } = useIntl()

return (
<InfoCard
data={[
{
title: formatMessage(m.indictmentCreated),
title: formatMessage(strings.indictmentCreated),
value: formatDate(workingCase.created, 'PP'),
},
{
title: formatMessage(m.prosecutor),
title: formatMessage(strings.prosecutor),
value: NameAndEmail(
workingCase.prosecutor?.name,
workingCase.prosecutor?.email,
Expand All @@ -45,8 +44,8 @@ const InfoCardActiveIndictment: React.FC<
value: workingCase.court?.name,
},
{
title: formatMessage(m.offence),
value: isIndictmentCase(workingCase.type) ? (
title: formatMessage(strings.offence),
value: (
<>
{readableIndictmentSubtypes(
workingCase.policeCaseNumbers,
Expand All @@ -55,8 +54,6 @@ const InfoCardActiveIndictment: React.FC<
<Text key={`${subtype}-${index}`}>{capitalize(subtype)}</Text>
))}
</>
) : (
formatCaseType(workingCase.type)
),
},
]}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineMessages } from 'react-intl'

export const strings = defineMessages({
scheduled: {
id: 'judicial.system.core:info_card_case_scheduled.scheduled',
defaultMessage: 'Á dagskrá',
description: 'Notaður sem texti sem tilgreinir að málið sé á dagskrá',
},
courtRoom: {
id: 'judicial.system.core:info_card_case_scheduled.court_room',
defaultMessage:
'{courtRoom, select, NONE {Dómsalur hefur ekki verið skráður} other {Dómsalur {courtRoom}}}',
description: 'Notaður sem texti sem tilgreinir hvaða dómsalur er skráður',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ import { formatDate } from '@island.is/judicial-system/formatters'

import { Institution } from '../../graphql/schema'
import InfoCard from './InfoCard'
import { infoCardCaseScheduled as strings } from './InfoCard.strings'
import { strings } from './InfoCardCaseScheduled.strings'

interface Props {
court: Institution
courtDate: string
courtRoom?: string | null
postponedIndefinitelyExplanation?: string | null
}

const InfoCardCaseScheduled: React.FC<Props> = (props) => {
const { court, courtDate, courtRoom, postponedIndefinitelyExplanation } =
props
const { court, courtDate, courtRoom } = props
const { formatMessage } = useIntl()

return (
Expand All @@ -28,9 +26,7 @@ const InfoCardCaseScheduled: React.FC<Props> = (props) => {
value: (
<>
<Text variant="eyebrow" marginBottom={1} marginTop={2}>
{postponedIndefinitelyExplanation
? formatMessage(strings.postponed)
: formatDate(courtDate, 'PPPp')}
{formatDate(courtDate, 'PPPp')}
</Text>
{<Text>{court.name}</Text>}
<Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineMessages } from 'react-intl'

export const strings = defineMessages({
postponed: {
id: 'judicial.system.core:info_card_case_scheduled.postponed',
defaultMessage: 'Frestað um ótilgreindan tíma',
description:
'Notaður sem texti sem tilgreinir að málinu hafi verið sé frestað',
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react'
import { useIntl } from 'react-intl'

import { Institution } from '../../graphql/schema'
import InfoCard from './InfoCard'
import InfoCardCaseScheduled from './InfoCardCaseScheduled'
import { strings } from './InfoCardCaseScheduledIndictment.strings'

interface Props {
court: Institution
courtDate: string
courtRoom?: string | null
postponedIndefinitelyExplanation?: string | null
}

const InfoCardCaseScheduledIndictment: React.FC<Props> = (props) => {
const { court, courtDate, courtRoom, postponedIndefinitelyExplanation } =
props
const { formatMessage } = useIntl()

return postponedIndefinitelyExplanation ? (
<InfoCard
data={[
{
title: formatMessage(strings.postponed),
value: postponedIndefinitelyExplanation,
},
]}
icon="calendar"
/>
) : (
<InfoCardCaseScheduled
court={court}
courtDate={courtDate}
courtRoom={courtRoom}
/>
)
}

export default InfoCardCaseScheduledIndictment
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { useIntl } from 'react-intl'
import { Text } from '@island.is/island-ui/core'
import {
capitalize,
formatCaseType,
readableIndictmentSubtypes,
} from '@island.is/judicial-system/formatters'
import { isIndictmentCase } from '@island.is/judicial-system/types'
import { core } from '@island.is/judicial-system-web/messages'

import { FormContext } from '../FormProvider/FormProvider'
import InfoCard, { NameAndEmail } from './InfoCard'
import { infoCardActiveIndictment as m } from './InfoCard.strings'
import { strings } from './InfoCardIndictment.strings'

const InfoCardClosedIndictment: React.FC<
React.PropsWithChildren<unknown>
Expand Down Expand Up @@ -51,7 +49,7 @@ const InfoCardClosedIndictment: React.FC<
value: workingCase.court?.name,
},
{
title: formatMessage(m.prosecutor),
title: formatMessage(strings.prosecutor),
value: NameAndEmail(
workingCase.prosecutor?.name,
workingCase.prosecutor?.email,
Expand All @@ -65,8 +63,8 @@ const InfoCardClosedIndictment: React.FC<
),
},
{
title: formatMessage(m.offence),
value: isIndictmentCase(workingCase.type) ? (
title: formatMessage(strings.offence),
value: (
<>
{readableIndictmentSubtypes(
workingCase.policeCaseNumbers,
Expand All @@ -75,8 +73,6 @@ const InfoCardClosedIndictment: React.FC<
<Text key={subtype}>{capitalize(subtype)}</Text>
))}
</>
) : (
formatCaseType(workingCase.type)
),
},
]}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineMessages } from 'react-intl'

export const strings = defineMessages({
indictmentCreated: {
id: 'judicial.system.core:info_card_indictment.indictment_created',
defaultMessage: 'Ákæra skráð',
description:
'Notaður sem titill á "dagsetningu ákæru" hluta af yfirliti ákæru.',
},
prosecutor: {
id: 'judicial.system.core:info_card_indictment.prosecutor',
defaultMessage: 'Ákærandi',
description: 'Notaður sem titill á "ákærandi" hluta af yfirliti ákæru.',
},
offence: {
id: 'judicial.system.core:info_card_indictment.offence',
defaultMessage: 'Brot',
description: 'Notaður sem titill á "brot" hluta af yfirliti ákæru.',
},
})
2 changes: 2 additions & 0 deletions apps/judicial-system/web/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export { default as InfoBox } from './InfoBox/InfoBox'
export { default as InfoCard } from './InfoCard/InfoCard'
export { default as InfoCardActiveIndictment } from './InfoCard/InfoCardActiveIndictment'
export { default as InfoCardClosedIndictment } from './InfoCard/InfoCardClosedIndictment'
export { default as InfoCardCaseScheduled } from './InfoCard/InfoCardCaseScheduled'
export { default as InfoCardCaseScheduledIndictment } from './InfoCard/InfoCardCaseScheduledIndictment'
export { default as Loading } from './Loading/Loading'
export { default as Logo } from './Logo/Logo'
export { default as MarkdownWrapper } from './MarkdownWrapper/MarkdownWrapper'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import {
FormContext,
FormFooter,
InfoCard,
InfoCardCaseScheduled,
PageHeader,
PageLayout,
PdfButton,
UserContext,
} from '@island.is/judicial-system-web/src/components'
import { NameAndEmail } from '@island.is/judicial-system-web/src/components/InfoCard/InfoCard'
import InfoCardCaseScheduled from '@island.is/judicial-system-web/src/components/InfoCard/InfoCardCaseScheduled'
import { CaseState } from '@island.is/judicial-system-web/src/graphql/schema'
import {
UploadState,
Expand Down Expand Up @@ -112,9 +112,6 @@ const Overview = () => {
court={workingCase.court}
courtDate={workingCase.arraignmentDate.date}
courtRoom={workingCase.arraignmentDate.location}
postponedIndefinitelyExplanation={
workingCase.postponedIndefinitelyExplanation
}
/>
</Box>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import {
FormContext,
FormFooter,
InfoCard,
InfoCardCaseScheduled,
PageHeader,
PageLayout,
PdfButton,
UserContext,
} from '@island.is/judicial-system-web/src/components'
import { NameAndEmail } from '@island.is/judicial-system-web/src/components/InfoCard/InfoCard'
import InfoCardCaseScheduled from '@island.is/judicial-system-web/src/components/InfoCard/InfoCardCaseScheduled'
import {
CaseLegalProvisions,
CaseState,
Expand Down Expand Up @@ -117,9 +117,6 @@ export const JudgeOverview: React.FC<React.PropsWithChildren<unknown>> = () => {
court={workingCase.court}
courtDate={workingCase.arraignmentDate.date}
courtRoom={workingCase.arraignmentDate.location}
postponedIndefinitelyExplanation={
workingCase.postponedIndefinitelyExplanation
}
/>
</Box>
)}
Expand Down
Loading
Loading