Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(admin): sc collection statuses #16501

Merged
merged 10 commits into from
Oct 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ import electionsCommitteeLogo from '../../../assets/electionsCommittee.svg'
import nationalRegistryLogo from '../../../assets/nationalRegistry.svg'
import { useSignatureCollectionAdminRemoveListMutation } from './removeList.generated'
import { useSignatureCollectionAdminRemoveCandidateMutation } from './removeCandidate.generated'
import { SignatureCollectionList } from '@island.is/api/schema'
import {
CollectionStatus,
SignatureCollectionList,
} from '@island.is/api/schema'

export const Constituency = ({
allowedToProcess,
Expand All @@ -41,7 +44,8 @@ export const Constituency = ({
const navigate = useNavigate()
const { revalidate } = useRevalidator()

const { collection, allLists } = useLoaderData() as ListsLoaderReturn
const { collection, collectionStatus, allLists } =
useLoaderData() as ListsLoaderReturn
const { constituencyName } = useParams() as { constituencyName: string }

const constituencyLists = allLists.filter(
Expand Down Expand Up @@ -127,12 +131,14 @@ export const Constituency = ({
': ' +
constituencyLists.length}
</Text>
{allowedToProcess && constituencyLists?.length > 0 && (
<CreateCollection
collectionId={collection?.id}
areaId={areaId}
/>
)}
{constituencyLists?.length > 0 &&
allowedToProcess &&
collectionStatus === CollectionStatus.InInitialReview && (
<CreateCollection
collectionId={collection?.id}
areaId={areaId}
/>
)}
</Box>
<Stack space={3}>
{constituencyLists.map((list) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ const List = ({ allowedToProcess }: { allowedToProcess: boolean }) => {
? formatMessage(m.listStatusReviewedStatusAlert)
: formatMessage(m.listStatusActiveAlert)
}
type={listStatus === ListStatus.Reviewed ? 'success' : undefined}
type={
listStatus === ListStatus.Reviewed ||
listStatus === ListStatus.Inactive
? 'success'
: undefined
}
/>
<ActionExtendDeadline
listId={list.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import nationalRegistryLogo from '../../assets/nationalRegistry.svg'
import { useState } from 'react'
import { useSignatureCollectionSignatureLookupQuery } from './findSignature.generated'
import { SkeletonSingleRow } from '../shared-components/compareLists/skeleton'
import { CollectionStatus } from '@island.is/api/schema'
import ActionCompleteCollectionProcessing from '../shared-components/completeCollectionProcessing'

const ParliamentaryRoot = ({
allowedToProcess,
Expand All @@ -33,7 +35,8 @@ const ParliamentaryRoot = ({
const { formatMessage } = useLocale()

const navigate = useNavigate()
const { collection, allLists } = useLoaderData() as ListsLoaderReturn
const { collection, collectionStatus, allLists } =
useLoaderData() as ListsLoaderReturn
albinagu marked this conversation as resolved.
Show resolved Hide resolved

const [searchTerm, setSearchTerm] = useState('')

Expand Down Expand Up @@ -179,41 +182,48 @@ const ParliamentaryRoot = ({
</Box>
))}
<Stack space={3}>
{collection?.areas.map((area) => (
<ActionCard
key={area.id}
eyebrow={
formatMessage(m.totalListsPerConstituency) +
allLists.filter((l) => l.area.name === area.name).length
}
heading={area.name}
cta={{
label: formatMessage(m.viewConstituency),
variant: 'text',
onClick: () => {
navigate(
SignatureCollectionPaths.ParliamentaryConstituency.replace(
':constituencyName',
area.name,
),
)
},
}}
tag={
allLists
.filter((l) => l.area.name === area.name)
.every((l) => l.reviewed === true)
? {
label: formatMessage(m.confirmListReviewed),
variant: 'mint',
outlined: true,
}
: undefined
}
/>
))}
{collection?.areas.map((area) => {
const areaLists = allLists.filter(
(l) => l.area.name === area.name,
)
return (
<ActionCard
key={area.id}
eyebrow={
formatMessage(m.totalListsPerConstituency) +
areaLists.length
albinagu marked this conversation as resolved.
Show resolved Hide resolved
}
heading={area.name}
cta={{
label: formatMessage(m.viewConstituency),
variant: 'text',
onClick: () => {
navigate(
SignatureCollectionPaths.ParliamentaryConstituency.replace(
':constituencyName',
area.name,
),
)
},
}}
tag={
areaLists.length > 0 &&
areaLists.every((l) => l.reviewed === true)
? {
label: formatMessage(m.confirmListReviewed),
variant: 'mint',
outlined: true,
}
: undefined
}
/>
)
})}
albinagu marked this conversation as resolved.
Show resolved Hide resolved
</Stack>
{allowedToProcess && <CompareLists collectionId={collection?.id} />}
{collectionStatus === CollectionStatus.InInitialReview && (
<ActionCompleteCollectionProcessing collectionId={collection?.id} />
)}
</GridColumn>
</GridRow>
</GridContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import {
import { format as formatNationalId } from 'kennitala'
import electionsCommitteeLogo from '../../../assets/electionsCommittee.svg'
import nationalRegistryLogo from '../../../assets/nationalRegistry.svg'
import ActionCompleteCollectionProcessing from './components/completeCollectionProcessing'
import ListInfo from '../../shared-components/listInfoAlert'
import EmptyState from '../../shared-components/emptyState'
import ReviewCandidates from './components/reviewCandidates'
import CompareLists from '../../shared-components/compareLists'
import { ListsLoaderReturn } from '../../loaders/AllLists.loader'
import CreateCollection from '../../shared-components/createCollection'
import ActionCompleteCollectionProcessing from '../../shared-components/completeCollectionProcessing'

const Lists = ({ allowedToProcess }: { allowedToProcess: boolean }) => {
const { formatMessage } = useLocale()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useLocale } from '@island.is/localization'
import { Box, Button, Text, toast } from '@island.is/island-ui/core'
import { m } from '../../../../lib/messages'
import { m } from '../../lib/messages'
albinagu marked this conversation as resolved.
Show resolved Hide resolved
import { useState } from 'react'
import { Modal } from '@island.is/react/components'
import { useRevalidator } from 'react-router-dom'
Expand Down
Loading