Skip to content

Commit

Permalink
fix(signature-collection): refetch is owner 16.10 (#16432)
Browse files Browse the repository at this point in the history
* fix(signature-collection): refetch is owner after remove last list

* tw

* tweak

* tw

* tw

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
albinagu and kodiakhq[bot] authored Oct 16, 2024
1 parent 8b46f97 commit 695edee
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
11 changes: 11 additions & 0 deletions libs/service-portal/signature-collection/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,22 @@ export const m = defineMessages({
defaultMessage: 'Þú ert að fara að hætta við söfnun meðmæla. Ertu viss?',
description: '',
},
cancelCollectionModalMessageLastList: {
id: 'sp.signatureCollection:cancelCollectionModalMessageLastList',
defaultMessage:
'Þú ert að fara að hætta við söfnun meðmæla í þessu kjördæmi. Þau meðmæli sem þú hefur nú þegar safnað munu eyðast. Athugaðu að með því að hætta við síðustu söfnun framboðsins verður framboðinu einnig eytt. Ertu viss um að þú viljir hætta við söfnun og eyða framboði?',
description: '',
},
cancelCollectionModalConfirmButton: {
id: 'sp.signatureCollection:modalConfirmButton',
defaultMessage: 'Já, hætta við',
description: '',
},
cancelCollectionModalConfirmButtonLastList: {
id: 'sp.signatureCollection:cancelCollectionModalConfirmButtonLastList',
defaultMessage: 'Já, hætta við söfnun of eyða framboði',
description: '',
},
cancelCollectionModalCancelButton: {
id: 'sp.signatureCollection:cancelCollectionModalCancelButton',
defaultMessage: 'Nei, hætta við',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ import { formatNationalId } from '@island.is/portals/core'
import SignedList from '../../shared/SignedList'

const OwnerView = ({
refetchIsOwner,
currentCollection,
// list holder is an individual who owns a list or has a delegation of type Procuration Holder
isListHolder,
}: {
refetchIsOwner: () => void
currentCollection: SignatureCollection
isListHolder: boolean
}) => {
Expand All @@ -54,6 +56,7 @@ const OwnerView = ({
onCompleted: () => {
toast.success(formatMessage(m.cancelCollectionModalToastSuccess))
refetchListsForOwner()
refetchIsOwner()
},
onError: () => {
toast.error(formatMessage(m.cancelCollectionModalToastError))
Expand All @@ -75,10 +78,13 @@ const OwnerView = ({
return (
<Stack space={8}>
<Box marginTop={5}>
<Box marginBottom={8}>
<SignedList currentCollection={currentCollection} />
</Box>
<Box display="flex" justifyContent="spaceBetween" alignItems="baseline">
<SignedList currentCollection={currentCollection} />
<Box
display="flex"
justifyContent="spaceBetween"
alignItems="baseline"
marginTop={[5, 10]}
>
<Text variant="h4">
{formatMessage(m.myListsDescription) + ' '}
<Tooltip
Expand Down Expand Up @@ -145,9 +151,13 @@ const OwnerView = ({
' - ' +
list.area?.name
}
description={formatMessage(
m.cancelCollectionModalMessage,
)}
description={
listsForOwner.length === 1
? formatMessage(
m.cancelCollectionModalMessageLastList,
)
: formatMessage(m.cancelCollectionModalMessage)
}
ariaLabel="delete"
disclosureElement={
<Tag outlined variant="red">
Expand All @@ -164,7 +174,9 @@ const OwnerView = ({
onCancelCollection(list.id)
}}
buttonTextConfirm={formatMessage(
m.cancelCollectionModalConfirmButton,
listsForOwner.length === 1
? m.cancelCollectionModalConfirmButtonLastList
: m.cancelCollectionModalConfirmButton,
)}
buttonPropsConfirm={{
variant: 'primary',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const SignatureListsParliamentary = () => {
useNamespaces('sp.signatureCollection')
const { formatMessage } = useLocale()

const { isOwner, loadingIsOwner } = useIsOwner()
const { isOwner, loadingIsOwner, refetchIsOwner } = useIsOwner()
const userInfo = useUserInfo()
const { currentCollection, loadingCurrentCollection } =
useGetCurrentCollection()
Expand All @@ -34,6 +34,7 @@ const SignatureListsParliamentary = () => {
{!currentCollection?.isPresidential ? (
isOwner.success ? (
<OwnerView
refetchIsOwner={refetchIsOwner}
currentCollection={currentCollection}
isListHolder={
!userInfo?.profile?.delegationType ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
SignatureCollectionSignedList,
SignatureCollectionSuccess,
} from '@island.is/api/schema'
import { SingleListSkeleton } from '../../../skeletons'

const SignedList = ({
currentCollection,
Expand Down Expand Up @@ -62,11 +61,6 @@ const SignedList = ({

return (
<Box>
{loadingSignedLists && (
<Box marginTop={10}>
<SingleListSkeleton />
</Box>
)}
{!loadingSignedLists && !!signedLists?.length && (
<Box marginTop={[5, 7]}>
<Text marginBottom={2} variant="h4">
Expand Down

0 comments on commit 695edee

Please sign in to comment.