Skip to content

Commit

Permalink
fix(application-plc): Providers and minor amends (#15834)
Browse files Browse the repository at this point in the history
* feat(application-plc): Allow procuration holders

* Introduce candidacy and party ballot letter checks into providers

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and jonnigs committed Sep 2, 2024
1 parent cfb936c commit 6a0b460
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ export class ParliamentaryListCreationService extends BaseTemplateApiService {
}

async candidate({ auth }: TemplateApiModuleActionProps) {
const candidate = this.signatureCollectionClientService.getSignee(auth)
const candidate = await this.signatureCollectionClientService.getSignee(
auth,
)

if (!candidate.hasPartyBallotLetter) {
throw new TemplateApiError(errorMessages.partyBallotLetter, 405)
}

return candidate
}

async parliamentaryCollection() {
async parliamentaryCollection({ auth }: TemplateApiModuleActionProps) {
const currentCollection =
await this.signatureCollectionClientService.currentCollection()
if (currentCollection.collectionType !== CollectionType.Parliamentary) {
Expand All @@ -41,6 +48,15 @@ export class ParliamentaryListCreationService extends BaseTemplateApiService {
405,
)
}

const candidateInCollection = currentCollection.candidates.some(
(candidate) => candidate.nationalId === auth.nationalId,
)

if (!candidateInCollection) {
throw new TemplateApiError(errorMessages.partyBallotLetter, 405)
}

return currentCollection
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { m } from './messages'
import { EphemeralStateLifeCycle } from '@island.is/application/core'
import { Features } from '@island.is/feature-flags'
import { ParliamentaryCollectionApi, CandidateApi } from '../dataProviders'
import { AuthDelegationType } from '@island.is/shared/types'

const WeekLifeCycle: StateLifeCycle = {
shouldBeListed: false,
Expand All @@ -39,6 +40,11 @@ const createListTemplate: ApplicationTemplate<
ApplicationConfigurations[ApplicationTypes.PARLIAMENTARY_LIST_CREATION]
.translation,
],
allowedDelegations: [
{
type: AuthDelegationType.ProcurationHolder,
},
],
stateMachineConfig: {
initial: States.PREREQUISITES,
states: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ export const errorMessages = {
description: '',
},
}),
partyBallotLetter: defineMessages({
title: {
id: 'plc.application:error.partyBallotLetter.title',
defaultMessage: 'Ekki er hægt að stofna meðmælasöfnun',
description: '',
},
summary: {
id: 'plc.application:error.partyBallotLetter.summary',
defaultMessage:
'Innskráður notandi/fyrirtæki vantar framboð eða listabókstaf',
description: '',
},
}),
citizenship: defineMessages({
title: {
id: 'plc.application:error.citizenship.title',
Expand Down

0 comments on commit 6a0b460

Please sign in to comment.