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

fix(j-s): Default service status fix #16332

Merged
merged 10 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
Expand Up @@ -365,7 +365,8 @@ export class PoliceService {
? ServiceStatus.ELECTRONICALLY
: response.deliveredOnPaper || response.delivered === true
? ServiceStatus.IN_PERSON
: response.acknowledged === false
: response.acknowledged === false &&
response.delivered === false
? ServiceStatus.FAILED
: // TODO: handle expired
undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import PoliceDemands from '@island.is/judicial-system-web/src/routes//Prosecutor/InvestigationCase/PoliceDemands/PoliceDemands'
import PoliceDemands from '@island.is/judicial-system-web/src/routes/Prosecutor/InvestigationCase/PoliceDemands/PoliceDemands'

export default PoliceDemands
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const strings = defineMessages({
},
serviceStatusUnknown: {
id: 'judicial.system.core:service_announcement.service_status_unknown',
defaultMessage: 'Birtingastaða óþekkt',
defaultMessage: 'Ákæra er í birtingarferli',
description: 'Notaður sem texti þegar ekki er vitað um stöðu birtingar.',
},
servedToDefender: {
Expand All @@ -36,4 +36,9 @@ export const strings = defineMessages({
defaultMessage: 'Rafrænt pósthólf island.is - {date}',
description: 'Notaður sem texti þegar birti var í pósthólfi.',
},
subpoenaCreated: {
id: 'judicial.system.core:service_announcement.subpoena_created',
defaultMessage: 'Ákæra fór í birtingu {date}',
description: 'Notaður sem texti þegar birti var í pósthólfi.',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from '@island.is/judicial-system-web/src/graphql/schema'

import { useGetLawyer, useSubpoena } from '../../utils/hooks'
import { SubpoenaStatusQuery } from '../../utils/hooks/useSubpoena/getSubpoenaStatus.generated'
import { strings } from './ServiceAnnouncement.strings'

const mapServiceStatusTitle = (
Expand Down Expand Up @@ -40,7 +39,11 @@ const mapServiceStatusMessages = (
switch (subpoena.serviceStatus) {
case ServiceStatus.DEFENDER:
return [
`${subpoena.servedBy} - ${formatDate(subpoena.serviceDate, 'Pp')}`,
`${subpoena.servedBy ? subpoena.servedBy : ''}${
subpoena.serviceDate
? ` - ${formatDate(subpoena.serviceDate, 'Pp')}`
: ''
}`,
formatMessage(strings.servedToDefender, {
lawyerName: lawyer?.name,
practice: lawyer?.practice,
Expand All @@ -49,19 +52,29 @@ const mapServiceStatusMessages = (
case ServiceStatus.ELECTRONICALLY:
return [
formatMessage(strings.servedToElectronically, {
date: formatDate(subpoena.serviceDate, 'Pp'),
date: subpoena.serviceDate
? formatDate(subpoena.serviceDate, 'Pp')
: '',
}),
]
case ServiceStatus.IN_PERSON:
case ServiceStatus.FAILED:
return [
`${subpoena.servedBy} - ${formatDate(subpoena.serviceDate, 'Pp')}`,
`${subpoena.servedBy ? subpoena.servedBy : ''}${
subpoena.serviceDate
? ` - ${formatDate(subpoena.serviceDate, 'Pp')}`
: ''
}`,
subpoena.comment,
]
case ServiceStatus.EXPIRED:
return [formatMessage(strings.serviceStatusExpiredMessage)]
default:
return []
return [
formatMessage(strings.subpoenaCreated, {
date: subpoena.created ? formatDate(subpoena.created, 'Pp') : '',
}),
]
}
}

Expand Down Expand Up @@ -114,7 +127,7 @@ const ServiceAnnouncement: FC<ServiceAnnouncementProps> = (props) => {
}
}, [localSubpoena, subpoenaStatus, subpoenaStatusError])

return !defendantName ? null : !subpoena && !subpoenaStatusLoading ? (
return !subpoena && !subpoenaStatusLoading ? (
<Box marginBottom={2}>{renderError(formatMessage)}</Box>
) : subpoenaStatusLoading ? (
<Box display="flex" justifyContent="center" paddingY={5}>
Expand All @@ -123,7 +136,9 @@ const ServiceAnnouncement: FC<ServiceAnnouncementProps> = (props) => {
) : (
<Box marginBottom={2}>
<AlertMessage
title={`${formatMessage(title)} - ${defendantName}`}
title={`${formatMessage(title)}${
defendantName && subpoena?.serviceStatus ? ` - ${defendantName}` : ''
}`}
message={
<Box>
{messages.map((msg) => (
Expand All @@ -134,8 +149,10 @@ const ServiceAnnouncement: FC<ServiceAnnouncementProps> = (props) => {
</Box>
}
type={
subpoena?.serviceStatus === ServiceStatus.FAILED ||
subpoena?.serviceStatus === ServiceStatus.EXPIRED
!subpoena?.serviceStatus
? 'info'
: subpoena?.serviceStatus === ServiceStatus.FAILED ||
subpoena?.serviceStatus === ServiceStatus.EXPIRED
? 'warning'
: 'success'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@ const Overview: FC = () => {
</Box>
<ProsecutorCaseInfo workingCase={workingCase} />
{workingCase.defendants?.map((defendant) =>
defendant.subpoenas?.map((subpoena) => (
<ServiceAnnouncement
key={`${subpoena.id}-${subpoena.created}`}
subpoena={subpoena}
defendantName={defendant.name}
/>
)),
defendant.subpoenas?.map(
(subpoena) =>
subpoena.subpoenaId && (
<ServiceAnnouncement
key={`${subpoena.id}-${subpoena.created}`}
subpoena={subpoena}
defendantName={defendant.name}
/>
),
),
)}
{workingCase.court &&
latestDate?.date &&
Expand Down
Loading