Skip to content

Commit

Permalink
Merge branch 'main' into feat/fix-delegation-from
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Sep 27, 2024
2 parents 10f5409 + 55d69bb commit a37c337
Show file tree
Hide file tree
Showing 43 changed files with 1,619 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const RecyclingCompanies: FC<React.PropsWithChildren<unknown>> = () => {

const handleUpdate = (id: string) => {
router.push({
pathname: BASE_PATH + routes.recyclingCompanies.edit, // without BASE-PATH it changes the whole route, probably some bug
pathname: routes.recyclingCompanies.edit, // with BASE-PATH it duplicates the path
query: { id },
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ const RecyclingCompanyUpdate: FC<React.PropsWithChildren<unknown>> = () => {
}

const handleUpdateRecyclingPartner = handleSubmit(async (input) => {
// Not needed to be sent to the backend, causes error if it is sent
delete input.__typename

const { errors } = await updateSkilavottordRecyclingPartner({
variables: { input },
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ export class HealthDirectorateResolver {
@Audit()
async updateDonorStatus(
@Args('input') input: DonorInput,
@Args('locale', { type: () => String, nullable: true })
locale: Locale = 'is',
@CurrentUser() user: User,
): Promise<void> {
return this.api.updateDonorStatus(user, input)
return this.api.updateDonorStatus(user, input, locale)
}

/* Vaccinations */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export class HealthDirectorateService {
const lang: organLocale = locale === 'is' ? organLocale.Is : organLocale.En
const data: OrganDonorDto | null =
await this.organDonationApi.getOrganDonation(auth, lang)
// Fetch organ list to get all names in correct language to sort out the names of the organs the user has limitations for

if (data === null) {
return null
}
Expand Down Expand Up @@ -58,11 +56,19 @@ export class HealthDirectorateService {
return limitations
}

async updateDonorStatus(auth: Auth, input: DonorInput): Promise<void> {
return await this.organDonationApi.updateOrganDonation(auth, {
isDonor: input.isDonor,
exceptions: input.organLimitations ?? [],
})
async updateDonorStatus(
auth: Auth,
input: DonorInput,
locale: Locale,
): Promise<void> {
return await this.organDonationApi.updateOrganDonation(
auth,
{
isDonor: input.isDonor,
exceptions: input.organLimitations ?? [],
},
locale === 'is' ? organLocale.Is : organLocale.En,
)
}

/* Vaccinations */
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { SetMetadata } from '@nestjs/common'
import { ALLOW_DELEGATION_KEY } from '../guards/constants'

export const AllowDelegation = () => SetMetadata(ALLOW_DELEGATION_KEY, true)
16 changes: 16 additions & 0 deletions libs/api/domains/signature-collection/src/lib/decorators/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { IsOwner } from './isOwner.decorator'
import { CurrentSignee, getCurrentSignee } from './signee.decorator'
import { AllowDelegation } from './allowDelegation.decorator'
import {
AllowManager,
RestrictGuarantor,
} from './parliamentaryUserTypes.decorator'

export {
AllowDelegation,
CurrentSignee,
IsOwner,
getCurrentSignee,
AllowManager,
RestrictGuarantor,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { SetMetadata } from '@nestjs/common'
import { IS_OWNER_KEY } from '../guards/constants'

export const IsOwner = () => SetMetadata(IS_OWNER_KEY, true)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { SetMetadata } from '@nestjs/common'
import {
ALLOW_DELEGATION_KEY,
RESTRICT_GUARANTOR_KEY,
} from '../guards/constants'
// ---------------
// ---Guarantor---
// ---------------
// A guarantor is a user in the signature collection system, aimed at parliamentary collections.
// A guarantor (is: Ábyrgðaraðili) defined by Þjóðskrá Íslands as one of the following :
// - A holder of procuration
// OR - A direct candidate in the party ballot

export const RestrictGuarantor = () => SetMetadata(RESTRICT_GUARANTOR_KEY, true)

// ---------------
// ----Manager----
// ---------------
// A manager is a user in the signature collection system, aimed at parliamentary collections.
// A manager (is: Umsjónaraðili) defined by Þjóðskrá Íslands as one of the following:
// - Individuals delegated to a company without having a procuration role
// OR - Individuals delegated to a person (possibly a list owner)

// This is the same as the allow_delegation rule so no new constants are needed
export const AllowManager = () => SetMetadata(ALLOW_DELEGATION_KEY, true)

// Assumptions: Guarantors have access to everything unless otherwise stated
// Managers have access to nothing unless otherwise stated
35 changes: 35 additions & 0 deletions libs/api/domains/signature-collection/src/lib/dto/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { SignatureCollectionAddListsInput } from './addLists.input'
import { SignatureCollectionAreaInput } from './area.input'
import {
BulkUploadUser,
SignatureCollectionListBulkUploadInput,
} from './bulkUpload.input'
import { SignatureCollectionCandidateIdInput } from './candidateId.input'
import { SignatureCollectionCancelListsInput } from './cencelLists.input'
import { SignatureCollectionIdInput } from './collectionId.input'
import { SignatureCollectionExtendDeadlineInput } from './extendDeadline.input'
import { SignatureCollectionListIdInput } from './listId.input'
import { SignatureCollectionNationalIdInput } from './nationalId.input'
import { SignatureCollectionOwnerInput } from './owner.input'
import { SignatureCollectionSignatureIdInput } from './signatureId.input'
import { SignatureCollectionListInput } from './singatureList.input'
import { SignatureCollectionUploadPaperSignatureInput } from './uploadPaperSignature.input'
import { SignatureCollectionCanSignFromPaperInput } from './canSignFromPaper.input'

export {
SignatureCollectionAddListsInput,
SignatureCollectionAreaInput,
SignatureCollectionListBulkUploadInput,
BulkUploadUser,
SignatureCollectionCandidateIdInput,
SignatureCollectionCancelListsInput,
SignatureCollectionIdInput,
SignatureCollectionExtendDeadlineInput,
SignatureCollectionListIdInput,
SignatureCollectionNationalIdInput,
SignatureCollectionOwnerInput,
SignatureCollectionSignatureIdInput,
SignatureCollectionListInput,
SignatureCollectionUploadPaperSignatureInput,
SignatureCollectionCanSignFromPaperInput,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IsNumber } from 'class-validator'
import { Field, InputType } from '@nestjs/graphql'
import { SignatureCollectionSignatureIdInput } from './signatureId.input'

@InputType()
export class SignatureCollectionSignatureUpdateInput extends SignatureCollectionSignatureIdInput {
@Field()
@IsNumber()
pageNumber!: number
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const IS_OWNER_KEY = 'is-owner'
export const ALLOW_DELEGATION_KEY = 'allow-delegation'
export const RESTRICT_GUARANTOR_KEY = 'restrict-guarantor'
Loading

0 comments on commit a37c337

Please sign in to comment.