diff --git a/libs/island-ui/core/src/lib/ActionCard/ActionCard.tsx b/libs/island-ui/core/src/lib/ActionCard/ActionCard.tsx index cca83b057a70..984eb0c3ff2e 100644 --- a/libs/island-ui/core/src/lib/ActionCard/ActionCard.tsx +++ b/libs/island-ui/core/src/lib/ActionCard/ActionCard.tsx @@ -237,7 +237,7 @@ export const ActionCard: React.FC> = ({ } return ( - + import('./screens')) -const ViewList = lazy(() => import('./screens/CandidateView/ViewList')) +const SignatureListsParliamentary = lazy(() => + import('./screens/Parliamentary/'), +) +const SignatureListsPresidential = lazy(() => import('./screens/Presidential')) +const ViewListPresidential = lazy(() => + import('./screens/Presidential/OwnerView/ViewList'), +) +const ViewListParliamentary = lazy(() => + import('./screens/Parliamentary/OwnerView/ViewList'), +) export const signatureCollectionModule: PortalModule = { name: m.signatureCollectionLists, - featureFlag: Features.servicePortalSignatureCollection, routes: ({ userInfo }) => { const applicationRoutes: PortalRoute[] = [ { - name: m.signatureCollectionLists, + name: m.signatureCollectionParliamentaryLists, path: SignatureCollectionPaths.RootPath, enabled: userInfo.scopes.includes(ApiScope.signatureCollection), element: ( - + /* Default path to general petitions since these are always ongoing */ + ), }, { - name: m.signatureCollectionLists, + name: m.signatureCollectionParliamentaryLists, + enabled: userInfo.scopes.includes(ApiScope.signatureCollection), + path: SignatureCollectionPaths.SignatureCollectionParliamentaryLists, + key: 'ParliamentaryLists', + element: , + }, + { + name: m.signatureCollectionPresidentialLists, + path: SignatureCollectionPaths.ViewParliamentaryList, + enabled: userInfo.scopes.includes(ApiScope.signatureCollection), + key: 'ParliamentaryLists', + element: , + }, + { + name: m.signatureCollectionPresidentialLists, enabled: userInfo.scopes.includes(ApiScope.signatureCollection), path: SignatureCollectionPaths.SignatureCollectionLists, - element: , + key: 'PresidentialLists', + element: , }, { - name: m.signatureCollectionLists, + name: m.signatureCollectionPresidentialLists, path: SignatureCollectionPaths.ViewList, + key: 'PresidentialLists', enabled: userInfo.scopes.includes(ApiScope.signatureCollection), - element: , + element: , }, ] 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.tsx new file mode 100644 index 000000000000..00407d53f316 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/Signees.tsx @@ -0,0 +1,142 @@ +import { + Box, + Text, + Table as T, + Pagination, + FilterInput, +} from '@island.is/island-ui/core' +import { useLocale, useNamespaces } from '@island.is/localization' +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 { format as formatNationalId } from 'kennitala' +import { SkeletonTable } from '../../../../skeletons' +import { SignatureCollectionSignature as Signature } from '@island.is/api/schema' + +const Signees = () => { + useNamespaces('sp.signatureCollection') + const { formatMessage } = useLocale() + const { pathname } = useLocation() + const listId = pathname.replace('/min-gogn/listar/medmaelasofnun/', '') + + const [searchTerm, setSearchTerm] = useState('') + const { listSignees, loadingSignees } = useGetListSignees(listId) + const [signees, setSignees] = useState(listSignees) + + const [page, setPage] = useState(1) + const pageSize = 10 + + useEffect(() => { + if (!loadingSignees && listSignees.length) { + setSignees(listSignees) + } + }, [listSignees]) + + // list search + useEffect(() => { + let filteredSignees: Signature[] = listSignees + + filteredSignees = filteredSignees.filter((s) => { + return ( + s.signee.name.toLowerCase().includes(searchTerm.toLowerCase()) || + formatNationalId(s.signee.nationalId).includes(searchTerm) || + s.signee.nationalId.includes(searchTerm) + ) + }) + + setPage(1) + setSignees(filteredSignees) + }, [searchTerm]) + + return ( + + {formatMessage(m.signeesHeader)} + + + setSearchTerm(v)} + placeholder={formatMessage(m.searchInListPlaceholder)} + backgroundColor="white" + /> + + + {!loadingSignees ? ( + signees.length > 0 ? ( + + + + + {formatMessage(m.signeeDate)} + {formatMessage(m.signeeName)} + {formatMessage(m.signeeNationalId)} + {formatMessage(m.signeeAddress)} + + + + {signees + .slice(pageSize * (page - 1), pageSize * page) + .map((s: Signature) => { + return ( + + + {format(new Date(), 'dd.MM.yyyy')} + + + {s.signee.name} + + + {formatNationalId(s.signee.nationalId)} + + + {s.signee.address} + + + ) + })} + + + + + ( + setPage(page)} + component="button" + > + {children} + + )} + /> + + + ) : searchTerm.length > 0 ? ( + + {formatMessage(m.noSigneesFoundBySearch)} + + {searchTerm} + + + ) : ( + {formatMessage(m.noSignees)} + ) + ) : ( + + )} + + ) +} + +export default Signees 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 new file mode 100644 index 000000000000..073523619387 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/ViewList/index.tsx @@ -0,0 +1,70 @@ +import { Box, Stack, Text } from '@island.is/island-ui/core' +import { useLocale, useNamespaces } from '@island.is/localization' +import { m } from '../../../../lib/messages' +import { useLocation } from 'react-router-dom' +import { useGetSignatureList } from '../../../../hooks' +import format from 'date-fns/format' +import Signees from './Signees' +import CancelCollection from '../../../Presidential/OwnerView/CancelCollection' +import { SignatureCollectionPaths } from '../../../../lib/paths' + +const ViewList = () => { + useNamespaces('sp.signatureCollection') + const { formatMessage } = useLocale() + const { pathname } = useLocation() + const listId = pathname.replace( + SignatureCollectionPaths.SignatureCollectionParliamentaryLists + '/', + '', + ) + const { listInfo, loadingList } = useGetSignatureList(listId) + + return ( + <> + {/*!loadingList && !!listInfo && (*/} + + + {'Listi A'} + + + + {formatMessage(m.listPeriod)} + {/* + {format(new Date(listInfo.startTime), "dd.MM.yyyy") + + " - " + + format(new Date(listInfo.endTime), "dd.MM.yyyy")} + */} + + + {formatMessage(m.numberOfSigns)} + {listInfo?.numberOfSignatures} + + + {!!listInfo?.collectors?.length && ( + <> + + {formatMessage(m.coOwners)} + + {listInfo?.collectors?.map((collector) => ( + + {collector.name} + + ))} + + )} + + + + + + + {/*)}*/} + + ) +} + +export default ViewList 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 new file mode 100644 index 000000000000..e85564267804 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/index.tsx @@ -0,0 +1,162 @@ +import { + ActionCard, + AlertMessage, + Box, + Stack, + Text, + Table as T, + Tooltip, +} from '@island.is/island-ui/core' +import { constituencies } from '../../../lib/constants' +import { useNavigate } from 'react-router-dom' +import { SignatureCollectionPaths } from '../../../lib/paths' +import LookupPerson from './modals/LookupPerson' +import { useLocale } from '@island.is/localization' +import { m } from '../../../lib/messages' +import AddConstituency from './modals/AddConstituency' +import DeletePerson from './modals/DeletePerson' +import EditPerson from './modals/EditPerson' + +const OwnerView = () => { + const navigate = useNavigate() + const { formatMessage } = useLocale() + + return ( + + + + + {formatMessage(m.myListsDescription)} + + + {constituencies.map((c: string, index: number) => ( + + { + navigate( + SignatureCollectionPaths.ViewParliamentaryList.replace( + ':id', + '1', + ), + ) + }, + }} + /> + + ))} + + {/* Ábyrgðaraðilar */} + + + + {formatMessage(m.managers) + ' '} + + + + + + + + {formatMessage(m.personName)} + {formatMessage(m.personNationalId)} + {formatMessage(m.constituency)} + + + + + + {'Nafni Nafnason'} + {'010130-3019'} + + {formatMessage(m.allConstituencies)} + + + + + + + + + + + {/* Umsjónaraðilar */} + + + + {formatMessage(m.supervisors) + ' '} + + + + + + + + {formatMessage(m.personName)} + {formatMessage(m.personNationalId)} + {formatMessage(m.constituency)} + + + + + + {'Nafni Nafnason'} + {'010130-3019'} + + {formatMessage( + 'Suðvesturkjördæmi, Suðurkjördæmi, Norðausturkjördæmi, Suðvesturkjördæmi, Suðurkjördæmi, Norðausturkjördæmi', + )} + + + + + + + + + + + + + ) +} + +export default OwnerView diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/AddConstituency/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/AddConstituency/index.tsx new file mode 100644 index 000000000000..bd98c7584e81 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/AddConstituency/index.tsx @@ -0,0 +1,61 @@ +import { useState } from 'react' +import { + Box, + Button, + Text, + Checkbox, + AlertMessage, +} 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' + +const AddConstituencyModal = () => { + const { formatMessage } = useLocale() + const [modalIsOpen, setModalIsOpen] = useState(false) + + return ( + + + setModalIsOpen(false)} + label={''} + > + + {formatMessage(m.addConstituency)} + + + {formatMessage(m.addConstituencyDescription)} + + {constituencies.map((constituency) => ( + + + + ))} + + + + + + + + + ) +} + +export default AddConstituencyModal diff --git a/libs/service-portal/signature-collection/src/screens/CandidateView/CancelCollection/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/CancelCollection/index.tsx similarity index 92% rename from libs/service-portal/signature-collection/src/screens/CandidateView/CancelCollection/index.tsx rename to libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/CancelCollection/index.tsx index 3a5b525c73b6..d06057f66f6f 100644 --- a/libs/service-portal/signature-collection/src/screens/CandidateView/CancelCollection/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/CancelCollection/index.tsx @@ -1,11 +1,11 @@ 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 { useGetListsForUser, useIsOwner } from '../../../hooks' +import { useGetListsForUser, useIsOwner } from '../../../../../hooks' import { useMutation } from '@apollo/client' -import { cancelCollectionMutation } from '../../../hooks/graphql/mutations' +import { cancelCollectionMutation } from '../../../../../hooks/graphql/mutations' import { SignatureCollectionSuccess } from '@island.is/api/schema' const CancelCollection = ({ collectionId }: { collectionId: string }) => { diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/DeletePerson/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/DeletePerson/index.tsx new file mode 100644 index 000000000000..3f29c2856f93 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/DeletePerson/index.tsx @@ -0,0 +1,40 @@ +import { useState } from 'react' +import { Box, Button, Text } 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' + +const DeletePersonModal = () => { + const { formatMessage } = useLocale() + const [modalIsOpen, setModalIsOpen] = useState(false) + + return ( + + + + + + ) +} + +export default DeletePersonModal diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/EditPerson/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/EditPerson/index.tsx new file mode 100644 index 000000000000..e87174af4c7b --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/EditPerson/index.tsx @@ -0,0 +1,60 @@ +import { useState } from 'react' +import { Box, Stack, Button, Input, Checkbox } 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' + +const EditPerson = () => { + const { formatMessage } = useLocale() + const [modalIsOpen, setModalIsOpen] = useState(false) + + return ( + + + + + + ) +} + +export default EditPerson diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/LookupPerson/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/LookupPerson/index.tsx new file mode 100644 index 000000000000..686c6167e0ff --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/OwnerView/modals/LookupPerson/index.tsx @@ -0,0 +1,125 @@ +import { useEffect, useState } from 'react' +import { + Box, + Stack, + Button, + Text, + Input, + Checkbox, +} from '@island.is/island-ui/core' +import { Modal } from '@island.is/service-portal/core' +import { useLocale } from '@island.is/localization' +import { useIdentityQuery } from '@island.is/service-portal/graphql' +import { InputController } from '@island.is/shared/form-fields' +import { useForm } from 'react-hook-form' +import { m } from '../../../../../lib/messages' +import { constituencies } from '../../../../../lib/constants' + +interface LookupPersonProps { + collectionId: string + title: string + withConstituencies?: boolean +} + +const LookupPerson = ({ + collectionId, + title, + withConstituencies, +}: LookupPersonProps) => { + const { formatMessage } = useLocale() + const { control } = useForm() + + const [modalIsOpen, setModalIsOpen] = useState(false) + const [nationalIdInput, setNationalIdInput] = useState('') + const [nationalIdNotFound, setNationalIdNotFound] = useState(false) + const [name, setName] = useState('') + + const { data, loading } = useIdentityQuery({ + variables: { + input: { + nationalId: nationalIdInput, + }, + }, + skip: nationalIdInput.length !== 10, + }) + + useEffect(() => { + if (!loading) { + if (nationalIdInput.length === 10 && data?.identity?.name) { + setName(data.identity.name) + } else { + setName('') + setNationalIdNotFound(nationalIdInput.length === 10) + if (nationalIdInput.length !== 10) { + setNationalIdInput('') + } + } + } + }, [nationalIdInput, loading]) + + return ( + + + setModalIsOpen(false)} + label={''} + > + + {title} + + + { + setNationalIdInput(e.target.value.replace(/\W/g, '')) + }} + error={ + nationalIdNotFound + ? formatMessage(m.nationalIdInvalid) + : undefined + } + loading={loading} + /> + + {withConstituencies && + constituencies.map((constituency) => ( + + ))} + + + + + + + ) +} + +export default LookupPerson diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/SigneeView/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/SigneeView/index.tsx new file mode 100644 index 000000000000..1701ddf89f7d --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/SigneeView/index.tsx @@ -0,0 +1,28 @@ +import { ActionCard, Box, Text } from '@island.is/island-ui/core' +import { useLocale } from '@island.is/localization' +import { m } from '../../../lib/messages' + +const SigneeView = () => { + const { formatMessage } = useLocale() + + return ( + + + {formatMessage(m.mySigneeListsHeader)} + + + + ) +} + +export default SigneeView diff --git a/libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx b/libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx new file mode 100644 index 000000000000..033ba27054d0 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Parliamentary/index.tsx @@ -0,0 +1,24 @@ +import { Box } from '@island.is/island-ui/core' +import { useLocale } from '@island.is/localization' +import { IntroHeader } from '@island.is/service-portal/core' +import { m } from '../../lib/messages' +import OwnerView from './OwnerView' +import SigneeView from './SigneeView' + +const SignatureListsParliamentary = () => { + const { formatMessage } = useLocale() + + return ( + + + + + + + ) +} + +export default SignatureListsParliamentary diff --git a/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/CancelCollection/index.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/CancelCollection/index.tsx new file mode 100644 index 000000000000..3a3611e77ef8 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/CancelCollection/index.tsx @@ -0,0 +1,86 @@ +import { Box, Button, Text, toast } from '@island.is/island-ui/core' +import { useLocale, useNamespaces } from '@island.is/localization' +import { m } from '../../../../lib/messages' +import { Modal } from '@island.is/service-portal/core' +import { useState } from 'react' +import { useGetListsForUser, useIsOwner } from '../../../../hooks' +import { useMutation } from '@apollo/client' +import { cancelCollectionMutation } from '../../../../hooks/graphql/mutations' +import { SignatureCollectionSuccess } from '@island.is/api/schema' + +const CancelCollection = ({ collectionId }: { collectionId: string }) => { + useNamespaces('sp.signatureCollection') + const { formatMessage } = useLocale() + const [modalIsOpen, setModalIsOpen] = useState(false) + const { refetchIsOwner } = useIsOwner() + const { refetchListsForUser } = useGetListsForUser(collectionId) + const [cancelCollection, { loading }] = + useMutation(cancelCollectionMutation, { + variables: { input: { collectionId: collectionId } }, + }) + + const onCancelCollection = async () => { + await cancelCollection().then(({ data }) => { + if ( + ( + data as any as { + signatureCollectionCancel: SignatureCollectionSuccess + } + ).signatureCollectionCancel.success + ) { + toast.success(formatMessage(m.cancelCollectionModalToastSuccess)) + setModalIsOpen(false) + refetchIsOwner() + refetchListsForUser() + } else { + toast.error(formatMessage(m.cancelCollectionModalToastError)) + setModalIsOpen(false) + } + }) + } + + return ( + + setModalIsOpen(false)} + disclosure={ + + } + > + + {formatMessage(m.cancelCollectionButton)} + + + {formatMessage(m.cancelCollectionModalMessage)} + + + + + + + ) +} + +export default CancelCollection diff --git a/libs/service-portal/signature-collection/src/screens/CandidateView/ViewList/signees.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/ViewList/SigneesOverview.tsx similarity index 96% rename from libs/service-portal/signature-collection/src/screens/CandidateView/ViewList/signees.tsx rename to libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/ViewList/SigneesOverview.tsx index ac5de6697886..373949633eb3 100644 --- a/libs/service-portal/signature-collection/src/screens/CandidateView/ViewList/signees.tsx +++ b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/ViewList/SigneesOverview.tsx @@ -6,14 +6,14 @@ import { FilterInput, } 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 * as styles from '../../styles.css' -import { useGetListSignees } from '../../../hooks' +import { useGetListSignees } from '../../../../hooks' import { useLocation } 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' const Signees = () => { diff --git a/libs/service-portal/signature-collection/src/screens/CandidateView/ViewList/index.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/ViewList/index.tsx similarity index 93% rename from libs/service-portal/signature-collection/src/screens/CandidateView/ViewList/index.tsx rename to libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/ViewList/index.tsx index a31cd269968b..ee9601e8b986 100644 --- a/libs/service-portal/signature-collection/src/screens/CandidateView/ViewList/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/ViewList/index.tsx @@ -1,10 +1,10 @@ import { Box, Stack, Text } from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' -import { m } from '../../../lib/messages' -import Signees from './signees' +import { m } from '../../../../lib/messages' import { useLocation } from 'react-router-dom' -import { useGetSignatureList } from '../../../hooks' +import { useGetSignatureList } from '../../../../hooks' import format from 'date-fns/format' +import Signees from './SigneesOverview' const ViewList = () => { useNamespaces('sp.signatureCollection') diff --git a/libs/service-portal/signature-collection/src/screens/CandidateView/index.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx similarity index 91% rename from libs/service-portal/signature-collection/src/screens/CandidateView/index.tsx rename to libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx index a8bbb9a0471f..197461ab20b4 100644 --- a/libs/service-portal/signature-collection/src/screens/CandidateView/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Presidential/OwnerView/index.tsx @@ -7,20 +7,19 @@ import { toast, } from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' -import { m } from '../../lib/messages' -import { SignatureCollectionPaths } from '../../lib/paths' -import { IntroHeader } from '@island.is/service-portal/core' +import { m } from '../../../lib/messages' +import { SignatureCollectionPaths } from '../../../lib/paths' import CancelCollection from './CancelCollection' -import { useGetListsForOwner } from '../../hooks' +import { useGetListsForOwner } from '../../../hooks' import format from 'date-fns/format' -import { Skeleton } from '../skeletons' +import { Skeleton } from '../../../skeletons' import { useNavigate } from 'react-router-dom' import { useAuth } from '@island.is/auth/react' import copyToClipboard from 'copy-to-clipboard' -import SignedList from '../../components/SignedList' +import SignedList from '../SignedList' import { SignatureCollection } from '@island.is/api/schema' -const CandidateView = ({ +const OwnerView = ({ currentCollection, }: { currentCollection: SignatureCollection @@ -35,10 +34,6 @@ const CandidateView = ({ return ( - {!loadingOwnerLists && !!currentCollection ? ( {listsForOwner?.length === 0 && currentCollection.isActive && ( @@ -158,4 +153,4 @@ const CandidateView = ({ ) } -export default CandidateView +export default OwnerView diff --git a/libs/service-portal/signature-collection/src/components/SignedList/index.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/SignedList/index.tsx similarity index 96% rename from libs/service-portal/signature-collection/src/components/SignedList/index.tsx rename to libs/service-portal/signature-collection/src/screens/Presidential/SignedList/index.tsx index cb732907cdca..410d4f148153 100644 --- a/libs/service-portal/signature-collection/src/components/SignedList/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Presidential/SignedList/index.tsx @@ -1,12 +1,12 @@ import { ActionCard, 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 { useGetSignedList } from '../../hooks' +import { useGetSignedList } from '../../../hooks' import format from 'date-fns/format' import { useMutation } from '@apollo/client' -import { unSignList } from '../../hooks/graphql/mutations' +import { unSignList } from '../../../hooks/graphql/mutations' import { SignatureCollectionSignedList, SignatureCollectionSuccess, diff --git a/libs/service-portal/signature-collection/src/screens/SigneeView/index.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/SigneeView/index.tsx similarity index 91% rename from libs/service-portal/signature-collection/src/screens/SigneeView/index.tsx rename to libs/service-portal/signature-collection/src/screens/Presidential/SigneeView/index.tsx index 8ac5c06e46e8..b8e97a633d7d 100644 --- a/libs/service-portal/signature-collection/src/screens/SigneeView/index.tsx +++ b/libs/service-portal/signature-collection/src/screens/Presidential/SigneeView/index.tsx @@ -7,15 +7,15 @@ import { Text, } from '@island.is/island-ui/core' import { useLocale, useNamespaces } from '@island.is/localization' -import { m } from '../../lib/messages' import { EmptyState, IntroHeader } from '@island.is/service-portal/core' -import { useGetListsForUser, useGetSignedList } from '../../hooks' +import { useGetListsForUser, useGetSignedList } from '../../../hooks' import format from 'date-fns/format' -import { Skeleton } from '../skeletons' -import SignedList from '../../components/SignedList' +import { Skeleton } from '../../../skeletons' import { useAuth } from '@island.is/auth/react' -import { SignatureCollection } from '../../types/schema' import { sortAlpha } from '@island.is/shared/utils' +import { m } from '../../../lib/messages' +import SignedList from '../SignedList' +import { SignatureCollection } from '../../../types/schema' const SigneeView = ({ currentCollection, @@ -33,10 +33,6 @@ const SigneeView = ({ return ( - {!user?.profile.actor && !loadingSignedLists && !loadingUserLists ? ( {currentCollection?.isActive && ( diff --git a/libs/service-portal/signature-collection/src/screens/Presidential/index.tsx b/libs/service-portal/signature-collection/src/screens/Presidential/index.tsx new file mode 100644 index 000000000000..f8e427108044 --- /dev/null +++ b/libs/service-portal/signature-collection/src/screens/Presidential/index.tsx @@ -0,0 +1,44 @@ +import { Box } from '@island.is/island-ui/core' +import { useLocale, useNamespaces } from '@island.is/localization' +import SigneeView from './SigneeView' +import OwnerView from './OwnerView' +import { useGetCurrentCollection, useIsOwner } from '../../hooks' +import { EmptyState, IntroHeader } from '@island.is/service-portal/core' +import { m } from '../../lib/messages' +import { CollectionType } from '../../lib/constants' + +const SignatureLists = () => { + useNamespaces('sp.signatureCollection') + const { formatMessage } = useLocale() + + const { isOwner, loadingIsOwner } = useIsOwner() + const { currentCollection, loadingCurrentCollection } = + useGetCurrentCollection() + + return ( + + + {currentCollection?.name === CollectionType.Presidential && + !loadingIsOwner && + !loadingCurrentCollection ? ( + + {isOwner.success ? ( + + ) : ( + + )} + + ) : ( + + )} + + ) +} + +export default SignatureLists diff --git a/libs/service-portal/signature-collection/src/screens/styles.css.ts b/libs/service-portal/signature-collection/src/screens/Presidential/styles.css.ts similarity index 100% rename from libs/service-portal/signature-collection/src/screens/styles.css.ts rename to libs/service-portal/signature-collection/src/screens/Presidential/styles.css.ts diff --git a/libs/service-portal/signature-collection/src/screens/index.tsx b/libs/service-portal/signature-collection/src/screens/index.tsx deleted file mode 100644 index ef4a7aa41268..000000000000 --- a/libs/service-portal/signature-collection/src/screens/index.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Box } from '@island.is/island-ui/core' -import { useNamespaces } from '@island.is/localization' -import OwnerView from './CandidateView' -import SigneeView from './SigneeView' -import { useGetCurrentCollection, useIsOwner } from '../hooks' - -const SignatureLists = () => { - useNamespaces('sp.signatureCollection') - - const { isOwner, loadingIsOwner } = useIsOwner() - const { currentCollection, loadingCurrentCollection } = - useGetCurrentCollection() - - return ( -
- {!loadingIsOwner && !loadingCurrentCollection && ( - - {isOwner.success ? ( - - ) : ( - - )} - - )} -
- ) -} - -export default SignatureLists diff --git a/libs/service-portal/signature-collection/src/screens/skeletons.tsx b/libs/service-portal/signature-collection/src/skeletons.tsx similarity index 100% rename from libs/service-portal/signature-collection/src/screens/skeletons.tsx rename to libs/service-portal/signature-collection/src/skeletons.tsx