From ddfcc0b2d1ab4893426b7b8c54569d43d6604c0d Mon Sep 17 00:00:00 2001 From: albina Date: Tue, 22 Oct 2024 10:25:53 +0000 Subject: [PATCH 1/5] fix(admin): sc collection statuses --- .../Constituency/index.tsx | 22 ++++-- .../src/screens-parliamentary/List/index.tsx | 7 +- .../src/screens-parliamentary/index.tsx | 78 +++++++++++-------- .../screens-presidential/AllLists/index.tsx | 2 +- .../finishCollectionProcess.graphql | 0 .../completeCollectionProcessing/index.tsx | 2 +- 6 files changed, 66 insertions(+), 45 deletions(-) rename libs/portals/admin/signature-collection/src/{screens-presidential/AllLists/components => shared-components}/completeCollectionProcessing/finishCollectionProcess.graphql (100%) rename libs/portals/admin/signature-collection/src/{screens-presidential/AllLists/components => shared-components}/completeCollectionProcessing/index.tsx (98%) diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx index c58fa93adda5..15582fc57fbb 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx @@ -30,7 +30,10 @@ import electionsCommitteeLogo from '../../../assets/electionsCommittee.svg' import nationalRegistryLogo from '../../../assets/nationalRegistry.svg' import { useSignatureCollectionAdminRemoveListMutation } from './removeList.generated' import { useSignatureCollectionAdminRemoveCandidateMutation } from './removeCandidate.generated' -import { SignatureCollectionList } from '@island.is/api/schema' +import { + CollectionStatus, + SignatureCollectionList, +} from '@island.is/api/schema' export const Constituency = ({ allowedToProcess, @@ -41,7 +44,8 @@ export const Constituency = ({ const navigate = useNavigate() const { revalidate } = useRevalidator() - const { collection, allLists } = useLoaderData() as ListsLoaderReturn + const { collection, collectionStatus, allLists } = + useLoaderData() as ListsLoaderReturn const { constituencyName } = useParams() as { constituencyName: string } const constituencyLists = allLists.filter( @@ -127,12 +131,14 @@ export const Constituency = ({ ': ' + constituencyLists.length} - {allowedToProcess && constituencyLists?.length > 0 && ( - - )} + {constituencyLists?.length > 0 && + allowedToProcess && + collectionStatus === CollectionStatus.InInitialReview && ( + + )} {constituencyLists.map((list) => ( diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx index 109d19479753..4dc51fd43cd9 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx @@ -87,7 +87,12 @@ const List = ({ allowedToProcess }: { allowedToProcess: boolean }) => { ? formatMessage(m.listStatusReviewedStatusAlert) : formatMessage(m.listStatusActiveAlert) } - type={listStatus === ListStatus.Reviewed ? 'success' : undefined} + type={ + listStatus === ListStatus.Reviewed || + listStatus === ListStatus.Inactive + ? 'success' + : undefined + } /> ))} - {collection?.areas.map((area) => ( - l.area.name === area.name).length - } - heading={area.name} - cta={{ - label: formatMessage(m.viewConstituency), - variant: 'text', - onClick: () => { - navigate( - SignatureCollectionPaths.ParliamentaryConstituency.replace( - ':constituencyName', - area.name, - ), - ) - }, - }} - tag={ - allLists - .filter((l) => l.area.name === area.name) - .every((l) => l.reviewed === true) - ? { - label: formatMessage(m.confirmListReviewed), - variant: 'mint', - outlined: true, - } - : undefined - } - /> - ))} + {collection?.areas.map((area) => { + const areaLists = allLists.filter( + (l) => l.area.name === area.name, + ) + return ( + { + navigate( + SignatureCollectionPaths.ParliamentaryConstituency.replace( + ':constituencyName', + area.name, + ), + ) + }, + }} + tag={ + areaLists.length > 0 && + areaLists.every((l) => l.reviewed === true) + ? { + label: formatMessage(m.confirmListReviewed), + variant: 'mint', + outlined: true, + } + : undefined + } + /> + ) + })} {allowedToProcess && } + {collectionStatus === CollectionStatus.InInitialReview && ( + + )} diff --git a/libs/portals/admin/signature-collection/src/screens-presidential/AllLists/index.tsx b/libs/portals/admin/signature-collection/src/screens-presidential/AllLists/index.tsx index 956d4bcb0743..294770affbaf 100644 --- a/libs/portals/admin/signature-collection/src/screens-presidential/AllLists/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-presidential/AllLists/index.tsx @@ -29,13 +29,13 @@ import { import { format as formatNationalId } from 'kennitala' import electionsCommitteeLogo from '../../../assets/electionsCommittee.svg' import nationalRegistryLogo from '../../../assets/nationalRegistry.svg' -import ActionCompleteCollectionProcessing from './components/completeCollectionProcessing' import ListInfo from '../../shared-components/listInfoAlert' import EmptyState from '../../shared-components/emptyState' import ReviewCandidates from './components/reviewCandidates' import CompareLists from '../../shared-components/compareLists' import { ListsLoaderReturn } from '../../loaders/AllLists.loader' import CreateCollection from '../../shared-components/createCollection' +import ActionCompleteCollectionProcessing from '../../shared-components/completeCollectionProcessing' const Lists = ({ allowedToProcess }: { allowedToProcess: boolean }) => { const { formatMessage } = useLocale() diff --git a/libs/portals/admin/signature-collection/src/screens-presidential/AllLists/components/completeCollectionProcessing/finishCollectionProcess.graphql b/libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/finishCollectionProcess.graphql similarity index 100% rename from libs/portals/admin/signature-collection/src/screens-presidential/AllLists/components/completeCollectionProcessing/finishCollectionProcess.graphql rename to libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/finishCollectionProcess.graphql diff --git a/libs/portals/admin/signature-collection/src/screens-presidential/AllLists/components/completeCollectionProcessing/index.tsx b/libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/index.tsx similarity index 98% rename from libs/portals/admin/signature-collection/src/screens-presidential/AllLists/components/completeCollectionProcessing/index.tsx rename to libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/index.tsx index 9d20f821e91e..6a6290e0f44b 100644 --- a/libs/portals/admin/signature-collection/src/screens-presidential/AllLists/components/completeCollectionProcessing/index.tsx +++ b/libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/index.tsx @@ -1,6 +1,6 @@ import { useLocale } from '@island.is/localization' import { Box, Button, Text, toast } from '@island.is/island-ui/core' -import { m } from '../../../../lib/messages' +import { m } from '../../lib/messages' import { useState } from 'react' import { Modal } from '@island.is/react/components' import { useRevalidator } from 'react-router-dom' From e26b7544b55f378b724d3ae27a93e7091418bac6 Mon Sep 17 00:00:00 2001 From: albina Date: Tue, 22 Oct 2024 11:59:19 +0000 Subject: [PATCH 2/5] finishups --- .../signature-collection/src/lib/messages.ts | 21 +++++++++++ .../Constituency/index.tsx | 18 +++++----- .../src/screens-parliamentary/List/index.tsx | 4 ++- .../List/paperSignees/index.tsx | 3 ++ .../src/screens-parliamentary/index.tsx | 35 +++++++++++++++++-- .../completeCollectionProcessing/index.tsx | 3 ++ 6 files changed, 71 insertions(+), 13 deletions(-) diff --git a/libs/portals/admin/signature-collection/src/lib/messages.ts b/libs/portals/admin/signature-collection/src/lib/messages.ts index a90cbdaccbb1..04147e17217e 100644 --- a/libs/portals/admin/signature-collection/src/lib/messages.ts +++ b/libs/portals/admin/signature-collection/src/lib/messages.ts @@ -442,6 +442,27 @@ export const m = defineMessages({ defaultMessage: 'Opna fyrir úrvinnslu', description: '', }, + collectionReviewedTitle: { + id: 'admin-portal.signature-collection:collectionReviewedTitle', + defaultMessage: 'Meðmælasöfnun vegna framboðs til Alþingis lokið', + description: '', + }, + collectionReviewedMessage: { + id: 'admin-portal.signature-collection:collectionReviewedMessage', + defaultMessage: + 'Nú hefur úrvinnslu verið lokið á öllum listum í öllum kjördæmum.', + description: '', + }, + collectionProcessedTitle: { + id: 'admin-portal.signature-collection:collectionProcessedTitle', + defaultMessage: 'Úrvinnsla meðmælasöfnunar lokið', + description: '', + }, + collectionProcessedMessage: { + id: 'admin-portal.signature-collection:collectionReviewedTitle', + defaultMessage: 'Nú er hægt að framlengja stökum listum.', + description: '', + }, listReviewedModalDescription: { id: 'admin-portal.signature-collection:listReviewedModalDescription#markdown', defaultMessage: diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx index 15582fc57fbb..c0ddcfdf8772 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/Constituency/index.tsx @@ -131,14 +131,12 @@ export const Constituency = ({ ': ' + constituencyLists.length} - {constituencyLists?.length > 0 && - allowedToProcess && - collectionStatus === CollectionStatus.InInitialReview && ( - - )} + {allowedToProcess && ( + + )} {constituencyLists.map((list) => ( @@ -164,7 +162,9 @@ export const Constituency = ({ }, }} tag={ - allowedToProcess && list.active + allowedToProcess && + list.active && + collectionStatus === CollectionStatus.InitialActive ? { label: 'Cancel collection', renderTag: () => ( diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx index 4dc51fd43cd9..49581f3a8171 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/List/index.tsx @@ -106,7 +106,9 @@ const List = ({ allowedToProcess }: { allowedToProcess: boolean }) => { )} {allowedToProcess && ( - {!list.active && } + {!list.active && !list.reviewed && ( + + )} )} diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/List/paperSignees/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/List/paperSignees/index.tsx index a156005bd07e..38d624aeec34 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/List/paperSignees/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/List/paperSignees/index.tsx @@ -20,10 +20,12 @@ import { useIdentityQuery, } from './identityAndCanSignLookup.generated' import { useSignatureCollectionAdminUploadPaperSignatureMutation } from './uploadPaperSignee.generated' +import { useRevalidator } from 'react-router-dom' export const PaperSignees = ({ listId }: { listId: string }) => { useNamespaces('sp.signatureCollection') const { formatMessage } = useLocale() + const { revalidate } = useRevalidator() const { control, reset } = useForm() const [nationalIdInput, setNationalIdInput] = useState('') @@ -76,6 +78,7 @@ export const PaperSignees = ({ listId }: { listId: string }) => { toast.error(formatMessage(m.paperSigneeError)) } reset() + revalidate() setNationalIdTypo(false) setName('') }, diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx index 0b7f2197ab34..8f5e994adfe2 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx @@ -9,6 +9,7 @@ import { Breadcrumbs, Table as T, Text, + AlertMessage, } from '@island.is/island-ui/core' import { useLocale } from '@island.is/localization' import { IntroHeader, PortalNavigation } from '@island.is/portals/core' @@ -220,9 +221,37 @@ const ParliamentaryRoot = ({ ) })} - {allowedToProcess && } - {collectionStatus === CollectionStatus.InInitialReview && ( - + {allowedToProcess && ( + + {collectionStatus !== CollectionStatus.InReview && ( + + )} + {(collectionStatus === CollectionStatus.InitialActive || + collectionStatus === CollectionStatus.InInitialReview) && ( + l.reviewed === true)} + /> + )} + + )} + {collectionStatus === CollectionStatus.Processed && ( + + + + )} + {collectionStatus === CollectionStatus.InReview && ( + + + )} diff --git a/libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/index.tsx b/libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/index.tsx index 6a6290e0f44b..4b281f23ac1c 100644 --- a/libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/index.tsx +++ b/libs/portals/admin/signature-collection/src/shared-components/completeCollectionProcessing/index.tsx @@ -8,8 +8,10 @@ import { useProcessCollectionMutation } from './finishCollectionProcess.generate const ActionCompleteCollectionProcessing = ({ collectionId, + canProcess, }: { collectionId: string + canProcess?: boolean }) => { const { formatMessage } = useLocale() const [modalSubmitReviewIsOpen, setModalSubmitReviewIsOpen] = useState(false) @@ -45,6 +47,7 @@ const ActionCompleteCollectionProcessing = ({ colorScheme="destructive" variant="text" onClick={() => setModalSubmitReviewIsOpen(true)} + disabled={!canProcess} > {formatMessage(m.completeCollectionProcessing)} From 711059eb03331a01d0152a8a0922313260e0bbf9 Mon Sep 17 00:00:00 2001 From: albina Date: Tue, 22 Oct 2024 12:40:50 +0000 Subject: [PATCH 3/5] tweak --- .../signature-collection/src/screens-parliamentary/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx index 8f5e994adfe2..72ac281091db 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx @@ -230,7 +230,7 @@ const ParliamentaryRoot = ({ collectionStatus === CollectionStatus.InInitialReview) && ( l.reviewed === true)} + canProcess={!!allLists.length && allLists.every((l) => l.reviewed === true)} /> )} From ddf3b4c43a243568c7cf792347a0616864898323 Mon Sep 17 00:00:00 2001 From: andes-it Date: Tue, 22 Oct 2024 12:45:11 +0000 Subject: [PATCH 4/5] chore: nx format:write update dirty files --- .../signature-collection/src/screens-parliamentary/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx index 72ac281091db..55beed7cbf74 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx @@ -230,7 +230,10 @@ const ParliamentaryRoot = ({ collectionStatus === CollectionStatus.InInitialReview) && ( l.reviewed === true)} + canProcess={ + !!allLists.length && + allLists.every((l) => l.reviewed === true) + } /> )} From f4d89a799440a5174346151461b52120aa281e80 Mon Sep 17 00:00:00 2001 From: albina Date: Tue, 22 Oct 2024 12:51:26 +0000 Subject: [PATCH 5/5] compare lists status tweak --- .../signature-collection/src/screens-parliamentary/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx b/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx index 72ac281091db..05eaba5669de 100644 --- a/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx +++ b/libs/portals/admin/signature-collection/src/screens-parliamentary/index.tsx @@ -223,7 +223,8 @@ const ParliamentaryRoot = ({ {allowedToProcess && ( - {collectionStatus !== CollectionStatus.InReview && ( + {(collectionStatus === CollectionStatus.InInitialReview || + collectionStatus === CollectionStatus.InReview) && ( )} {(collectionStatus === CollectionStatus.InitialActive ||