Skip to content

Commit

Permalink
fix(signature-collection): tweaks 15.10 (#16402)
Browse files Browse the repository at this point in the history
* tweaka

* chore: nx format:write update dirty files

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and kksteini committed Oct 16, 2024
1 parent cb84770 commit 1e2c309
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ query Identity($input: IdentityInput!) {
}
}

query CanSign($input: SignatureCollectionCanSignFromPaperInput!) {
signatureCollectionCanSignFromPaper(input: $input)
query SignatureCollectionAdminCanSignInfo(
$input: SignatureCollectionCanSignFromPaperInput!
) {
signatureCollectionAdminCanSignInfo(input: $input) {
reasons
success
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useForm } from 'react-hook-form'
import { toast } from 'react-toastify'
import { m } from '../../../lib/messages'
import {
useCanSignQuery,
useSignatureCollectionAdminCanSignInfoQuery,
useIdentityQuery,
} from './identityAndCanSignLookup.generated'
import { useSignatureCollectionUploadPaperSignatureMutation } from './uploadPaperSignee.generated'
Expand All @@ -37,15 +37,16 @@ export const PaperSignees = ({ listId }: { listId: string }) => {
onCompleted: (data) => setName(data.identity?.name || ''),
})

const { data: canSign, loading: loadingCanSign } = useCanSignQuery({
variables: {
input: {
signeeNationalId: nationalIdInput,
listId,
const { data: canSign, loading: loadingCanSign } =
useSignatureCollectionAdminCanSignInfoQuery({
variables: {
input: {
signeeNationalId: nationalIdInput,
listId,
},
},
},
skip: !nationalId.isValid(nationalIdInput) || !name,
})
skip: !nationalId.isValid(nationalIdInput) || !name,
})

useEffect(() => {
if (nationalIdInput.length === 10) {
Expand Down Expand Up @@ -126,7 +127,11 @@ export const PaperSignees = ({ listId }: { listId: string }) => {
}}
error={nationalIdTypo ? ' ' : undefined}
loading={loading || loadingCanSign}
icon={name && canSign ? 'checkmark' : undefined}
icon={
name && canSign?.signatureCollectionAdminCanSignInfo?.success
? 'checkmark'
: undefined
}
/>
</GridColumn>
<GridColumn span={['5/12', '4/12']}>
Expand Down Expand Up @@ -157,7 +162,9 @@ export const PaperSignees = ({ listId }: { listId: string }) => {
<Button
variant="ghost"
size="small"
disabled={!canSign || !page}
disabled={
!canSign?.signatureCollectionAdminCanSignInfo?.success || !page
}
onClick={() => uploadPaperSignee()}
loading={uploadingPaperSignature}
>
Expand All @@ -175,15 +182,17 @@ export const PaperSignees = ({ listId }: { listId: string }) => {
/>
</Box>
)}
{name && !loadingCanSign && !canSign && (
<Box marginTop={5}>
<AlertMessage
type="error"
title={formatMessage(m.paperSigneeCantSignTitle)}
message={formatMessage(m.paperSigneeCantSignMessage)}
/>
</Box>
)}
{name &&
!loadingCanSign &&
!canSign?.signatureCollectionAdminCanSignInfo?.success && (
<Box marginTop={5}>
<AlertMessage
type="error"
title={formatMessage(m.paperSigneeCantSignTitle)}
message={formatMessage(m.paperSigneeCantSignMessage)}
/>
</Box>
)}
</Box>
)
}
14 changes: 10 additions & 4 deletions libs/service-portal/signature-collection/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const m = defineMessages({
},
coOwners: {
id: 'sp.signatureCollection:coOwners',
defaultMessage: 'Umboðsaðilar:',
defaultMessage: 'Umsjónaraðilar:',
description: '',
},
copyLink: {
Expand Down Expand Up @@ -277,6 +277,12 @@ export const m = defineMessages({
defaultMessage: 'Skrá meðmæli af blaði',
description: '',
},
paperSigneesTooltip: {
id: 'sp.signatureCollection:paperSigneesTooltip',
defaultMessage:
'Athugið að ógild meðmæli skrást inn en teljast ekki með í heildartölu meðmæla. Dæmi slegnar eru inn 10 kennitölur en kerfið telur aðeins 8 gildar.',
description: '',
},
paperSigneesClearButton: {
id: 'sp.signatureCollection:paperSigneesClearButton',
defaultMessage: 'Hreinsa',
Expand Down Expand Up @@ -355,10 +361,10 @@ export const m = defineMessages({
defaultMessage: 'Umsjónaraðilar',
description: '',
},
supervisorsInfo: {
id: 'sp.signatureCollection:supervisorsInfo',
supervisorsTooltip: {
id: 'sp.signatureCollection:supervisorsTooltip',
defaultMessage:
'Umsjónaraðilar hafa aðgang að öllum upplýsingum safnananna en geta ekki eytt söfnununum. ',
'Umsjónaraðilar hafa aðgang að öllum upplýsingum safnananna en geta ekki eytt söfnununum.',
description: '',
},
add: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
GridContainer,
AlertMessage,
Input,
Tooltip,
} from '@island.is/island-ui/core'
import { useLocale, useNamespaces } from '@island.is/localization'
import { useIdentityQuery } from '@island.is/service-portal/graphql'
Expand Down Expand Up @@ -93,9 +94,14 @@ export const PaperSignees = ({

return (
<Box marginTop={8}>
<Box display={'flex'} justifyContent={'spaceBetween'}>
<Box display="flex" justifyContent={'spaceBetween'}>
<Text variant="h4" marginBottom={2}>
{formatMessage(m.paperSigneesHeader)}
{formatMessage(m.paperSigneesHeader) + ' '}
<Tooltip
placement="right"
color="blue400"
text={formatMessage(m.paperSigneesTooltip)}
/>
</Text>
<Box>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,20 @@ const ViewList = () => {
<Box>
<Text variant="h3">{listInfo.title}</Text>
</Box>
<Box display={['block', 'flex']} justifyContent="spaceBetween">
<Box display="block">
<Box>
<Text variant="h5">{formatMessage(m.listPeriod)}</Text>
<Text variant="h4">{formatMessage(m.listPeriod)}</Text>
<Text>
{format(new Date(listInfo.startTime), 'dd.MM.yyyy') +
' - ' +
format(new Date(listInfo.endTime), 'dd.MM.yyyy')}
</Text>
</Box>
<Box marginTop={[2, 0]}>
<Text variant="h5">{formatMessage(m.numberOfSigns)}</Text>
<Text>{listInfo?.numberOfSignatures}</Text>
</Box>
<Box marginTop={[2, 0]}>
<Box marginTop={5}>
{!!listInfo?.collectors?.length && (
<>
<Text marginTop={[2, 0]} variant="h5">
{formatMessage(m.supervisors)}
<Text marginTop={[2, 0]} variant="h4">
{formatMessage(m.coOwners)}
</Text>
{listInfo?.collectors?.map((collector) => (
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const OwnerView = ({
{formatMessage(m.supervisors) + ' '}
<Tooltip
placement="right"
text={formatMessage(m.supervisorsInfo)}
text={formatMessage(m.supervisorsTooltip)}
color="blue400"
/>
</Text>
Expand Down

0 comments on commit 1e2c309

Please sign in to comment.