Skip to content

Commit

Permalink
fix(signature-collection): A litany of fixes (#16415)
Browse files Browse the repository at this point in the history
* fix(service-portal): company route signature collections (#16382)

* draft

* chore: nx format:write update dirty files

* fix: company path

* tweaks

* p

* view list company path

* chore: nx format:write update dirty files

* nav tweak

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: Ásdís Erna Guðmundsdóttir <[email protected]>

* fix(service-portal): sp list submitted (#16383)

* fix(service-portal): sp list submitted

* tweak

* chore: nx format:write update dirty files

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: andes-it <[email protected]>

* fix(portals-admin): adding report date (#16384)

* fix(portals-admin): adding report date

* chore: nx format:write update dirty files

* tweak

* tweak supervisors info

* chore: nx format:write update dirty files

* tweak

* message - company card

* tweak

* t

* t

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collection): tweaks 15.10 (#16402)

* tweaka

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collection): Tweaks for parliamentary collection (#16407)

* Tweaks for parliamentary collection

* revertt'

* Update libs/api/domains/signature-collection/src/lib/signatureCollection.service.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* managers should see other managers

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collection): Fix paper signatures for candidacy (#16411)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* fix(signature-collections): ongoing updates (#16409)

* tweaks

* tweak - create list

* copylink

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

---------

Co-authored-by: albinagu <[email protected]>
Co-authored-by: andes-it <[email protected]>
Co-authored-by: Ásdís Erna Guðmundsdóttir <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: juni-haukur <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
7 people authored Oct 16, 2024
1 parent 415c1e1 commit 4ed03ad
Show file tree
Hide file tree
Showing 26 changed files with 339 additions and 294 deletions.
2 changes: 2 additions & 0 deletions apps/service-portal/src/lib/masterNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { consentNavigation } from '@island.is/service-portal/consent'
import { ServicePortalPaths } from '@island.is/service-portal/core'
import { socialInsuranceMaintenanceNavigation } from '@island.is/service-portal/social-insurance-maintenance'
import { lawAndOrderNavigation } from '@island.is/service-portal/law-and-order'
import { companySignatureCollectionNavigation } from '@island.is/service-portal/signature-collection'

export const rootNavigationItem: PortalNavigationItem = {
name: m.overview,
Expand All @@ -47,6 +48,7 @@ export const MAIN_NAVIGATION: PortalNavigationItem = {
],
},
companyNavigation,
companySignatureCollectionNavigation,
informationNavigation,
socialInsuranceMaintenanceNavigation,
assetsNavigation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class SignatureCollectionResolver {

@Scopes(ApiScope.signatureCollection)
@Query(() => SignatureCollectionSuccess)
@AllowManager()
@Audit()
async signatureCollectionIsOwner(
@CurrentSignee() signee: SignatureCollectionSignee,
Expand Down Expand Up @@ -97,9 +98,10 @@ export class SignatureCollectionResolver {
@Audit()
async signatureCollectionList(
@CurrentUser() user: User,
@CurrentSignee() signee: SignatureCollectionSignee,
@Args('input') input: SignatureCollectionListIdInput,
): Promise<SignatureCollectionList> {
return this.signatureCollectionService.list(input.listId, user)
return this.signatureCollectionService.list(input.listId, user, signee)
}

@Scopes(ApiScope.signatureCollection)
Expand Down Expand Up @@ -140,8 +142,13 @@ export class SignatureCollectionResolver {
async signatureCollectionCanSignFromPaper(
@Args('input') input: SignatureCollectionCanSignFromPaperInput,
@CurrentUser() user: User,
@CurrentSignee() signee: SignatureCollectionSignee,
): Promise<boolean> {
return await this.signatureCollectionService.canSignFromPaper(user, input)
return await this.signatureCollectionService.canSignFromPaper(
user,
input,
signee,
)
}

@Scopes(ApiScope.signatureCollection)
Expand Down Expand Up @@ -192,6 +199,7 @@ export class SignatureCollectionResolver {

@Scopes(ApiScope.signatureCollection)
@IsOwner()
@AllowManager()
@Query(() => [SignatureCollectionCollector])
@Audit()
async signatureCollectionCollectors(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Injectable } from '@nestjs/common'
import {
Injectable,
NotFoundException,
UnauthorizedException,
} from '@nestjs/common'
import { SignatureCollectionSuccess } from './models/success.model'
import { SignatureCollection } from './models/collection.model'
import {
Expand Down Expand Up @@ -28,6 +32,12 @@ export class SignatureCollectionService {
private signatureCollectionClientService: SignatureCollectionClientService,
) {}

private checkListAccess(listId: string, signee: SignatureCollectionSignee) {
if (!signee.ownedLists?.some((list) => list.id === listId)) {
throw new NotFoundException('List not found')
}
}

async currentCollection(): Promise<SignatureCollection> {
return await this.signatureCollectionClientService.currentCollection()
}
Expand Down Expand Up @@ -82,7 +92,12 @@ export class SignatureCollectionService {
)
}

async list(listId: string, user: User): Promise<SignatureCollectionList> {
async list(
listId: string,
user: User,
signee: SignatureCollectionSignee,
): Promise<SignatureCollectionList> {
this.checkListAccess(listId, signee)
return await this.signatureCollectionClientService.getList(listId, user)
}

Expand Down Expand Up @@ -149,19 +164,22 @@ export class SignatureCollectionService {
async canSignFromPaper(
user: User,
input: SignatureCollectionCanSignFromPaperInput,
signee: SignatureCollectionSignee,
): Promise<boolean> {
const signee = await this.signatureCollectionClientService.getSignee(
user,
input.signeeNationalId,
)
const list = await this.list(input.listId, user)
const signatureSignee =
await this.signatureCollectionClientService.getSignee(
user,
input.signeeNationalId,
)
const list = await this.list(input.listId, user, signee)
// Current signatures should not prevent paper signatures
const canSign =
signee.canSign ||
(signee.canSignInfo?.length === 1 &&
signee.canSignInfo[0] === ReasonKey.AlreadySigned)
signatureSignee.canSign ||
(signatureSignee.canSignInfo?.length === 1 &&
(signatureSignee.canSignInfo[0] === ReasonKey.AlreadySigned ||
signatureSignee.canSignInfo[0] === ReasonKey.noInvalidSignature))

return canSign && list.area.id === signee.area?.id
return canSign && list.area.id === signatureSignee.area?.id
}

async collectors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { SignatureCollectionSignatureIdInput } from './dto/signatureId.input'
import { SignatureCollectionIdInput } from './dto/collectionId.input'
import { SignatureCollectionCandidateIdInput } from './dto/candidateId.input'
import { SignatureCollectionCanSignFromPaperInput } from './dto/canSignFromPaper.input'
import { CanSignInfo } from './models/canSignInfo.model'
import { SignatureCollectionSignatureUpdateInput } from './dto/signatureUpdate.input'
import { SignatureCollectionSignatureLookupInput } from './dto/signatureLookup.input'
import { SignatureCollectionAreaSummaryReportInput } from './dto/areaSummaryReport.input'
Expand All @@ -48,25 +47,17 @@ export class SignatureCollectionAdminResolver {
private signatureCollectionManagerService: SignatureCollectionManagerService,
) {}

@Query(() => CanSignInfo, { nullable: true })
@Scopes(
AdminPortalScope.signatureCollectionManage,
AdminPortalScope.signatureCollectionProcess,
)
@Query(() => SignatureCollectionSuccess)
async signatureCollectionAdminCanSignInfo(
@CurrentUser()
user: User,
@Args('input') input: SignatureCollectionCanSignFromPaperInput,
): Promise<CanSignInfo> {
const canSignInfo = await this.signatureCollectionService.getCanSignInfo(
): Promise<SignatureCollectionSuccess> {
return this.signatureCollectionService.getCanSignInfo(
user,
input.signeeNationalId,
input.listId,
)

return {
reasons: canSignInfo,
success: true,
}
}

@Query(() => SignatureCollection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,22 @@ export class SignatureCollectionAdminService {
async getCanSignInfo(
auth: User,
nationalId: string,
): Promise<ReasonKey[] | undefined> {
return (
listId: string,
): Promise<SignatureCollectionSuccess> {
const signatureSignee =
await this.signatureCollectionBasicService.getSignee(auth, nationalId)
).canSignInfo
const list = await this.list(listId, auth)
// Current signatures should not prevent paper signatures
const canSign =
signatureSignee.canSign ||
(signatureSignee.canSignInfo?.length === 1 &&
(signatureSignee.canSignInfo[0] === ReasonKey.AlreadySigned ||
signatureSignee.canSignInfo[0] === ReasonKey.noInvalidSignature))

return {
success: canSign && list.area.id === signatureSignee.area?.id,
reasons: canSign ? [] : signatureSignee.canSignInfo,
}
}

async signatures(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import { FC } from 'react'

export const CopyLink: FC<FieldBaseProps> = ({ application }) => {
const { formatMessage } = useLocale()
const { slug } = application.externalData.createLists.data as { slug: string }

return (
<Box>
<Text variant="h4" marginBottom={2}>
{formatMessage(m.shareList)}
</Text>
<Copy linkUrl={'TBD'} buttonTitle={formatMessage(m.copyLink)} />
<Copy
linkUrl={`${document.location.origin}${slug}`}
buttonTitle={formatMessage(m.copyLink)}
/>
</Box>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
buildPhoneField,
buildSection,
buildSubmitField,
buildTableRepeaterField,
buildTextField,
getValueViaPath,
} from '@island.is/application/core'
Expand All @@ -20,7 +19,6 @@ import Logo from '../../assets/Logo'

import { m } from '../lib/messages'
import { formatPhone } from '../lib/utils'
import { Manager, Supervisor } from '../lib/constants'
import { Collection } from '@island.is/clients/signature-collection'
import { Signee } from '@island.is/clients/signature-collection'

Expand Down Expand Up @@ -176,89 +174,6 @@ export const Draft: Form = buildForm({
}),
],
}),
/* Hiding this screen as for now
buildSection({
id: 'managers',
title: m.managersAndSupervisors,
children: [
buildMultiField({
id: 'managers',
title: m.managersAndSupervisorsTitle,
description: '',
children: [
buildTableRepeaterField({
id: 'managers',
title: m.managers,
description: m.managersDescription,
addItemButtonText: m.addManager,
marginTop: 0,
fields: {
manager: {
component: 'nationalIdWithName',
},
constituency: {
component: 'select',
label: m.constituency,
width: 'full',
options: [
{
value: m.allConstituencies.defaultMessage,
label: m.allConstituencies,
},
],
},
},
table: {
header: [m.nationalId, m.name, m.constituency],
rows: ['nationalId', 'name', 'constituency'],
format: {
nationalId: (v) => formatNationalId(v),
},
},
}),
buildTableRepeaterField({
id: 'supervisors',
title: m.supervisors,
description: m.supervisorsDescription,
addItemButtonText: m.addSupervisor,
marginTop: 5,
fields: {
supervisor: {
component: 'nationalIdWithName',
},
constituency: {
component: 'select',
label: m.constituency,
width: 'full',
isMulti: true,
options: (application) => {
return (
application.externalData.parliamentaryCollection
.data as Collection
)?.areas.map((area) => ({
value: `${area.id}|${area.name}`,
label: area.name,
}))
},
},
},
table: {
header: [m.nationalId, m.name, m.constituency],
rows: ['nationalId', 'name', 'constituency'],
format: {
nationalId: (v) => formatNationalId(v),
constituency: (v) => {
return (v as unknown as string[])
.map((e) => e.split('|')[1])
.join(', ')
},
},
},
}),
],
}),
],
}),*/
buildSection({
id: 'overview',
title: m.overview,
Expand Down Expand Up @@ -364,7 +279,10 @@ export const Draft: Form = buildForm({
title: '',
items: ({ answers }) => {
return (answers.constituency as string[]).map((c: string) => ({
heading: 'Flokkur 1 - ' + c.split('|')[1],
heading:
getValueViaPath(answers, 'list.name') +
' - ' +
c.split('|')[1],
progressMeter: {
currentProgress: 0,
maxProgress: 350,
Expand All @@ -373,68 +291,6 @@ export const Draft: Form = buildForm({
}))
},
}),
/*buildDescriptionField({
id: 'space4',
title: '',
space: 'gutter',
}),
buildDescriptionField({
id: 'managersHeader',
title: m.managers,
titleVariant: 'h3',
space: 'gutter',
marginBottom: 3,
condition: (answers) =>
!!(answers.managers as Array<Manager>)?.length,
}),
buildKeyValueField({
label: '',
width: 'full',
value: ({ answers }) => {
return (answers.managers as Array<Manager>)
.map(
(m: Manager) =>
m.manager.name +
' - ' +
formatNationalId(m.manager.nationalId) +
' - ' +
m.constituency,
)
.join('\n')
},
}),
buildDescriptionField({
id: 'space5',
title: '',
space: 'gutter',
}),
buildDescriptionField({
id: 'supervisorsHeader',
title: m.supervisors,
titleVariant: 'h3',
space: 'gutter',
marginBottom: 3,
condition: (answers) =>
!!(answers.supervisors as Array<Supervisor>)?.length,
}),
buildKeyValueField({
label: '',
width: 'full',
value: ({ answers }) => {
return (answers.supervisors as Array<Supervisor>)
.map(
(s: Supervisor) =>
s.supervisor.name +
' - ' +
formatNationalId(s.supervisor.nationalId) +
' - ' +
(s.constituency as unknown as string[])
.map((c) => c.split('|')[1])
.join(', '),
)
.join('\n')
},
}),*/
buildSubmitField({
id: 'submit',
placement: 'footer',
Expand Down
Loading

0 comments on commit 4ed03ad

Please sign in to comment.