Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
oddsson committed Nov 26, 2024
1 parent c044079 commit 1494993
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const getIndictmentInfo = (
eventLog?: EventLog[],
): IndictmentInfo => {
const indictmentInfo: IndictmentInfo = {}
const isFine = rulingDecision === CaseIndictmentRulingDecision.FINE

if (!rulingDate) {
return indictmentInfo
Expand All @@ -169,9 +170,8 @@ export const getIndictmentInfo = (

const verdictInfo = defendants?.map<[boolean, Date | undefined]>(
(defendant) => [
rulingDecision === CaseIndictmentRulingDecision.RULING ||
rulingDecision === CaseIndictmentRulingDecision.FINE,
defendant.serviceRequirement === ServiceRequirement.NOT_REQUIRED
rulingDecision === CaseIndictmentRulingDecision.RULING || isFine,
defendant.serviceRequirement === ServiceRequirement.NOT_REQUIRED || isFine
? new Date()
: defendant.verdictViewDate
? new Date(defendant.verdictViewDate)
Expand All @@ -180,7 +180,7 @@ export const getIndictmentInfo = (
)

const [indictmentVerdictViewedByAll, indictmentVerdictAppealDeadlineExpired] =
getIndictmentVerdictAppealDeadlineStatus(verdictInfo)
getIndictmentVerdictAppealDeadlineStatus(verdictInfo, isFine)
indictmentInfo.indictmentVerdictViewedByAll = indictmentVerdictViewedByAll
indictmentInfo.indictmentVerdictAppealDeadlineExpired =
indictmentVerdictAppealDeadlineExpired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const BlueBoxWithDate: FC<Props> = (props) => {
if (isFine) {
texts.push(
formatMessage(strings.fineAppealDeadline, {
appealDeadlineIsInThePast: !defendant.isVerdictAppealDeadlineExpired,
appealDeadlineIsInThePast: defendant.isVerdictAppealDeadlineExpired,
appealDeadline: formatDate(defendant.verdictAppealDeadline),
}),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const strings = defineMessages({
description: 'Notaður sem titill á yfirliti ákæru.',
},
reviewerSubtitle: {
id: 'judicial.system.core:public_prosecutor.indictments.overview.reviewer_subtitle',
id: 'judicial.system.core:public_prosecutor.indictments.overview.reviewer_subtitle_v2',
defaultMessage:
'Frestur til að áfrýja dómi rennur út {indictmentAppealDeadline}',
'Frestur til að {isFine, select, true {kæra viðurlagaákvörðun} other {áfrýja dómi}} {appealDeadlineIsInThePast, select, true {rann} other {rennur}} út {indictmentAppealDeadline}',
description: 'Notaður sem undirtitill á yfirliti ákæru.',
},
reviewerAssignedModalTitle: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useProsecutorSelectionUsersQuery } from '@island.is/judicial-system-web
import { useCase } from '@island.is/judicial-system-web/src/utils/hooks'

import { strings } from './Overview.strings'
import { CaseIndictmentRulingDecision } from '@island.is/judicial-system/types'
type VisibleModal = 'REVIEWER_ASSIGNED'

export const Overview = () => {
Expand Down Expand Up @@ -126,9 +127,14 @@ export const Overview = () => {
description={
<Text variant="eyebrow">
{fm(strings.reviewerSubtitle, {
isFine:
workingCase.indictmentRulingDecision ===
CaseIndictmentRulingDecision.FINE,
indictmentAppealDeadline: formatDate(
workingCase.indictmentAppealDeadline,
),
appealDeadlineIsInThePast:
workingCase.indictmentVerdictAppealDeadlineExpired,
})}
</Text>
}
Expand Down
12 changes: 9 additions & 3 deletions libs/judicial-system/types/src/lib/indictmentCase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const DAYS_TO_MILLISECONDS = 24 * 60 * 60 * 1000
export const VERDICT_APPEAL_WINDOW_DAYS = 28
export const FINE_APPEAL_WINDOW_DAYS = 3
const MILLISECONDS_TO_EXPIRY = VERDICT_APPEAL_WINDOW_DAYS * DAYS_TO_MILLISECONDS
const getDays = (days: number) => days * DAYS_TO_MILLISECONDS

/*
This function takes an array of verdict info tuples:
Expand All @@ -13,6 +13,7 @@ const MILLISECONDS_TO_EXPIRY = VERDICT_APPEAL_WINDOW_DAYS * DAYS_TO_MILLISECONDS
*/
export const getIndictmentVerdictAppealDeadlineStatus = (
verdictInfo?: [boolean, Date | undefined][],
isFine?: boolean,
): [boolean, boolean] => {
if (
!verdictInfo ||
Expand All @@ -22,18 +23,23 @@ export const getIndictmentVerdictAppealDeadlineStatus = (
return [true, true]
}

console.log('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', { verdictInfo })

if (
verdictInfo.some(
([canBeAppealed, viewedDate]) => canBeAppealed && !viewedDate,
)
) {
return [false, false]
}

console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&&&')
const newestViewDate = verdictInfo.reduce(
(newest, [_, current]) => (current && current > newest ? current : newest),
new Date(0),
)

return [true, Date.now() > newestViewDate.getTime() + MILLISECONDS_TO_EXPIRY]
return [
true,
Date.now() > newestViewDate.getTime() + getDays(isFine ? 3 : 28),
]
}

0 comments on commit 1494993

Please sign in to comment.