Skip to content

Commit

Permalink
chore(judicial-system): Use "Varnaraðili" instead of "Sakborningur" e…
Browse files Browse the repository at this point in the history
…verywhere (#6171)

* Change Sakborningur to varnaraðili

* Use Varnaradili in info card

* Use Varnaradili in policeRequestAccordionItem

* Use accused from core in requests table

* Fix tests

Co-authored-by: Ívar Oddsson <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 7, 2022
1 parent ec500fe commit 66cf7bc
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 28 deletions.
64 changes: 64 additions & 0 deletions apps/judicial-system/web/messages/Core/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ import { defineMessage, defineMessages } from 'react-intl'
export const requests = {
sections: {
activeRequests: {
table: {
headers: {
caseNumber: defineMessage({
id:
'judicial.system.core:requests.active_requests.table.headers.case_number',
defaultMessage: 'Málsnr.',
description:
'Notaður sem titill fyrir málsnúmer dálk í lista yfir kröfur í vinnslu.',
}),
type: defineMessage({
id:
'judicial.system.core:requests.active_requests.table.headers.type',
defaultMessage: 'Tegund',
description:
'Notaður sem titill fyrir tegund dálk í lista yfir kröfur í vinnslu.',
}),
state: defineMessage({
id:
'judicial.system.core:requests.active_requests.table.headers.state',
defaultMessage: 'Staða',
description:
'Notaður sem titill fyrir staða dálk í lista yfir kröfur í vinnslu.',
}),
created: defineMessage({
id:
'judicial.system.core:requests.active_requests.table.headers.created',
defaultMessage: 'Krafa stofnuð',
description:
'Notaður sem titill fyrir krafa stofnuð dálk í lista yfir kröfur í vinnslu.',
}),
},
},
title: defineMessage({
id: 'judicial.system.core:requests.active_requests.title',
defaultMessage: 'Kröfur í vinnslu',
Expand Down Expand Up @@ -53,6 +85,38 @@ export const requests = {
}),
},
pastRequests: {
table: {
headers: {
caseNumber: defineMessage({
id:
'judicial.system.core:requests.past_requests.table.headers.case_number',
defaultMessage: 'Málsnr.',
description:
'Notaður sem titill fyrir málsnúmer dálk í lista yfir afgreiddar kröfur.',
}),
type: defineMessage({
id:
'judicial.system.core:requests.past_requests.table.headers.type',
defaultMessage: 'Tegund',
description:
'Notaður sem titill fyrir tegund dálk í lista yfir afgreiddar kröfur.',
}),
state: defineMessage({
id:
'judicial.system.core:requests.past_requests.table.headers.state',
defaultMessage: 'Staða',
description:
'Notaður sem titill fyrir staða dálk í lista yfir afgreiddar kröfur.',
}),
duration: defineMessage({
id:
'judicial.system.core:requests.past_requests.table.headers.duration',
defaultMessage: 'Gildistími',
description:
'Notaður sem titill fyrir gildistíma dálk í lista yfir afgreiddar kröfur.',
}),
},
},
title: defineMessage({
id: 'judicial.system.core:requests.past_requests.title',
defaultMessage: 'Afgreiddar kröfur',
Expand Down
1 change: 1 addition & 0 deletions apps/judicial-system/web/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ export * from './Core/restrictions'
export * from './Core/login'
export * from './Core/closedCourt'
export * from './Core/ruling'
export * from './Core/requests'
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const PoliceRequestAccordionItem: React.FC<Props> = ({
>
<Box marginBottom={2}>
<Text variant="h4" as="h4">
Grunnupplýsingar
{formatMessage(core.accused)}
</Text>
</Box>
<Box marginBottom={1}>
Expand Down
46 changes: 36 additions & 10 deletions apps/judicial-system/web/src/components/InfoCard/InfoCard.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ import React from 'react'
import { render, screen } from '@testing-library/react'

import InfoCard from './InfoCard'
import { LocaleProvider } from '@island.is/localization'
import { MockedProvider } from '@apollo/client/testing'

describe('InfoCard', () => {
test('should display the assigned defender name if that info is provided even though the defender email is not', async () => {
// Arrange
render(<InfoCard data={[]} defender={{ name: 'Joe' }} />)
render(
<MockedProvider>
<LocaleProvider locale="is" messages={{}}>
<InfoCard data={[]} defender={{ name: 'Joe' }} />
</LocaleProvider>
</MockedProvider>,
)

// Act and Assert
expect(await screen.findByText('Joe')).toBeTruthy()
Expand All @@ -15,10 +23,14 @@ describe('InfoCard', () => {
test('should display the assigned defender name and phonenumber if that info is provided', async () => {
// Arrange
render(
<InfoCard
data={[]}
defender={{ name: 'Joe', phoneNumber: '555-5555' }}
/>,
<MockedProvider>
<LocaleProvider locale="is" messages={{}}>
<InfoCard
data={[]}
defender={{ name: 'Joe', phoneNumber: '555-5555' }}
/>
</LocaleProvider>
</MockedProvider>,
)

// Act and Assert
Expand All @@ -28,10 +40,18 @@ describe('InfoCard', () => {
test('should display the assigned defender name, email and phonenumber if that info is provided', async () => {
// Arrange
render(
<InfoCard
data={[]}
defender={{ name: 'Joe', email: '[email protected]', phoneNumber: '455-5544' }}
/>,
<MockedProvider>
<LocaleProvider locale="is" messages={{}}>
<InfoCard
data={[]}
defender={{
name: 'Joe',
email: '[email protected]',
phoneNumber: '455-5544',
}}
/>
</LocaleProvider>
</MockedProvider>,
)

// Act and Assert
Expand All @@ -40,7 +60,13 @@ describe('InfoCard', () => {

test('should display a message saying that a defender has not been set if the defender info is missing', async () => {
// Arrange
render(<InfoCard data={[]} />)
render(
<MockedProvider>
<LocaleProvider locale="is" messages={{}}>
<InfoCard data={[]} />
</LocaleProvider>
</MockedProvider>,
)

// Act and Assert
expect(await screen.findByText('Hefur ekki verið skráður')).toBeTruthy()
Expand Down
13 changes: 8 additions & 5 deletions apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import React, { PropsWithChildren } from 'react'
import { useIntl } from 'react-intl'

import { Box, Text } from '@island.is/island-ui/core'
import { formatNationalId } from '@island.is/judicial-system/formatters'
import React, { PropsWithChildren } from 'react'
import { core } from '@island.is/judicial-system-web/messages'

import * as styles from './InfoCard.css'

interface Props {
Expand All @@ -14,15 +18,14 @@ interface Props {
phoneNumber?: string
defenderIsSpokesperson?: boolean
}
isInvestigationCase?: boolean
}

const InfoCard: React.FC<Props> = (props: PropsWithChildren<Props>) => {
const { formatMessage } = useIntl()

return (
<Box className={styles.infoCardContainer} data-testid="infoCard">
<Text variant="h4">
{props.isInvestigationCase ? 'Varnaraðili' : 'Sakborningur'}
</Text>
<Text variant="h4">{formatMessage(core.accused)}</Text>
<Box className={styles.infoCardTitleContainer}>
<Box marginBottom={4}>
<Text fontWeight="semiBold">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ const OverviewForm: React.FC<Props> = (props) => {
phoneNumber: workingCase.defenderPhoneNumber,
defenderIsSpokesperson: workingCase.defenderIsSpokesperson,
}}
isInvestigationCase
/>
</Box>
{!workingCase.isMasked && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ const OverviewForm: React.FC<Props> = (props) => {
phoneNumber: workingCase.defenderPhoneNumber,
defenderIsSpokesperson: workingCase.defenderIsSpokesperson,
}}
isInvestigationCase
/>
</Box>
{workingCase.description && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useContext, useMemo, useState } from 'react'
import { useIntl } from 'react-intl'
import cn from 'classnames'
import localeIS from 'date-fns/locale/is'
import format from 'date-fns/format'
Expand All @@ -13,6 +14,7 @@ import {
SortConfig,
} from '@island.is/judicial-system-web/src/types'
import { capitalize, caseTypes } from '@island.is/judicial-system/formatters'
import { core, requests } from '@island.is/judicial-system-web/messages'
import type { Case } from '@island.is/judicial-system/types'

import { mapCaseStateToTagVariant } from './utils'
Expand All @@ -28,6 +30,7 @@ const ActiveRequests: React.FC<Props> = (props) => {
const { cases, onRowClick, onDeleteCase } = props

const { user } = useContext(UserContext)
const { formatMessage } = useIntl()
const isProsecutor = user?.role === UserRole.PROSECUTOR
const isCourtRole =
user?.role === UserRole.JUDGE || user?.role === UserRole.REGISTRAR
Expand Down Expand Up @@ -84,7 +87,9 @@ const ActiveRequests: React.FC<Props> = (props) => {
<tr>
<th className={styles.th}>
<Text as="span" fontWeight="regular">
Málsnr.
{formatMessage(
requests.sections.activeRequests.table.headers.caseNumber,
)}
</Text>
</th>
<th className={cn(styles.th, styles.largeColumn)}>
Expand All @@ -96,7 +101,7 @@ const ActiveRequests: React.FC<Props> = (props) => {
onClick={() => requestSort('accusedName')}
data-testid="accusedNameSortButton"
>
<Text fontWeight="regular">Sakborningur</Text>
<Text fontWeight="regular">{formatMessage(core.accused)}</Text>
<Box
className={cn(styles.sortIcon, {
[styles.sortAccusedNameAsc]:
Expand All @@ -115,12 +120,16 @@ const ActiveRequests: React.FC<Props> = (props) => {
</th>
<th className={styles.th}>
<Text as="span" fontWeight="regular">
Tegund
{formatMessage(
requests.sections.activeRequests.table.headers.type,
)}
</Text>
</th>
<th className={styles.th}>
<Text as="span" fontWeight="regular">
Staða
{formatMessage(
requests.sections.activeRequests.table.headers.state,
)}
</Text>
</th>
<th className={styles.th}>
Expand All @@ -131,7 +140,11 @@ const ActiveRequests: React.FC<Props> = (props) => {
className={styles.thButton}
onClick={() => requestSort('created')}
>
<Text fontWeight="regular">Krafa stofnuð</Text>
<Text fontWeight="regular">
{formatMessage(
requests.sections.activeRequests.table.headers.created,
)}
</Text>
<Box
className={cn(styles.sortIcon, {
[styles.sortCreatedAsc]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useContext, useMemo } from 'react'
import { useIntl } from 'react-intl'
import parseISO from 'date-fns/parseISO'

import { Box, Text, Tag } from '@island.is/island-ui/core'
Expand All @@ -19,6 +20,7 @@ import {
} from '@island.is/judicial-system/formatters'
import { Table } from '@island.is/judicial-system-web/src/components'
import { insertAt } from '@island.is/judicial-system-web/src/utils/formatters'
import { core, requests } from '@island.is/judicial-system-web/messages'

import { getAppealDate, mapCaseStateToTagVariant } from './utils'
import * as styles from './Requests.css'
Expand All @@ -31,13 +33,18 @@ interface Props {

const PastRequests: React.FC<Props> = (props) => {
const { cases, onRowClick, isHighCourtUser } = props

const { user } = useContext(UserContext)
const { formatMessage } = useIntl()

const sortableColumnIds = ['courtCaseNumber', 'accusedName', 'type']
const isCourtRole =
user?.role === UserRole.JUDGE || user?.role === UserRole.REGISTRAR
const prColumns = [
{
Header: 'Málsnr. ',
Header: formatMessage(
requests.sections.pastRequests.table.headers.caseNumber,
),
accessor: 'courtCaseNumber' as keyof Case,
Cell: (row: {
row: {
Expand All @@ -57,7 +64,7 @@ const PastRequests: React.FC<Props> = (props) => {
},
},
{
Header: 'Sakborningur',
Header: formatMessage(core.accused),
accessor: 'accusedName' as keyof Case,
Cell: (row: {
row: { original: { accusedName: string; accusedNationalId: string } }
Expand All @@ -80,7 +87,7 @@ const PastRequests: React.FC<Props> = (props) => {
},

{
Header: 'Tegund',
Header: formatMessage(requests.sections.pastRequests.table.headers.type),
accessor: 'type' as keyof Case,
Cell: (row: {
row: {
Expand Down Expand Up @@ -112,7 +119,7 @@ const PastRequests: React.FC<Props> = (props) => {
},

{
Header: 'Staða',
Header: formatMessage(requests.sections.pastRequests.table.headers.state),
accessor: 'state' as keyof Case,
disableSortBy: true,
Cell: (row: {
Expand All @@ -139,7 +146,9 @@ const PastRequests: React.FC<Props> = (props) => {
},
},
{
Header: 'Gildistími',
Header: formatMessage(
requests.sections.pastRequests.table.headers.duration,
),
accessor: 'rulingDate' as keyof Case,
disableSortBy: true,
Cell: (row: {
Expand Down

0 comments on commit 66cf7bc

Please sign in to comment.