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/formstepper error #15180

Merged
merged 9 commits into from
Jun 11, 2024
396 changes: 198 additions & 198 deletions apps/judicial-system/backend/src/app/formatters/PDFKitCoatOfArms.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { applyCase } from 'beygla'
import { PDFDocument, rgb, StandardFonts } from 'pdf-lib'

import { formatDate } from '@island.is/judicial-system/formatters'

import {
calculatePt,
drawTextWithEllipsisPDFKit,
IndictmentConfirmation,
smallFontSize,
} from './pdfHelpers'
import { PDFKitCoatOfArms } from './PDFKitCoatOfArms'

Expand All @@ -21,32 +22,34 @@ export const createConfirmedIndictment = async (
const darkGray = rgb(0.7961, 0.7961, 0.7961)
const gold = rgb(0.6784, 0.6392, 0.451)
const white = rgb(1, 1, 1)
const pageMargin = 24
// The shaddow and content heights are the same
const shaddowHeight = 88
const coatOfArmsDimensions = 88
const coatOfArmsX = pageMargin + 8
const titleWidth = doc.getWidth() - 142
const titleHeight = 32
const titleX = coatOfArmsX + coatOfArmsDimensions + 8
const confirmedByWidth = 160
const institutionWidth = confirmedByWidth + 62

const { width, height } = doc.getSize()

const pageMargin = calculatePt(18)
const shaddowHeight = calculatePt(90)
const coatOfArmsWidth = calculatePt(105)
const coatOfArmsHeight = calculatePt(90)
const coatOfArmsX = pageMargin + calculatePt(8)
const titleWidth = width - coatOfArmsWidth - 2 * coatOfArmsX
const titleHeight = calculatePt(32)
const titleX = coatOfArmsX + coatOfArmsWidth + calculatePt(8)
const confirmedByWidth = calculatePt(258)
const confirmedByHeight = calculatePt(50)
const institutionWidth = confirmedByWidth + calculatePt(48)

// Draw the shaddow
doc.drawRectangle({
x: pageMargin,
y: height - shaddowHeight - 32,
width: doc.getWidth() - 2 * pageMargin - 8,
y: height - shaddowHeight - pageMargin,
width: doc.getWidth() - 2 * pageMargin - calculatePt(16),
height: shaddowHeight,
color: lightGray,
})

// Draw the box around the coat of arms
doc.drawRectangle({
x: coatOfArmsX,
y: height - coatOfArmsDimensions - pageMargin,
width: coatOfArmsDimensions,
height: coatOfArmsDimensions,
y: height - shaddowHeight - pageMargin + calculatePt(8),
width: coatOfArmsWidth,
height: coatOfArmsHeight,
color: rgb(1, 1, 1),
borderColor: darkGray,
borderWidth: 1,
Expand All @@ -55,8 +58,8 @@ export const createConfirmedIndictment = async (
PDFKitCoatOfArms(doc, height)

doc.drawRectangle({
x: coatOfArmsX + coatOfArmsDimensions,
y: height - pageMargin - titleHeight,
x: coatOfArmsX + coatOfArmsWidth,
y: height - pageMargin - titleHeight + calculatePt(8),
width: titleWidth,
height: titleHeight,
color: lightGray,
Expand All @@ -70,57 +73,68 @@ export const createConfirmedIndictment = async (
)
doc.drawText('Réttarvörslugátt', {
x: titleX,
y: height - 44,
size: 12,
y: height - pageMargin - titleHeight + calculatePt(20),
size: calculatePt(smallFontSize),
font: timesRomanBoldFont,
})

doc.drawText('Skjal samþykkt rafrænt', {
x: 220,
y: height - 44,
size: 12,
x: 158,
y: height - pageMargin - titleHeight + calculatePt(20),
size: calculatePt(smallFontSize),
font: timesRomanFont,
})

doc.drawSvgPath(
'M0.763563 11.8047H7.57201C7.85402 11.8047 8.08264 11.5761 8.08264 11.2941V5.50692C8.08264 5.22492 7.85402 4.99629 7.57201 4.99629H7.06138V3.46439C7.06138 1.86887 5.76331 0.570801 4.16779 0.570801C2.57226 0.570801 1.2742 1.86887 1.2742 3.46439V4.99629H0.763563C0.481557 4.99629 0.25293 5.22492 0.25293 5.50692V11.2941C0.25293 11.5761 0.481557 11.8047 0.763563 11.8047ZM5.61394 8.03817L4.16714 9.48496C4.06743 9.58467 3.93674 9.63455 3.80609 9.63455C3.67543 9.63455 3.54471 9.58467 3.44504 9.48496L2.72164 8.76157C2.52222 8.56215 2.52222 8.23888 2.72164 8.03943C2.92102 7.84001 3.24436 7.84001 3.44378 8.03943L3.80612 8.40174L4.89187 7.31603C5.09125 7.11661 5.41458 7.11661 5.614 7.31603C5.81339 7.51549 5.81339 7.83875 5.61394 8.03817ZM2.29546 3.46439C2.29546 2.43199 3.13539 1.59207 4.16779 1.59207C5.20019 1.59207 6.04011 2.43199 6.04011 3.46439V4.99629H2.29546V3.46439Z',
{ color: gold, x: width - 38, y: height - 34 },
{
color: gold,
x: width - 38,
y: height - pageMargin - titleHeight + calculatePt(33),
},
)

// Draw the "Confirmed by" box
doc.drawRectangle({
x: coatOfArmsX + coatOfArmsDimensions,
y: height - pageMargin - titleHeight - 56,
x: coatOfArmsX + coatOfArmsWidth,
y: height - pageMargin - titleHeight - confirmedByHeight,
width: confirmedByWidth,
height: shaddowHeight - titleHeight,
color: white,
borderColor: darkGray,
borderWidth: 1,
})

doc.drawText('Staðfest af', {
x: coatOfArmsX + coatOfArmsDimensions + 8,
y: height - pageMargin - titleHeight - 24,
size: 12,
doc.drawText('Staðfestingaraðili', {
x: titleX,
y: height - pageMargin - titleHeight - calculatePt(15),
size: calculatePt(smallFontSize),
font: timesRomanBoldFont,
})

if (confirmation?.actor) {
timesRomanFont.widthOfTextAtSize(applyCase('þgf', confirmation.actor), 12)
timesRomanFont.widthOfTextAtSize(
`${confirmation.actor}${
confirmation.title ? `, ${confirmation.title}` : ''
}`,
calculatePt(smallFontSize),
)
drawTextWithEllipsisPDFKit(
doc,
applyCase('þgf', confirmation.actor),
{ type: timesRomanFont, size: 12 },
coatOfArmsX + coatOfArmsDimensions + 8,
height - pageMargin - titleHeight - 40,
`${confirmation.actor}${
confirmation.title ? `, ${confirmation.title}` : ''
}`,
{ type: timesRomanFont, size: calculatePt(smallFontSize) },
titleX,
height - pageMargin - titleHeight - calculatePt(29),
confirmedByWidth - 16,
)
}

// Draw the "Institution" box
doc.drawRectangle({
x: coatOfArmsX + coatOfArmsDimensions + confirmedByWidth,
y: height - pageMargin - titleHeight - 56,
x: coatOfArmsX + coatOfArmsWidth + confirmedByWidth,
y: height - pageMargin - titleHeight - confirmedByHeight,
width: institutionWidth,
height: shaddowHeight - titleHeight,
color: white,
Expand All @@ -129,36 +143,36 @@ export const createConfirmedIndictment = async (
})

doc.drawText('Embætti', {
x: coatOfArmsX + coatOfArmsDimensions + confirmedByWidth + 8,
y: height - pageMargin - titleHeight - 24,
size: 12,
x: titleX + confirmedByWidth,
y: height - pageMargin - titleHeight - calculatePt(15),
size: calculatePt(smallFontSize),
font: timesRomanBoldFont,
})

if (confirmation?.institution) {
doc.drawText(confirmation.institution, {
x: coatOfArmsX + coatOfArmsDimensions + confirmedByWidth + 8,
y: height - pageMargin - titleHeight - 40,
x: titleX + confirmedByWidth,
y: height - pageMargin - titleHeight - calculatePt(29),
font: timesRomanFont,
size: 12,
size: calculatePt(smallFontSize),
})
}

// Draw the "Indictment date" box
doc.drawRectangle({
x: width - 88 - 22,
y: height - pageMargin - titleHeight - 56,
width: 88,
x: width - 90,
y: height - pageMargin - titleHeight - confirmedByHeight,
width: 70,
height: shaddowHeight - titleHeight,
color: white,
borderColor: darkGray,
borderWidth: 1,
})

doc.drawText('Útgáfa ákæru', {
x: width - 88 - 16,
y: height - pageMargin - titleHeight - 24,
size: 12,
x: width - 72,
y: height - pageMargin - titleHeight - calculatePt(15),
size: calculatePt(smallFontSize),
font: timesRomanBoldFont,
})

Expand All @@ -167,10 +181,10 @@ export const createConfirmedIndictment = async (

if (dateFormattedDate) {
doc.drawText(dateFormattedDate, {
x: width - 88 - 16,
y: height - pageMargin - titleHeight - 40,
x: width - 62,
y: height - pageMargin - titleHeight - calculatePt(29),
font: timesRomanFont,
size: 12,
size: calculatePt(smallFontSize),
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ export class UserProfileService {
auth,
).meUserProfileControllerFindUserProfile()
return {
email: userProfile.isRestricted ? undefined : userProfile.email,
email: userProfile.isRestricted
? undefined
: userProfile.email ?? undefined,
emailVerified: userProfile.isRestricted
? undefined
: userProfile.emailVerified,
phoneNumber: userProfile.isRestricted
? undefined
: userProfile.mobilePhoneNumber,
: userProfile.mobilePhoneNumber ?? undefined,
phoneNumberVerified: userProfile.isRestricted
? undefined
: userProfile.mobilePhoneNumberVerified,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const WORK_ENDING_HOUR = 23 // 11 PM
type HandleNotification = {
profile: {
nationalId: string
email?: string
email?: string | null
documentNotifications: boolean
emailNotifications: boolean
locale?: string
Expand Down
36 changes: 0 additions & 36 deletions apps/services/user-profile/infra/service-portal-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ import {
NationalRegistryB2C,
} from '../../../../infra/src/dsl/xroad'

// We basically don't want it to run in a cron job
// but manually, so set it to run once a year on dec 31st
const schedule = '0 0 31 12 *'

const namespace = 'service-portal'
const serviceId = `${namespace}-api`
const workerId = `${serviceId}-worker`
const imageId = 'services-user-profile'

const envVariables: EnvironmentVariables = {
Expand All @@ -36,11 +31,6 @@ const envVariables: EnvironmentVariables = {
staging: 'false',
prod: 'false',
},
USER_PROFILE_WORKER_PAGE_SIZE: {
dev: '3000',
staging: '3000',
prod: '3000',
},
AUTH_DELEGATION_API_URL: {
dev: 'http://web-services-auth-delegation-api.identity-server-delegation.svc.cluster.local',
staging:
Expand Down Expand Up @@ -68,32 +58,6 @@ const secrets: Secrets = {
'/k8s/api/NATIONAL_REGISTRY_B2C_CLIENT_SECRET',
}

export const workerSetup = (): ServiceBuilder<typeof workerId> =>
service(workerId)
.namespace(namespace)
.image(imageId)
.env(envVariables)
.secrets(secrets)
.files({ filename: 'islyklar.p12', env: 'ISLYKILL_CERT' })
.command('node')
.args('main.js', '--job=worker')
.resources({
limits: { cpu: '800m', memory: '1024Mi' },
requests: { cpu: '400m', memory: '512Mi' },
})
.db()
.extraAttributes({
dev: {
schedule,
},
staging: {
schedule,
},
prod: {
schedule,
},
})

export const serviceSetup = (): ServiceBuilder<typeof serviceId> =>
service(serviceId)
.namespace(namespace)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

module.exports = {
async up(queryInterface) {
return queryInterface.dropTable('user_profile_advania')
},

async down(queryInterface, Sequelize) {
/**
* This migration is cleaning up the migration table used when we migrated from the old user profile database.
*
* There is no down action as we cannot reinstate the data that was dropped along with the table.
*/
},
}
9 changes: 1 addition & 8 deletions apps/services/user-profile/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@
"buildTarget": "services-user-profile:build"
}
},
"worker": {
"executor": "@nx/js:node",
"options": {
"buildTarget": "services-user-profile:build",
"args": ["--job", "worker"]
}
},
"lint": {
"executor": "@nx/linter:eslint",
"options": {
Expand Down Expand Up @@ -98,7 +91,7 @@
"migrate/generate": {
"executor": "nx:run-commands",
"options": {
"command": "../../../node_modules/.bin/sequelize-cli migration:generate --name $(whoami)",
"command": "../../../node_modules/.bin/sequelize-cli migration:generate",
"cwd": "apps/services/user-profile/"
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IsNotEmpty, IsString } from 'class-validator'
import { ApiProperty } from '@nestjs/swagger'
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'

export class ConfirmEmailDto {
@IsNotEmpty()
@IsString()
@ApiProperty()
readonly hash!: string
@ApiPropertyOptional()
readonly hash?: string

@IsNotEmpty()
@IsString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IsNotEmpty, IsString } from 'class-validator'
import { ApiProperty } from '@nestjs/swagger'
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'

export class ConfirmSmsDto {
@IsNotEmpty()
@IsString()
@ApiProperty()
readonly code!: string
@ApiPropertyOptional()
readonly code?: string

@IsNotEmpty()
@IsString()
Expand Down
Loading
Loading