Skip to content

Commit

Permalink
Merge branch 'main' into j-s/gendered-subpoena
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 16, 2024
2 parents 5fbe0df + f7773d8 commit c613301
Show file tree
Hide file tree
Showing 17 changed files with 664 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
PdfButton,
ProsecutorCaseInfo,
} from '@island.is/judicial-system-web/src/components'
import { CaseFileCategory } from '@island.is/judicial-system-web/src/graphql/schema'
import {
CaseFile as TCaseFile,
CaseFileCategory,
} from '@island.is/judicial-system-web/src/graphql/schema'

import { caseFile as m } from './CaseFile.strings'

Expand All @@ -25,12 +28,17 @@ const CaseFile = () => {
useContext(FormContext)

const caseFiles = useMemo(() => {
return (
workingCase.caseFiles?.filter(
(caseFile) => caseFile.category === CaseFileCategory.CASE_FILE_RECORD,
) ?? []
return new Map<string, TCaseFile[]>(
workingCase.policeCaseNumbers?.map((policeCaseNumber) => [
policeCaseNumber,
workingCase.caseFiles?.filter(
(caseFile) =>
caseFile.policeCaseNumber === policeCaseNumber &&
caseFile.category === CaseFileCategory.CASE_FILE_RECORD,
) ?? [],
]),
)
}, [workingCase.caseFiles])
}, [workingCase.caseFiles, workingCase.policeCaseNumbers])

