Skip to content

Commit

Permalink
Merge branch 'main' into fix/web-temporary-event-licence-boolean-check
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 21, 2024
2 parents f07d048 + b97aca7 commit b43bc46
Show file tree
Hide file tree
Showing 22 changed files with 430 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,19 +289,19 @@ const canPrisonAdminUserAccessCase = (
) {
return false
}
}

// Check defendant verdict appeal deadline access
const canAppealVerdict = true
const verdictInfo = (theCase.defendants || []).map<
[boolean, Date | undefined]
>((defendant) => [canAppealVerdict, defendant.verdictViewDate])
// Check defendant verdict appeal deadline access
const canAppealVerdict = true
const verdictInfo = (theCase.defendants || []).map<
[boolean, Date | undefined]
>((defendant) => [canAppealVerdict, defendant.verdictViewDate])

const [_, indictmentVerdictAppealDeadlineExpired] =
getIndictmentVerdictAppealDeadlineStatus(verdictInfo)
const [_, indictmentVerdictAppealDeadlineExpired] =
getIndictmentVerdictAppealDeadlineStatus(verdictInfo)

if (!indictmentVerdictAppealDeadlineExpired) {
return false
if (!indictmentVerdictAppealDeadlineExpired) {
return false
}
}

return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
SignatureCollectionSignedList,
SignatureCollectionSignee,
} from './models'
import { SignatureCollectionListSummary } from './models/areaSummaryReport.model'

@UseGuards(IdsUserGuard, ScopesGuard, UserAccessGuard)
@Resolver()
Expand Down Expand Up @@ -207,4 +208,16 @@ export class SignatureCollectionResolver {
signee.candidate?.id,
)
}

