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(signature-collection): sign list without candidateid #16154

Merged
merged 8 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -1,8 +1,8 @@
import {
buildDescriptionField,
buildForm,
buildHiddenInput,
buildMultiField,
buildRadioField,
buildSection,
buildSubmitField,
buildTextField,
Expand All @@ -20,7 +20,7 @@ export const Draft: Form = buildForm({
title: '',
mode: FormModes.DRAFT,
renderLastScreenButton: true,
renderLastScreenBackButton: true,
renderLastScreenBackButton: false,
logo: Logo,
children: [
buildSection({
Expand All @@ -33,6 +33,60 @@ export const Draft: Form = buildForm({
title: m.dataCollection,
children: [],
}),
/* section used for testing purposes */
buildSection({
id: 'selectCandidateSection',
title: m.selectCandidate,
condition: (_, externalData) => {
const lists = getValueViaPath(
externalData,
'getList.data',
[],
) as SignatureCollectionList[]
return lists.length > 1
},
children: [
buildMultiField({
id: 'selectCandidateSection',
title: m.selectCandidate,
description: m.selectCandidateDescription,
children: [
buildRadioField({
id: 'listId',
title: '',
defaultValue: '',
required: true,
options: ({
externalData: {
getList: { data },
},
}) => {
return (data as SignatureCollectionList[]).map((list) => ({
value: list.id,
label: list.candidate.name,
disabled:
list.maxReached || new Date(list.endTime) < new Date(),
albinagu marked this conversation as resolved.
Show resolved Hide resolved
tag: list.maxReached
? {
label: m.selectCandidateMaxReached.defaultMessage,
variant: 'red',
outlined: true,
}
: new Date(list.endTime) < new Date()
? {
label: m.selectCandidateListExpired.defaultMessage,
variant: 'red',
outlined: true,
}
: undefined,
albinagu marked this conversation as resolved.
Show resolved Hide resolved
}))
},
}),
],
}),
],
}),
/* ------------------------------- */
buildSection({
id: 'signListInformationSection',
title: m.information,
Expand All @@ -47,24 +101,7 @@ export const Draft: Form = buildForm({
title: m.listHeader,
titleVariant: 'h3',
}),
buildHiddenInput({
id: 'listId',
defaultValue: ({ answers, externalData }: Application) => {
const lists = getValueViaPath(
externalData,
'getList.data',
[],
) as SignatureCollectionList[]

const initialQuery = getValueViaPath(
answers,
'initialQuery',
'',
)

return lists.find((x) => x.candidate.id === initialQuery)?.id
},
}),
buildTextField({
id: 'list.name',
title: m.listName,
Expand All @@ -83,7 +120,11 @@ export const Draft: Form = buildForm({
'',
)

return lists.find((x) => x.candidate.id === initialQuery)?.title
return lists.find((list) =>
initialQuery
? list.candidate.id === initialQuery
: list.id === answers.listId,
)?.candidate?.name
albinagu marked this conversation as resolved.
Show resolved Hide resolved
},
}),
buildTextField({
Expand All @@ -104,8 +145,11 @@ export const Draft: Form = buildForm({
'',
)

return lists.find((x) => x.candidate.id === initialQuery)
?.candidate?.partyBallotLetter
return lists.find((list) =>
initialQuery
? list.candidate.id === initialQuery
: list.id === answers.listId,
)?.candidate?.partyBallotLetter
},
}),
buildDescriptionField({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ export const Prerequisites: Form = buildForm({
title: '',
subTitle: '',
}),
buildDataProviderItem({
//provider: TODO: Add providers needed for signing collection,
title: '',
subTitle: '',
}),
],
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { z } from 'zod'
export const dataSchema = z.object({
/* Gagnaöflun */
approveExternalData: z.boolean().refine((v) => v),
listId: z.string().min(1),
list: z.object({
name: z.string(),
letter: z.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ export const m = defineMessages({
defaultMessage: 'Nafn',
description: '',
},
selectCandidate: {
id: 'pls.application:selectCandidate',
defaultMessage: 'Veldu frambjóðanda',
description: '',
},
selectCandidateDescription: {
id: 'pls.application:selectCandidateDescription',
defaultMessage: 'Frambjóðendur á þínu svæði sem hægt er að mæla með:',
description: '',
},
selectCandidateMaxReached: {
id: 'pls.application:selectCandidateMaxReached',
defaultMessage: 'Hámarki meðmæla náð',
description: '',
},
selectCandidateListExpired: {
id: 'pls.application:selectCandidateListExpired',
defaultMessage: 'Söfnuninni lokið',
description: '',
},
listName: {
id: 'pls.application:listName',
defaultMessage: 'Heiti framboðs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ import { dataSchema } from './dataSchema'
import { m } from './messages'
import { EphemeralStateLifeCycle } from '@island.is/application/core'
import { Features } from '@island.is/feature-flags'
import {
CanSignApi,
CurrentCollectionApi,
GetListApi,
OwnerRequirementsApi,
} from '../dataProviders'
import { CanSignApi, CurrentCollectionApi, GetListApi } from '../dataProviders'
albinagu marked this conversation as resolved.
Show resolved Hide resolved

const WeekLifeCycle: StateLifeCycle = {
shouldBeListed: false,
Expand Down
Loading