const { formatMessage } = useIntl()
const [editCount, setEditCount] = useState<number>(0)
Expand Down Expand Up @@ -73,7 +81,7 @@ const CaseFile = () => {
caseId={workingCase.id}
policeCaseNumber={policeCaseNumber}
shouldStartExpanded={index === 0}
caseFiles={caseFiles}
caseFiles={caseFiles.get(policeCaseNumber) ?? []}
subtypes={workingCase.indictmentSubtypes}
crimeScenes={workingCase.crimeScenes}
setEditCount={setEditCount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,6 @@ export class SharedTemplateApiService {
return new Blob([file.Body as ArrayBuffer], { type: file.ContentType })
}

async getAttachmentUrl(key: string, expiration: number): Promise<string> {
if (expiration <= 0) {
return Promise.reject('expiration must be positive')
}

const bucket = this.config.templateApi.attachmentBucket

if (bucket == undefined) {
return Promise.reject('could not find s3 bucket')
}

return this.s3.getSignedUrlPromise('getObject', {
Bucket: bucket,
Key: key,
Expires: expiration,
})
}

async saveAttachmentToApplicaton(
application: ApplicationWithAttachments,
fileName: string,
Expand Down Expand Up @@ -333,4 +315,26 @@ export class SharedTemplateApiService {
)
return token
}

async getAttachmentUrl(
application: ApplicationWithAttachments,
attachmentKey: string,
expiration: number,
): Promise<string> {
if (expiration <= 0) {
return Promise.reject('expiration must be positive')
}
const fileName = (
application.attachments as {
[key: string]: string
}
)[attachmentKey]
const { bucket, key } = AmazonS3URI(fileName)

return this.s3.getSignedUrlPromise('getObject', {
Bucket: bucket,
Key: key,
Expires: expiration,
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,25 +286,34 @@ export class CitizenshipService extends BaseTemplateApiService {
auth,
{
selectedChildren:
answers.selectedChildrenExtraData?.map((c) => {
answers.selectedChildren?.map((y) => {
const childExtraInformation =
answers.selectedChildrenExtraData?.find((z) => z.nationalId === y)

if (!childExtraInformation) {
throw new Error('Vantar upplýsingar um börn')
}

const childrenCustodyInformation = application.externalData
.childrenCustodyInformation
.data as ApplicantChildCustodyInformation[]

const thisChild = childrenCustodyInformation.find(
(x) => x.nationalId === c.nationalId,
(x) => x.nationalId === childExtraInformation.nationalId,
)

return {
nationalId: c.nationalId,
otherParentNationalId: c.otherParentNationalId,
otherParentBirtDate: c.otherParentBirtDate
? new Date(c.otherParentBirtDate)
nationalId: childExtraInformation.nationalId,
otherParentNationalId:
childExtraInformation.otherParentNationalId,
otherParentBirtDate: childExtraInformation.otherParentBirtDate
? new Date(childExtraInformation.otherParentBirtDate)
: undefined,
otherParentName: c.otherParentName,
otherParentName: childExtraInformation.otherParentName,
citizenship: thisChild?.citizenship?.code || '',
}
}) || [],

isFormerIcelandicCitizen: answers.formerIcelander === YES,
givenName:
individual?.givenName ||
Expand Down Expand Up @@ -341,33 +350,33 @@ export class CitizenshipService extends BaseTemplateApiService {
passportNumber: applicantPassport.passportNumber,
passportTypeId: parseInt(applicantPassport.passportTypeId),
countryOfIssuerId: applicantPassport.countryOfIssuerId,
file: await this.getFilesFromAttachment(
file: await this.getUrlForAttachment(
application,
answers?.passport?.attachment,
),
},
supportingDocuments: {
birthCertificate: await this.getFilesFromAttachment(
birthCertificate: await this.getUrlForAttachment(
application,
answers?.supportingDocuments?.birthCertificate,
),
subsistenceCertificate: await this.getFilesFromAttachment(
subsistenceCertificate: await this.getUrlForAttachment(
application,
answers?.supportingDocuments?.subsistenceCertificate,
),
subsistenceCertificateForTown: await this.getFilesFromAttachment(
subsistenceCertificateForTown: await this.getUrlForAttachment(
application,
answers?.supportingDocuments?.subsistenceCertificateForTown,
),
certificateOfLegalResidenceHistory: await this.getFilesFromAttachment(
certificateOfLegalResidenceHistory: await this.getUrlForAttachment(
application,
answers?.supportingDocuments?.certificateOfLegalResidenceHistory,
),
icelandicTestCertificate: await this.getFilesFromAttachment(
icelandicTestCertificate: await this.getUrlForAttachment(
application,
answers?.supportingDocuments?.icelandicTestCertificate,
),
criminalRecord: await this.getFilesFromAttachment(
criminalRecord: await this.getUrlForAttachment(
application,
applicantCriminalRecordAttachments,
),
Expand All @@ -387,25 +396,25 @@ export class CitizenshipService extends BaseTemplateApiService {
passportNumber: p.passportNumber,
passportTypeId: parseInt(p.passportTypeId),
countryIdOfIssuer: p.countryOfIssuerId,
file: await this.getFilesFromAttachment(application, p.attachment),
file: await this.getUrlForAttachment(application, p.attachment),
})) || [],
),
childrenSupportingDocuments: await Promise.all(
answers.childrenSupportingDocuments?.map(async (d) => ({
nationalId: d.nationalId,
birthCertificate: await this.getFilesFromAttachment(
birthCertificate: await this.getUrlForAttachment(
application,
d.birthCertificate,
),
writtenConsentFromChild: await this.getFilesFromAttachment(
writtenConsentFromChild: await this.getUrlForAttachment(
application,
d.writtenConsentFromChild,
),
writtenConsentFromOtherParent: await this.getFilesFromAttachment(
writtenConsentFromOtherParent: await this.getUrlForAttachment(
application,
d.writtenConsentFromOtherParent,
),
custodyDocuments: await this.getFilesFromAttachment(
custodyDocuments: await this.getUrlForAttachment(
application,
d.custodyDocuments,
),
Expand All @@ -415,20 +424,20 @@ export class CitizenshipService extends BaseTemplateApiService {
)
}

private async getFilesFromAttachment(
private async getUrlForAttachment(
application: ApplicationWithAttachments,
attachments?: { name: string; key: string; countryId?: string }[],
): Promise<{ filename: string; base64: string; countryId: string }[]> {
): Promise<{ filename: string; fileUrl: string; countryId: string }[]> {
return await Promise.all(
attachments?.map(async (file) => {
const base64 =
await this.sharedTemplateAPIService.getAttachmentContentAsBase64(
application,
file.key,
)
const fileUrl = await this.sharedTemplateAPIService.getAttachmentUrl(
application,
file.key,
300000,
)
return {
filename: file.name,
base64,
fileUrl,
countryId: file.countryId || '',
}
}) || [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TemplateApiModuleActionProps } from '../../../types'
import { BaseTemplateApiService } from '../../base-template-api.service'
import {
ApplicationTypes,
ApplicationWithAttachments,
NationalRegistryIndividual,
} from '@island.is/application/types'

Expand Down Expand Up @@ -147,6 +148,7 @@ export class UniversityService extends BaseTemplateApiService {
educationOptionChosen === UniversityApplicationTypes.EXEMPTION
? {
degreeAttachments: await this.getAttachmentUrls(
application,
answers.educationDetails.exemptionDetails?.degreeAttachments?.map(
(x, i) => {
const type = this.mapFileTypes(i)
Expand Down Expand Up @@ -177,6 +179,7 @@ export class UniversityService extends BaseTemplateApiService {
moreDetails:
answers.educationDetails.thirdLevelDetails?.moreDetails,
degreeAttachments: await this.getAttachmentUrls(
application,
answers.educationDetails.thirdLevelDetails?.degreeAttachments?.map(
(x, i) => {
const type = this.mapFileTypes(i)
Expand All @@ -196,6 +199,7 @@ export class UniversityService extends BaseTemplateApiService {
return {
...item,
degreeAttachments: await this.getAttachmentUrls(
application,
item.degreeAttachments?.map((x, i) => {
const type = this.mapFileTypes(i)
return {
Expand Down Expand Up @@ -267,6 +271,7 @@ export class UniversityService extends BaseTemplateApiService {
}

private async getAttachmentUrls(
application: ApplicationWithAttachments,
attachments?: { name: string; key: string; type: string }[],
): Promise<{ fileName: string; fileType: string; url: string }[]> {
const expiry = 36000
Expand All @@ -277,6 +282,7 @@ export class UniversityService extends BaseTemplateApiService {
fileName: file.name,
fileType: file.type,
url: await this.sharedTemplateAPIService.getAttachmentUrl(
application,
file.key,
expiry,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const Prerequisites: Form = buildForm({
subTitle: externalData.dataProvider.subTitle,
description: externalData.dataProvider.description,
checkboxLabel: externalData.dataProvider.checkboxLabel,
enableMockPayment: true,
submitField: buildSubmitField({
id: 'submit',
placement: 'footer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DefaultEvents,
Form,
FormModes,
NationalRegistryUserApi,
UserProfileApi,
} from '@island.is/application/types'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export const m = defineMessages({
description: '',
},
listsOverviewHeader: {
id: 'plc.application:listOverviewHeader',
id: 'plc.application:listsOverviewHeader',
defaultMessage: 'Upplýsingar um meðmælalista',
description: '',
},
Expand Down Expand Up @@ -305,7 +305,7 @@ export const m = defineMessages({

/* Action Card logs */
logListCreated: {
id: 'plc.application:listCreated',
id: 'plc.application:logListCreated',
defaultMessage: 'Meðmælalisti stofnaður',
description: '',
},
Expand Down
Loading

0 comments on commit c613301

Please sign in to comment.