@Scopes(ApiScope.signatureCollection)
@IsOwner()
@AllowManager()
@Query(() => SignatureCollectionListSummary)
@Audit()
async signatureCollectionListOverview(
@CurrentUser() user: User,
@Args('input') input: SignatureCollectionListIdInput,
): Promise<SignatureCollectionListSummary> {
return this.signatureCollectionService.listOverview(user, input.listId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { SignatureCollectionAddListsInput } from './dto/addLists.input'
import { SignatureCollectionUploadPaperSignatureInput } from './dto/uploadPaperSignature.input'
import { SignatureCollectionCanSignFromPaperInput } from './dto/canSignFromPaper.input'
import { SignatureCollectionCollector } from './models/collector.model'
import { SignatureCollectionListSummary } from './models/areaSummaryReport.model'

@Injectable()
export class SignatureCollectionService {
Expand Down Expand Up @@ -187,4 +188,14 @@ export class SignatureCollectionService {
candidateId,
)
}

async listOverview(
user: User,
listId: string,
): Promise<SignatureCollectionListSummary> {
return await this.signatureCollectionClientService.getListOverview(
user,
listId,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Module } from '@nestjs/common'
import { SharedTemplateAPIModule } from '../../shared'
import { EuropeanHealthInsuranceCardService } from './european-health-insurance-card.service'
import { EhicClientModule } from '@island.is/clients/ehic-client-v1'
import { RightsPortalClientModule } from '@island.is/clients/icelandic-health-insurance/rights-portal'

@Module({
imports: [EhicClientModule, SharedTemplateAPIModule],
imports: [SharedTemplateAPIModule, RightsPortalClientModule],
providers: [EuropeanHealthInsuranceCardService],
exports: [EuropeanHealthInsuranceCardService],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Inject, Injectable } from '@nestjs/common'
import { EhicApi } from '@island.is/clients/ehic-client-v1'
import { LOGGER_PROVIDER } from '@island.is/logging'
import type { Logger } from '@island.is/logging'
import {
Expand All @@ -18,7 +17,7 @@ import {
} from './types'
import { TemplateApiModuleActionProps } from '../../../types'
import { Auth, AuthMiddleware } from '@island.is/auth-nest-tools'

import { EhicApi } from '@island.is/clients/icelandic-health-insurance/rights-portal'
@Injectable()
export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService {
constructor(
Expand All @@ -29,6 +28,10 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService {
super(ApplicationTypes.EUROPEAN_HEALTH_INSURANCE_CARD)
}

private ehicApiWithAuth(auth: Auth) {
return this.ehicApi.withMiddleware(new AuthMiddleware(auth))
}

/** Returns unique values of an array */
onlyUnique(value: string, index: number, array: string[]) {
return array.indexOf(value) === index
Expand Down Expand Up @@ -149,11 +152,9 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService {
const nridArr = this.getApplicants(application)
if (nridArr?.length > 0) {
try {
const resp = await this.ehicApi
.withMiddleware(new AuthMiddleware(auth as Auth))
.cardStatus({
applicantnationalids: this.toCommaDelimitedList(nridArr),
})
const resp = await this.ehicApiWithAuth(auth).getEhicCardStatus({
applicantnationalids: this.toCommaDelimitedList(nridArr),
})

if (!resp) {
this.logger.error(
Expand Down Expand Up @@ -188,12 +189,10 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService {

for (let i = 0; i < applicants?.length; i++) {
try {
const res = await this.ehicApi
.withMiddleware(new AuthMiddleware(auth as Auth))
.requestCard({
applicantnationalid: applicants[i],
cardtype: CardType.PLASTIC,
})
const res = await this.ehicApiWithAuth(auth).requestEhicCard({
applicantnationalid: applicants[i],
cardtype: CardType.PLASTIC,
})
cardResponses.push(res)
} catch (error) {
this.logger.error('EHIC.API error applyForPhysicalCard', error)
Expand All @@ -214,12 +213,10 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService {

for (let i = 0; i < applicants?.length; i++) {
try {
await this.ehicApi
.withMiddleware(new AuthMiddleware(auth as Auth))
.requestCard({
applicantnationalid: applicants[i],
cardtype: CardType.PDF,
})
await this.ehicApiWithAuth(auth).requestEhicCard({
applicantnationalid: applicants[i],
cardtype: CardType.PDF,
})
} catch (error) {
this.logger.error('EHIC.API error applyForTemporaryCard', error)
throw error
Expand All @@ -233,12 +230,14 @@ export class EuropeanHealthInsuranceCardService extends BaseTemplateApiService {

for (let i = 0; i < applicants?.length; i++) {
try {
const res = await this.ehicApi
.withMiddleware(new AuthMiddleware(auth as Auth))
.fetchTempPDFCard({
applicantnationalid: applicants[i].nationalId ?? '',
cardnumber: applicants[i].cardNumber ?? '',
})
const { nationalId, cardNumber } = applicants[i]
if (!nationalId || !cardNumber) {
throw new Error('National ID or card number is missing')
}
const res = await this.ehicApiWithAuth(auth).fetchTempEhicPDFCard({
applicantnationalid: nationalId,
cardnumber: cardNumber,
})
pdfArray.push(res)
} catch (error) {
this.logger.error('EHIC.API error getTemporaryCard', error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ const OldAgePensionTemplate: ApplicationTemplate<
},
pendingAction: {
title: coreSIAStatesMessages.tryggingastofnunSubmittedTitle,
content: coreSIAStatesMessages.tryggingastofnunSubmittedContent,
displayStatus: 'info',
content: statesMessages.oldAgePensionSubmittedContent,
displayStatus: 'warning',
},
historyLogs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,4 +516,11 @@ export const statesMessages = defineMessages({
defaultMessage: 'Umsókn vegna ellilífeyris hefur verið samþykkt',
description: 'The application for old-age pension has been approved',
},
oldAgePensionSubmittedContent: {
id: 'oap.application:oldAgePensionSubmittedContent#markdown',
defaultMessage:
'Umsókn þín er í bið eftir yfirferð. Hægt er að breyta umsókn þar til hún er tekin til yfirferðar. Athugið að ef ekki er búið að skila inn tekjuáætlun þarf að gera það hér.',
description:
'Your application is awaiting review. It is possible to edit the application until it is under review. Please note that if you have not submitted an income plan, you must do so here.',
},
})
35 changes: 35 additions & 0 deletions libs/clients/signature-collection/src/clientConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,41 @@
}
}
},
"/Medmaelalistar/{ID}/Info": {
"get": {
"tags": ["Medmaelalistar"],
"summary": "Skilar yfirliti fyrir ákveðinn meðmælalista",
"description": "Framboð geta sótt yfirlit fyrir sína eigin lista",
"parameters": [
{
"name": "ID",
"in": "path",
"description": "ID meðmælalista",
"required": true,
"schema": { "type": "integer", "format": "int32" }
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MedmaelalistiExtendedDTO"
}
}
}
},
"204": { "description": "No Content" },
"400": {
"description": "Bad Request",
"content": {
"application/json": { "schema": { "type": "string" } }
}
}
}
}
},
"/Medmaelalistar/{ID}/Medmaeli": {
"get": {
"tags": ["Medmaelalistar"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { mapCandidate } from './types/candidate.dto'
import { Slug } from './types/slug.dto'
import { Auth, AuthMiddleware, User } from '@island.is/auth-nest-tools'
import { SignatureCollectionSharedClientService } from './signature-collection-shared.service'
import { ListSummary, mapListSummary } from './types/areaSummaryReport.dto'
type Api = MedmaelalistarApi | MedmaelasofnunApi | MedmaeliApi | FrambodApi

@Injectable()
Expand Down Expand Up @@ -561,4 +562,15 @@ export class SignatureCollectionClientService {
})) ?? []
)
}

async getListOverview(auth: User, listId: string): Promise<ListSummary> {
const summary = await this.getApiWithAuth(
this.listsApi,
auth,
).medmaelalistarIDInfoGet({
iD: parseInt(listId),
})

return mapListSummary(summary)
}
}
1 change: 1 addition & 0 deletions libs/nest/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './lib/decorators/nationalId.decorator'
export * from './lib/decorators/ParsedUserAgent.decorator'
export * from './lib/validators/isPersonNationalId.decorator'
export * from './lib/validators/isNationalId.decorator'
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { parseUserAgent } from './ParsedUserAgent.decorator'

describe('parseUserAgent Function', () => {
it('should parse new iOS app user agent', () => {
// Arrange
const userAgentString = 'IslandIsApp (1.0.0) Build/321 (ios/9.0.0)'

// Act
const result = parseUserAgent(userAgentString)

// Assert
expect(result).toEqual({
ua: userAgentString,
os: { name: 'iOS', version: '9.0.0' },
app: { name: 'IslandIsApp', version: '1.0.0', build: 321 },
})
})

it('should parse new Android app user agent', () => {
// Arrange
const userAgentString = 'IslandIsApp (2.1.0) Build/123 (android/11.0.0)'

// Act
const result = parseUserAgent(userAgentString)

// Assert
expect(result).toEqual({
ua: userAgentString,
os: { name: 'Android', version: '11.0.0' },
app: { name: 'IslandIsApp', version: '2.1.0', build: 123 },
})
})

it('should parse old iOS app user agent', () => {
// Arrange
const userAgentString = 'IslandApp/144 CFNetwork/1498.700.2 Darwin/23.6.0'

// Act
const result = parseUserAgent(userAgentString)

// Assert
expect(result).toEqual({
ua: userAgentString,
os: { name: 'iOS' },
app: { name: 'IslandIsApp' },
})
})

it('should parse old Android app user agent', () => {
// Arrange
const userAgentString = 'okhttp/4.9.2'

// Act
const result = parseUserAgent(userAgentString)

// Assert
expect(result).toEqual({
ua: userAgentString,
os: { name: 'Android' },
app: { name: 'IslandIsApp' },
})
})

it('should return empty app and os for unknown user agent', () => {
// Arrange
const userAgentString = 'UnknownUserAgent/1.0'

// Act
const result = parseUserAgent(userAgentString)

// Assert
expect(result).toEqual({
ua: userAgentString,
os: {},
app: {},
})
})
})
Loading

0 comments on commit b43bc46

Please sign in to comment.