-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service-portal): Signee view for parliamentary signature collect…
…ion (#16019) * initial setup parliamentary * Parliamentary signee view * update urls for parliamentary * feedback * more * refactor is parliamentary check --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a4803a3
commit a5c9f5c
Showing
8 changed files
with
314 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,7 @@ export const GetCurrentCollection = gql` | |
startTime | ||
name | ||
isActive | ||
isPresidential | ||
status | ||
areas { | ||
id | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
libs/service-portal/signature-collection/src/screens/Parliamentary/SignedList/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { ActionCard, Box, Button, Text, toast } from '@island.is/island-ui/core' | ||
import { useLocale } from '@island.is/localization' | ||
import { m } from '../../../lib/messages' | ||
import { Modal } from '@island.is/service-portal/core' | ||
import { useState } from 'react' | ||
import { useGetSignedList } from '../../../hooks' | ||
import format from 'date-fns/format' | ||
import { useMutation } from '@apollo/client' | ||
import { unSignList } from '../../../hooks/graphql/mutations' | ||
import { | ||
SignatureCollectionSignedList, | ||
SignatureCollectionSuccess, | ||
} from '@island.is/api/schema' | ||
|
||
const SignedList = () => { | ||
const { formatMessage } = useLocale() | ||
const [modalIsOpen, setModalIsOpen] = useState(false) | ||
|
||
// SignedList is typically singular, although it may consist of multiple entries, which in that case will all be invalid | ||
const { signedLists, loadingSignedLists, refetchSignedLists } = | ||
useGetSignedList() | ||
|
||
const [unSign, { loading }] = useMutation(unSignList, { | ||
variables: { | ||
input: { | ||
listId: | ||
signedLists && signedLists?.length === 1 | ||
? signedLists[0].id | ||
: undefined, | ||
}, | ||
}, | ||
}) | ||
|
||
const onUnSignList = async () => { | ||
try { | ||
await unSign().then(({ data }) => { | ||
if ( | ||
( | ||
data as unknown as { | ||
signatureCollectionUnsign: SignatureCollectionSuccess | ||
} | ||
).signatureCollectionUnsign.success | ||
) { | ||
toast.success(formatMessage(m.unSignSuccess)) | ||
setModalIsOpen(false) | ||
refetchSignedLists() | ||
} else { | ||
setModalIsOpen(false) | ||
} | ||
}) | ||
} catch (e) { | ||
toast.error(formatMessage(m.unSignError)) | ||
} | ||
} | ||
|
||
return ( | ||
<Box> | ||
{!loadingSignedLists && !!signedLists?.length && ( | ||
<Box marginTop={[5, 7]}> | ||
<Text marginBottom={2}>{formatMessage(m.mySigneeListsHeader)}</Text> | ||
{signedLists?.map((list: SignatureCollectionSignedList) => { | ||
return ( | ||
<Box marginBottom={3} key={list.id}> | ||
<ActionCard | ||
heading={list.title} | ||
eyebrow={`${ | ||
list.isDigital | ||
? formatMessage(m.signedTime) | ||
: formatMessage(m.uploadedTime) | ||
} ${format(new Date(list.signedDate), 'dd.MM.yyyy')}`} | ||
text={formatMessage(m.collectionTitle)} | ||
cta={ | ||
list.canUnsign | ||
? { | ||
label: formatMessage(m.unSignList), | ||
buttonType: { | ||
variant: 'text', | ||
colorScheme: 'destructive', | ||
}, | ||
onClick: () => setModalIsOpen(true), | ||
icon: undefined, | ||
} | ||
: undefined | ||
} | ||
tag={ | ||
list.isValid && !list.active | ||
? { | ||
label: formatMessage(m.collectionClosed), | ||
variant: 'red', | ||
outlined: true, | ||
} | ||
: list.isValid && !list.isDigital | ||
? { | ||
label: formatMessage(m.paperUploadedSignature), | ||
variant: 'blue', | ||
outlined: true, | ||
} | ||
: !list.isValid | ||
? { | ||
label: formatMessage(m.signatureIsInvalid), | ||
variant: 'red', | ||
outlined: false, | ||
} | ||
: undefined | ||
} | ||
/> | ||
<Modal | ||
id="unSignList" | ||
isVisible={modalIsOpen} | ||
toggleClose={false} | ||
initialVisibility={false} | ||
onCloseModal={() => setModalIsOpen(false)} | ||
> | ||
<Text variant="h2" marginTop={[5, 0]}> | ||
{formatMessage(m.unSignList)} | ||
</Text> | ||
<Text variant="default" marginTop={2}> | ||
{formatMessage(m.unSignModalMessage)} | ||
</Text> | ||
<Box | ||
marginTop={[7, 10]} | ||
marginBottom={5} | ||
display="flex" | ||
justifyContent="center" | ||
> | ||
<Button | ||
loading={loading} | ||
colorScheme="destructive" | ||
onClick={() => { | ||
onUnSignList() | ||
}} | ||
> | ||
{formatMessage(m.unSignModalConfirmButton)} | ||
</Button> | ||
</Box> | ||
</Modal> | ||
</Box> | ||
) | ||
})} | ||
</Box> | ||
)} | ||
</Box> | ||
) | ||
} | ||
|
||
export default SignedList |
126 changes: 110 additions & 16 deletions
126
libs/service-portal/signature-collection/src/screens/Parliamentary/SigneeView/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.