Skip to content

Commit

Permalink
Merge branch 'main' into my-pages/layout
Browse files Browse the repository at this point in the history
  • Loading branch information
disaerna authored Nov 1, 2024
2 parents 224132e + dc89848 commit a76e682
Show file tree
Hide file tree
Showing 184 changed files with 6,531 additions and 544 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tmp/
out-tsc/
**/tsconfig.tsbuildinfo
infra/mountebank-imposter-config.json
mountebank-imposter-config.json
infra/helm/**/*.tgz

# dependencies
Expand Down Expand Up @@ -96,3 +97,4 @@ apps/**/index.html
.next

.nx/
.zed/
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
/infra/helm/
/.nx/cache
/.nx/workspace-data
apps/web/public/assets/pdf.worker.min.mjs
apps/web/public/assets/pdf.worker.min.mjs
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"semi": false,
"trailingComma": "all",
"arrowParens": "always",
"plugins": ["./scripts/prettier-plugins/sort-projects"],
"plugins": ["./scripts/prettier-plugins/sort-projects.js"],
"endOfLine": "lf",
"overrides": [
{
Expand Down
45 changes: 23 additions & 22 deletions apps/api/infra/api.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
import { json, ref, service, ServiceBuilder } from '../../../infra/src/dsl/dsl'
import {
AdrAndMachine,
AircraftRegistry,
Base,
ChargeFjsV2,
EnergyFunds,
Client,
CriminalRecord,
DirectorateOfImmigration,
Disability,
DistrictCommissionersLicenses,
DistrictCommissionersPCard,
DrivingLicense,
DrivingLicenseBook,
Education,
EnergyFunds,
Finance,
Firearm,
FishingLicense,
Frigg,
HealthDirectorateOrganDonation,
HealthDirectorateVaccination,
HealthInsurance,
HousingBenefitCalculator,
Hunting,
IcelandicGovernmentInstitutionVacancies,
Inna,
IntellectualProperties,
JudicialAdministration,
JudicialSystemServicePortal,
Labor,
MunicipalitiesFinancialAid,
NationalRegistry,
NationalRegistryB2C,
OccupationalLicenses,
OfficialJournalOfIceland,
OfficialJournalOfIcelandApplication,
Passports,
Payment,
PaymentSchedule,
Properties,
RskCompanyInfo,
TransportAuthority,
Vehicles,
VehiclesMileage,
VehicleServiceFjsV1,
WorkMachines,
IcelandicGovernmentInstitutionVacancies,
RskProcuring,
AircraftRegistry,
HousingBenefitCalculator,
OccupationalLicenses,
ShipRegistry,
DistrictCommissionersPCard,
DistrictCommissionersLicenses,
DirectorateOfImmigration,
Hunting,
SignatureCollection,
SocialInsuranceAdministration,
IntellectualProperties,
Inna,
TransportAuthority,
UniversityCareers,
OfficialJournalOfIceland,
OfficialJournalOfIcelandApplication,
JudicialSystemServicePortal,
Frigg,
HealthDirectorateOrganDonation,
HealthDirectorateVaccination,
Vehicles,
VehicleServiceFjsV1,
VehiclesMileage,
WorkMachines,
} from '../../../infra/src/dsl/xroad'

export const serviceSetup = (services: {
Expand Down Expand Up @@ -469,5 +469,6 @@ export const serviceSetup = (services: {
'api-catalogue',
'application-system',
'consultation-portal',
'services-bff-portals-admin',
)
}
2 changes: 2 additions & 0 deletions apps/api/src/app/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const prodConfig = () => ({
basePath: process.env.ISLYKILL_SERVICE_BASEPATH,
},
})

const devConfig = () => ({
production: false,
xroad: {
Expand Down Expand Up @@ -207,6 +208,7 @@ const devConfig = () => ({
basePath: process.env.ISLYKILL_SERVICE_BASEPATH,
},
})

export const getConfig =
process.env.PROD_MODE === 'true' || process.env.NODE_ENV === 'production'
? prodConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
NestInterceptor,
} from '@nestjs/common'

import { isRequestCase } from '@island.is/judicial-system/types'
import {
CaseAppealDecision,
isRequestCase,
} from '@island.is/judicial-system/types'

import { getIndictmentInfo } from '../../case/interceptors/case.transformer'
import { CaseListEntry } from '../models/caseList.model'
Expand All @@ -20,6 +23,16 @@ const getAppealedDate = (
return prosecutorPostponedAppealDate ?? accusedPostponedAppealDate
}

const wasAcceptedInCourt = (
prosecutorAppealDecision?: CaseAppealDecision,
accusedAppealDecision?: CaseAppealDecision,
): boolean => {
return (
prosecutorAppealDecision === CaseAppealDecision.ACCEPT &&
accusedAppealDecision === CaseAppealDecision.ACCEPT
)
}

@Injectable()
export class CaseListInterceptor implements NestInterceptor {
intercept(
Expand All @@ -39,6 +52,15 @@ export class CaseListInterceptor implements NestInterceptor {
theCase.prosecutorPostponedAppealDate,
theCase.accusedPostponedAppealDate,
),
// This state overwrite is added in at least temporarily to handle strange
// behaviour when a case is reopened after being appealed and then closed
// again with everyone having accepted the ruling in court
appealState: !wasAcceptedInCourt(
theCase.prosecutorAppealDecision,
theCase.accusedAppealDecision,
)
? theCase.appealState
: undefined,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,29 @@ describe('getAppealInfo', () => {
})
})

it('should transform appeal state and dates if appeal data does not match up', () => {
const theCase = {
type: CaseType.CUSTODY,
rulingDate: '2022-06-15T19:50:08.033Z',
appealState: CaseAppealState.APPEALED,
accusedAppealDecision: CaseAppealDecision.ACCEPT,
prosecutorAppealDecision: CaseAppealDecision.ACCEPT,
accusedPostponedAppealDate: '2022-06-15T19:50:08.033Z',
prosecutorPostponedAppealDate: '2022-06-15T19:50:08.033Z',
} as Case

const appealInfo = getAppealInfo(theCase)

expect(appealInfo).toEqual({
canBeAppealed: false,
hasBeenAppealed: false,
appealedDate: undefined,
appealDeadline: '2022-06-18T19:50:08.033Z',
canDefenderAppeal: false,
canProsecutorAppeal: false,
})
})

const rulingDate = new Date().toISOString()

Object.values(CaseAppealDecision).forEach((decision) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,23 @@ export const getAppealInfo = (theCase: Case): AppealInfo => {
return appealInfo
}

const hasBeenAppealed = Boolean(appealState)

const didProsecutorAcceptInCourt =
prosecutorAppealDecision === CaseAppealDecision.ACCEPT
const didAccusedAcceptInCourt =
accusedAppealDecision === CaseAppealDecision.ACCEPT
const didAllAcceptInCourt =
didProsecutorAcceptInCourt && didAccusedAcceptInCourt

const hasBeenAppealed = Boolean(appealState) && !didAllAcceptInCourt
appealInfo.hasBeenAppealed = hasBeenAppealed

if (hasBeenAppealed) {
appealInfo.appealedByRole = prosecutorPostponedAppealDate
? UserRole.PROSECUTOR
: accusedPostponedAppealDate
? UserRole.DEFENDER
: undefined
appealInfo.appealedByRole =
prosecutorPostponedAppealDate && !didProsecutorAcceptInCourt
? UserRole.PROSECUTOR
: accusedPostponedAppealDate && !didAccusedAcceptInCourt
? UserRole.DEFENDER
: undefined

appealInfo.appealedDate =
appealInfo.appealedByRole === UserRole.PROSECUTOR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EmailService } from '@island.is/email-service'
import { type Logger, LOGGER_PROVIDER } from '@island.is/logging'
import { type ConfigType } from '@island.is/nest/config'

import { INDICTMENTS_COURT_OVERVIEW_ROUTE } from '@island.is/judicial-system/consts'
import { ROUTE_HANDLER_ROUTE } from '@island.is/judicial-system/consts'
import { SubpoenaNotificationType } from '@island.is/judicial-system/types'

import { Case } from '../case'
Expand Down Expand Up @@ -50,42 +50,33 @@ export class SubpoenaNotificationService extends BaseNotificationService {
notificationType: SubpoenaNotificationType,
subject: MessageDescriptor,
body: MessageDescriptor,
to: { name?: string; email?: string }[],
) {
const formattedSubject = this.formatMessage(subject, {
courtCaseNumber: theCase.courtCaseNumber,
})

const formattedBody = this.formatMessage(body, {
courtCaseNumber: theCase.courtCaseNumber,
linkStart: `<a href="${this.config.clientUrl}${INDICTMENTS_COURT_OVERVIEW_ROUTE}/${theCase.id}">`,
linkEnd: '</a>',
})
const promises: Promise<Recipient>[] = []

if (theCase.judge?.email) {
promises.push(
this.sendEmail(
formattedSubject,
formattedBody,
theCase.judge.name,
theCase.judge.email,
undefined,
true,
),
)
}

if (theCase.registrar?.email) {
promises.push(
this.sendEmail(
formattedSubject,
formattedBody,
theCase.registrar.name,
theCase.registrar.email,
undefined,
true,
),
)
for (const recipient of to) {
if (recipient.email && recipient.name) {
const formattedBody = this.formatMessage(body, {
courtCaseNumber: theCase.courtCaseNumber,
linkStart: `<a href="${this.config.clientUrl}${ROUTE_HANDLER_ROUTE}/${theCase.id}">`,
linkEnd: '</a>',
})

promises.push(
this.sendEmail(
formattedSubject,
formattedBody,
recipient.name,
recipient.email,
undefined,
true,
),
)
}
}

const recipients = await Promise.all(promises)
Expand All @@ -101,6 +92,20 @@ export class SubpoenaNotificationService extends BaseNotificationService {
SubpoenaNotificationType.SERVICE_SUCCESSFUL,
strings.serviceSuccessfulSubject,
strings.serviceSuccessfulBody,
[
{
name: theCase.judge?.name,
email: theCase.judge?.email,
},
{
name: theCase.registrar?.name,
email: theCase.registrar?.email,
},
{
name: theCase.prosecutor?.name,
email: theCase.prosecutor?.email,
},
],
)
}

Expand All @@ -112,6 +117,20 @@ export class SubpoenaNotificationService extends BaseNotificationService {
SubpoenaNotificationType.SERVICE_FAILED,
strings.serviceFailedSubject,
strings.serviceFailedBody,
[
{
name: theCase.judge?.name,
email: theCase.judge?.email,
},
{
name: theCase.registrar?.name,
email: theCase.registrar?.email,
},
{
name: theCase.prosecutor?.name,
email: theCase.prosecutor?.email,
},
],
)
}

Expand All @@ -123,6 +142,16 @@ export class SubpoenaNotificationService extends BaseNotificationService {
SubpoenaNotificationType.DEFENDANT_SELECTED_DEFENDER,
strings.defendantSelectedDefenderSubject,
strings.defendantSelectedDefenderBody,
[
{
name: theCase.judge?.name,
email: theCase.judge?.email,
},
{
name: theCase.registrar?.name,
email: theCase.registrar?.email,
},
],
)
}

Expand Down
3 changes: 3 additions & 0 deletions apps/judicial-system/web/pages/beinir/[id].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import RouteHandler from '@island.is/judicial-system-web/src/routes/Shared/RouteHandler/RouteHandler'

export default RouteHandler
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { style } from '@vanilla-extract/css'

export const loadingContainer = style({
position: 'absolute',
top: 0,
background: 'white',
width: '100vw',
height: '100vh',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
})
Loading

0 comments on commit a76e682

Please sign in to comment.