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(application-plc): Providers and minor amends #15834

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
albinagu marked this conversation as resolved.
Show resolved Hide resolved

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
Loading