diff --git a/libs/service-portal/signature-collection/src/hooks/graphql/mutations.ts b/libs/service-portal/signature-collection/src/hooks/graphql/mutations.ts index dd9bb068e793..8fb53c33cfb7 100644 --- a/libs/service-portal/signature-collection/src/hooks/graphql/mutations.ts +++ b/libs/service-portal/signature-collection/src/hooks/graphql/mutations.ts @@ -18,3 +18,24 @@ export const unSignList = gql` } } ` +export const addConstituency = gql` + mutation SignatureCollectionAddAreas( + $inputAdd: SignatureCollectionAddListsInput! + ) { + signatureCollectionAddAreas(input: $inputAdd) { + success + reasons + } + } +` + +export const uploadPaperSignature = gql` + mutation SignatureCollectionUploadPaperSignature( + $input: SignatureCollectionUploadPaperSignatureInput! + ) { + signatureCollectionUploadPaperSignature(input: $input) { + success + reasons + } + } +` diff --git a/libs/service-portal/signature-collection/src/hooks/graphql/queries.ts b/libs/service-portal/signature-collection/src/hooks/graphql/queries.ts index 55a7b6a24cb9..45d50fdbe81c 100644 --- a/libs/service-portal/signature-collection/src/hooks/graphql/queries.ts +++ b/libs/service-portal/signature-collection/src/hooks/graphql/queries.ts @@ -45,6 +45,7 @@ export const GetListSignatures = gql` isDigital valid created + pageNumber } } ` @@ -70,6 +71,7 @@ export const GetSignedList = gql` collectionId canUnsign slug + signedDate } } ` @@ -155,3 +157,9 @@ export const GetCurrentCollection = gql` } } ` + +export const GetCanSign = gql` + query Query($input: SignatureCollectionCanSignInput!) { + signatureCollectionCanSign(input: $input) + } +` diff --git a/libs/service-portal/signature-collection/src/hooks/index.ts b/libs/service-portal/signature-collection/src/hooks/index.ts index d8246c12763c..9c3800136b8e 100644 --- a/libs/service-portal/signature-collection/src/hooks/index.ts +++ b/libs/service-portal/signature-collection/src/hooks/index.ts @@ -7,6 +7,7 @@ import { GetSignedList, GetListsForOwner, GetCurrentCollection, + GetCanSign, } from './graphql/queries' import { SignatureCollectionListBase, @@ -147,3 +148,19 @@ export const useGetCurrentCollection = () => { refetchCurrentCollection, } } + +export const useGetCanSign = (signeeId: string, isValidId: boolean) => { + const { data: getCanSignData, loading: loadingCanSign } = useQuery( + GetCanSign, + { + variables: { + input: { + signeeNationalId: signeeId, + }, + }, + skip: !signeeId || signeeId.length !== 10 || !isValidId, + }, + ) + const canSign = getCanSignData?.signatureCollectionCanSign ?? false + return { canSign, loadingCanSign } +} diff --git a/libs/service-portal/signature-collection/src/lib/constants.ts b/libs/service-portal/signature-collection/src/lib/constants.ts index 04eb57fdee3a..8e28b87d3fe3 100644 --- a/libs/service-portal/signature-collection/src/lib/constants.ts +++ b/libs/service-portal/signature-collection/src/lib/constants.ts @@ -2,13 +2,3 @@ export const CollectionType = { Presidential: 'Forsetakosningar', Parliamentary: 'Alþingiskosningar', } - -// will be fetched later on -export const constituencies = [ - 'Norðvesturkjördæmi', - 'Norðausturkjördæmi', - 'Suðurkjördæmi', - 'Suðvesturkjördæmi', - 'Reykjavíkurkjördæmi suður', - 'Reykjavíkurkjördæmi norður', -] diff --git a/libs/service-portal/signature-collection/src/lib/messages.ts b/libs/service-portal/signature-collection/src/lib/messages.ts index 7cad88479236..0518d12283d8 100644 --- a/libs/service-portal/signature-collection/src/lib/messages.ts +++ b/libs/service-portal/signature-collection/src/lib/messages.ts @@ -51,7 +51,7 @@ export const m = defineMessages({ }, copyLinkDescription: { id: 'sp.signatureCollection:copyLinkDescription', - defaultMessage: 'Hér getur þú afritað hlekk á þitt framboð til að deila.', + defaultMessage: 'Hér getur þú afritað hlekk á þitt framboð til að deila', description: '', }, copyLinkSuccess: { @@ -99,6 +99,11 @@ export const m = defineMessages({ defaultMessage: 'Meðmæli lesin inn', description: '', }, + digitalSignature: { + id: 'sp.signatureCollection:digitalSignature', + defaultMessage: 'Skrifað undir: ', + description: '', + }, signatureIsInvalid: { id: 'sp.signatureCollection:signatureIsInvalid', defaultMessage: 'Ógilt meðmæli', @@ -181,7 +186,12 @@ export const m = defineMessages({ }, cancelCollectionModalConfirmButton: { id: 'sp.signatureCollection:modalConfirmButton', - defaultMessage: 'Já, hætta við söfnun meðmæla', + defaultMessage: 'Já, hætta við', + description: '', + }, + cancelCollectionModalCancelButton: { + id: 'sp.signatureCollection:cancelCollectionModalCancelButton', + defaultMessage: 'Nei, hætta við', description: '', }, cancelCollectionModalToastError: { @@ -256,6 +266,61 @@ export const m = defineMessages({ defaultMessage: 'Heimilisfang', description: '', }, + paperSigneesHeader: { + id: 'sp.signatureCollection:paperSigneesHeader', + defaultMessage: 'Skrá meðmæli af blaði', + description: '', + }, + paperSigneesClearButton: { + id: 'sp.signatureCollection:paperSigneesClearButton', + defaultMessage: 'Hreinsa', + description: '', + }, + paperNumber: { + id: 'sp.signatureCollection:paperNumber', + defaultMessage: 'Blaðsíðunúmer', + description: '', + }, + paperSigneeName: { + id: 'sp.signatureCollection:paperSigneeName', + defaultMessage: 'Nafn meðmælanda', + description: '', + }, + signPaperSigneeButton: { + id: 'sp.signatureCollection:signPaperSigneeButton', + defaultMessage: 'Skrá meðmæli á lista', + description: '', + }, + paperSigneeTypoTitle: { + id: 'sp.signatureCollection:paperSigneeTypoTitle', + defaultMessage: 'Kennitala ekki á réttu formi', + description: '', + }, + paperSigneeTypoMessage: { + id: 'sp.signatureCollection:paperSigneeTypoMessage', + defaultMessage: 'Vinsamlegast athugið kennitöluna og reynið aftur', + description: '', + }, + paperSigneeCantSignTitle: { + id: 'sp.signatureCollection:paperSigneeCantSignTitle', + defaultMessage: 'Ekki er hægt að skrá meðmæli', + description: '', + }, + paperSigneeCantSignMessage: { + id: 'sp.signatureCollection:paperSigneeCantSign', + defaultMessage: 'Kennitala uppfyllir ekki skilyrði fyrir að skrá meðmæli', + description: '', + }, + paperSigneeSuccess: { + id: 'sp.signatureCollection:paperSigneeSuccess', + defaultMessage: 'Meðmæli skráð', + description: '', + }, + paperSigneeError: { + id: 'sp.signatureCollection:paperSigneeError', + defaultMessage: 'Ekki tókst að skrá meðmæli', + description: '', + }, /* Parliamentary */ parliamentaryElectionsTitle: { @@ -279,16 +344,6 @@ export const m = defineMessages({ defaultMessage: 'Þjóðskrá Íslands hefur umsjón með gögnum um meðmælasöfnun.', }, - managers: { - id: 'sp.signatureCollection:managers', - defaultMessage: 'Ábyrgðaraðilar', - description: '', - }, - addManager: { - id: 'sp.signatureCollection:addManager', - defaultMessage: 'Bæta við ábyrgðaraðila', - description: '', - }, supervisors: { id: 'sp.signatureCollection:supervisors', defaultMessage: 'Umsjónaraðilar', @@ -299,11 +354,6 @@ export const m = defineMessages({ defaultMessage: 'Bæta við', description: '', }, - addSupervisor: { - id: 'sp.signatureCollection:addSupervisor', - defaultMessage: 'Bæta við umsjónaraðila', - description: '', - }, personName: { id: 'sp.signatureCollection:personName', defaultMessage: 'Nafn', @@ -340,31 +390,14 @@ export const m = defineMessages({ 'Veldu viðeigandi kjördæmi sem þú vilt stofna meðmælendasöfnun í.', description: '', }, - addConstituencyAlertInfo: { - id: 'sp.signatureCollection:addConstituencyAlertInfo', - defaultMessage: - 'Athugið að skrá þarf viðeigandi ábyrgðar-/umsjónaraðila á yfirlitssíðu fyrir ný kjördæmi.', - description: '', - }, - deleteManager: { - id: 'sp.signatureCollection:deleteManager', - defaultMessage: 'Eyða umsjónaraðila', - description: '', - }, - deleteManagerDescription: { - id: 'sp.signatureCollection:deleteManagerDescription', - defaultMessage: - 'Þú ert að fara að taka Nafna Nafnason af lista yfir umsjónaraðila. Ertu viss um að þú viljir halda áfram?', - description: '', - }, - delete: { - id: 'sp.signatureCollection:delete', - defaultMessage: 'Eyða', + addConstituencySuccess: { + id: 'sp.signatureCollection:addConstituencySuccess', + defaultMessage: 'Kjördæmi bætt við', description: '', }, - save: { - id: 'sp.signatureCollection:save', - defaultMessage: 'Vista', + addConstituencyError: { + id: 'sp.signatureCollection:addConstituencyError', + defaultMessage: 'Ekki tókst að bæta við kjördæmi', description: '', }, }) diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/AddConstituency/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/AddConstituency/index.tsx index 4820dcef6996..c6119aa3ed74 100644 --- a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/AddConstituency/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/AddConstituency/index.tsx @@ -1,26 +1,63 @@ import { useState } from 'react' -import { Box, Button, Text, Checkbox } from '@island.is/island-ui/core' +import { Box, Button, Text, Checkbox, toast } from '@island.is/island-ui/core' import { Modal } from '@island.is/service-portal/core' import { useLocale } from '@island.is/localization' import { m } from '../../../../lib/messages' -import { constituencies } from '../../../../lib/constants' -import { SignatureCollectionList } from '@island.is/api/schema' +import { + SignatureCollection, + SignatureCollectionArea, + SignatureCollectionList, +} from '@island.is/api/schema' +import { addConstituency } from '../../../../hooks/graphql/mutations' +import { useMutation } from '@apollo/client' const AddConstituencyModal = ({ lists, + collection, + candidateId, + refetch, }: { lists: SignatureCollectionList[] + collection: SignatureCollection + candidateId: string + refetch: () => void }) => { const { formatMessage } = useLocale() - const listTitles = lists.map((l) => l.title) - const filteredConstituencies = constituencies.filter( - (c) => !listTitles.some((title) => title.includes(c)), - ) + const currentConstituencies = lists.map( + (l) => l.area, + ) as SignatureCollectionArea[] + const filteredConstituencies = collection.areas.filter( + (cc) => !currentConstituencies.some((c) => cc.name === c.name), + ) as SignatureCollectionArea[] + const [modalIsOpen, setModalIsOpen] = useState(false) const [selectedConstituencies, setSelectedConstituencies] = useState< string[] >([]) + const [addNewConstituency, { loading }] = useMutation(addConstituency, { + onCompleted: () => { + setModalIsOpen(false) + refetch() + toast.success(formatMessage(m.addConstituencySuccess)) + }, + onError: () => { + toast.error(formatMessage(m.addConstituencyError)) + }, + }) + + const onAddConstituency = async () => { + addNewConstituency({ + variables: { + inputAdd: { + collectionId: collection?.id, + areaIds: selectedConstituencies, + candidateId: candidateId, + }, + }, + }) + } + return ( + diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/PaperSignees.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/PaperSignees.tsx new file mode 100644 index 000000000000..f101e7bd3d80 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/PaperSignees.tsx @@ -0,0 +1,188 @@ +import { + Box, + Text, + Button, + GridRow, + GridColumn, + GridContainer, + AlertMessage, + Input, +} from '@island.is/island-ui/core' +import { useLocale, useNamespaces } from '@island.is/localization' +import { useIdentityQuery } from '@island.is/service-portal/graphql' +import * as nationalId from 'kennitala' +import { useEffect, useState } from 'react' +import { InputController } from '@island.is/shared/form-fields' +import { useForm } from 'react-hook-form' +import { m } from '../../../../../lib/messages' +import { useGetCanSign } from '../../../../../hooks' +import { useMutation } from '@apollo/client' +import { uploadPaperSignature } from '../../../../../hooks/graphql/mutations' +import { toast } from 'react-toastify' + +export const PaperSignees = ({ + listId, + refetchSignees, +}: { + listId: string + refetchSignees: () => void +}) => { + useNamespaces('sp.signatureCollection') + const { formatMessage } = useLocale() + const { control, reset } = useForm() + + const [nationalIdInput, setNationalIdInput] = useState('') + const [nationalIdTypo, setNationalIdTypo] = useState(false) + const [page, setPage] = useState('') + const [name, setName] = useState('') + + /* identity & canSign fetching logic */ + const { data, loading } = useIdentityQuery({ + variables: { input: { nationalId: nationalIdInput } }, + skip: nationalIdInput.length !== 10 || !nationalId.isValid(nationalIdInput), + onCompleted: (data) => setName(data.identity?.name || ''), + }) + const { canSign, loadingCanSign } = useGetCanSign( + nationalIdInput, + nationalId.isValid(nationalIdInput), + ) + + useEffect(() => { + if (nationalIdInput.length === 10) { + setNationalIdTypo( + !nationalId.isValid(nationalIdInput) || + (!loading && !data?.identity?.name), + ) + } else { + setName('') + setNationalIdTypo(false) + } + }, [nationalIdInput, loading, data]) + + /* upload paper signature logic */ + const [upload, { loading: uploadingPaperSignature }] = useMutation( + uploadPaperSignature, + { + variables: { + input: { + listId: listId, + nationalId: nationalIdInput, + pageNumber: Number(page), + }, + }, + onCompleted: () => { + toast.success(formatMessage(m.paperSigneeSuccess)) + refetchSignees() + }, + onError: () => { + toast.error(formatMessage(m.paperSigneeError)) + }, + }, + ) + + const onClearForm = () => { + reset() // resets nationalId field + setNationalIdTypo(false) + setName('') + } + + return ( + + + + {formatMessage(m.paperSigneesHeader)} + + + + + + + + + + + { + setNationalIdInput(e.target.value.replace(/\W/g, '')) + }} + error={nationalIdTypo ? ' ' : undefined} + loading={loading || loadingCanSign} + icon={canSign ? 'checkmark' : undefined} + /> + + + setPage(e.target.value)} + /> + + + + + + + + + + + + + {nationalIdTypo && ( + + + + )} + {name && !loadingCanSign && !canSign && ( + + + + )} + + ) +} diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/index.tsx similarity index 69% rename from libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees.tsx rename to libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/index.tsx index 49031cc603aa..581ffb77b6be 100644 --- a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees.tsx +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees/index.tsx @@ -4,28 +4,28 @@ import { Table as T, Pagination, FilterInput, + Icon, } from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' -import { m } from '../../../../lib/messages' +import { m } from '../../../../../lib/messages' import format from 'date-fns/format' import { useEffect, useState } from 'react' -import { useGetListSignees } from '../../../../hooks' -import { useLocation } from 'react-router-dom' +import { useGetListSignees } from '../../../../../hooks' +import { useParams } from 'react-router-dom' import { format as formatNationalId } from 'kennitala' -import { SkeletonTable } from '../../../../skeletons' +import { SkeletonTable } from '../../../../../skeletons' import { SignatureCollectionSignature as Signature } from '@island.is/api/schema' +import { PaperSignees } from './PaperSignees' +import sortBy from 'lodash/sortBy' const Signees = () => { useNamespaces('sp.signatureCollection') const { formatMessage } = useLocale() - const { pathname } = useLocation() - const listId = pathname.replace( - '/min-gogn/listar/althingis-medmaelasofnun/', - '', - ) + const { id } = useParams() as { id: string } const [searchTerm, setSearchTerm] = useState('') - const { listSignees, loadingSignees } = useGetListSignees(listId) + const { listSignees, loadingSignees, refetchListSignees } = + useGetListSignees(id) const [signees, setSignees] = useState(listSignees) const [page, setPage] = useState(1) @@ -33,7 +33,11 @@ const Signees = () => { useEffect(() => { if (!loadingSignees && listSignees.length) { - setSignees(listSignees) + setSignees( + sortBy(listSignees, (item) => { + return item.created + }).reverse(), + ) } }, [listSignees]) @@ -56,30 +60,25 @@ const Signees = () => { return ( {formatMessage(m.signeesHeader)} - - - setSearchTerm(v)} - placeholder={formatMessage(m.searchInListPlaceholder)} - backgroundColor="white" - /> - + + setSearchTerm(v)} + placeholder={formatMessage(m.searchInListPlaceholder)} + backgroundColor="white" + /> {!loadingSignees ? ( signees.length > 0 ? ( - + {formatMessage(m.signeeDate)} {formatMessage(m.signeeName)} {formatMessage(m.signeeNationalId)} + @@ -88,7 +87,7 @@ const Signees = () => { .map((s: Signature) => { return ( - + {format(new Date(), 'dd.MM.yyyy')} @@ -97,13 +96,25 @@ const Signees = () => { {formatNationalId(s.signee.nationalId)} + + {!s.isDigital && ( + + + {s.pageNumber} + + )} + ) })} - + { ) : ( )} + ) } diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/index.tsx index b99c8b73b533..89bf289b13fb 100644 --- a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/index.tsx @@ -1,17 +1,15 @@ -import { Box, Button, Stack, Text, toast } from '@island.is/island-ui/core' +import { Box, Stack, Text } from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' import { m } from '../../../../lib/messages' import { useParams } from 'react-router-dom' import { useGetSignatureList } from '../../../../hooks' import format from 'date-fns/format' import Signees from './Signees' -import CancelCollection from '../../../shared/CancelCollection' -import copyToClipboard from 'copy-to-clipboard' const ViewList = () => { useNamespaces('sp.signatureCollection') const { formatMessage } = useLocale() - const { id } = useParams() + const { id } = useParams() as { id: string } const { listInfo, loadingList } = useGetSignatureList(id || '') return ( @@ -54,39 +52,7 @@ const ViewList = () => { )} - - - - {formatMessage(m.copyLinkDescription)} - - - - - - )} diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx index faa2ec4c2528..659882231e88 100644 --- a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx @@ -5,16 +5,27 @@ import { Text, Table as T, Tooltip, + DialogPrompt, + Tag, + Icon, + toast, + Button, } from '@island.is/island-ui/core' import { useNavigate } from 'react-router-dom' import { SignatureCollectionPaths } from '../../../lib/paths' import { useLocale } from '@island.is/localization' import { m } from '../../../lib/messages' import AddConstituency from './AddConstituency' -import { SignatureCollectionList } from '@island.is/api/schema' +import { + SignatureCollectionList, + SignatureCollectionSuccess, +} from '@island.is/api/schema' import { OwnerParliamentarySkeleton } from '../../../skeletons' import { useGetListsForOwner } from '../../../hooks' import { SignatureCollection } from '@island.is/api/schema' +import { useMutation } from '@apollo/client' +import { cancelCollectionMutation } from '../../../hooks/graphql/mutations' +import copyToClipboard from 'copy-to-clipboard' const OwnerView = ({ currentCollection, @@ -23,10 +34,33 @@ const OwnerView = ({ }) => { const navigate = useNavigate() const { formatMessage } = useLocale() - const { listsForOwner, loadingOwnerLists } = useGetListsForOwner( - currentCollection?.id || '', + const { listsForOwner, loadingOwnerLists, refetchListsForOwner } = + useGetListsForOwner(currentCollection?.id || '') + + const [cancelCollection] = useMutation( + cancelCollectionMutation, + { + onCompleted: () => { + toast.success(formatMessage(m.cancelCollectionModalToastSuccess)) + refetchListsForOwner() + }, + onError: () => { + toast.error(formatMessage(m.cancelCollectionModalToastError)) + }, + }, ) + const onCancelCollection = (listId: string) => { + cancelCollection({ + variables: { + input: { + collectionId: currentCollection?.id ?? '', + listIds: listId, + }, + }, + }) + } + return ( @@ -39,11 +73,15 @@ const OwnerView = ({ color="blue400" /> - {/* If the number of lists is equal to 6, it means that - lists have been created in all of the constituencies */} - {listsForOwner.length < 6 && ( - - )} + {!loadingOwnerLists && + listsForOwner?.length < currentCollection?.areas.length && ( + + )} {loadingOwnerLists ? ( @@ -54,12 +92,13 @@ const OwnerView = ({ ( + + + + + + } + onConfirm={() => { + onCancelCollection(list.id) + }} + buttonTextConfirm={formatMessage( + m.cancelCollectionModalConfirmButton, + )} + buttonPropsConfirm={{ + variant: 'primary', + colorScheme: 'destructive', + }} + buttonTextCancel={formatMessage( + m.cancelCollectionModalCancelButton, + )} + /> + ), + }} /> )) @@ -110,6 +186,36 @@ const OwnerView = ({ + + + {formatMessage(m.copyLinkDescription)} + + + + + ) } diff --git a/libs/service-portal/signature-collection/src/screens/shared/CancelCollection/index.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/CancelCollection/index.tsx similarity index 83% rename from libs/service-portal/signature-collection/src/screens/shared/CancelCollection/index.tsx rename to libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/CancelCollection/index.tsx index 08b0cc27a325..8e11940926fd 100644 --- a/libs/service-portal/signature-collection/src/screens/shared/CancelCollection/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/CancelCollection/index.tsx @@ -1,31 +1,23 @@ import { Box, Button, Text, toast } from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' -import { m } from '../../../lib/messages' +import { m } from '../../../../lib/messages' import { Modal } from '@island.is/service-portal/core' import { useState } from 'react' -import { useGetCurrentCollection } from '../../../hooks' +import { useGetCurrentCollection } from '../../../../hooks' import { useMutation } from '@apollo/client' -import { cancelCollectionMutation } from '../../../hooks/graphql/mutations' -import { - SignatureCollectionCancelListsInput, - SignatureCollectionSuccess, -} from '@island.is/api/schema' +import { cancelCollectionMutation } from '../../../../hooks/graphql/mutations' +import { SignatureCollectionSuccess } from '@island.is/api/schema' -const CancelCollection = ({ listId }: { listId?: string }) => { +const CancelCollection = () => { useNamespaces('sp.signatureCollection') const { formatMessage } = useLocale() const [modalIsOpen, setModalIsOpen] = useState(false) const { currentCollection } = useGetCurrentCollection() - const input = {} as SignatureCollectionCancelListsInput - if (listId && !currentCollection?.isPresidential) { - input.listIds = [listId] - } const [cancelCollection, { loading }] = useMutation(cancelCollectionMutation, { variables: { input: { - ...input, collectionId: currentCollection?.id ?? '', }, }, diff --git a/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx index d159e7170c02..397e3776bbe4 100644 --- a/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx @@ -17,7 +17,7 @@ import { useAuth } from '@island.is/auth/react' import copyToClipboard from 'copy-to-clipboard' import { SignatureCollection } from '@island.is/api/schema' import SignedList from '../../shared/SignedList' -import CancelCollection from '../../shared/CancelCollection' +import CancelCollection from './CancelCollection' const OwnerView = ({ currentCollection, diff --git a/libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx b/libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx index 4cf324e865ab..df7b95016cf0 100644 --- a/libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/shared/SignedList/index.tsx @@ -70,12 +70,8 @@ const SignedList = ({ return (