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(signature-collections): ongoing updates #16409

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import { FC } from 'react'

export const CopyLink: FC<FieldBaseProps> = ({ application }) => {
const { formatMessage } = useLocale()
const { slug } = application.externalData.createLists.data as { slug: string }
albinagu marked this conversation as resolved.
Show resolved Hide resolved

return (
<Box>
<Text variant="h4" marginBottom={2}>
{formatMessage(m.shareList)}
</Text>
<Copy linkUrl={'TBD'} buttonTitle={formatMessage(m.copyLink)} />
<Copy
linkUrl={`${document.location.origin}${slug}`}
buttonTitle={formatMessage(m.copyLink)}
/>
</Box>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
buildPhoneField,
buildSection,
buildSubmitField,
buildTableRepeaterField,
buildTextField,
getValueViaPath,
} from '@island.is/application/core'
Expand All @@ -20,7 +19,6 @@ import Logo from '../../assets/Logo'

import { m } from '../lib/messages'
import { formatPhone } from '../lib/utils'
import { Manager, Supervisor } from '../lib/constants'
import { Collection } from '@island.is/clients/signature-collection'
import { Signee } from '@island.is/clients/signature-collection'

Expand Down Expand Up @@ -175,89 +173,6 @@ export const Draft: Form = buildForm({
}),
],
}),
/* Hiding this screen as for now
buildSection({
id: 'managers',
title: m.managersAndSupervisors,
children: [
buildMultiField({
id: 'managers',
title: m.managersAndSupervisorsTitle,
description: '',
children: [
buildTableRepeaterField({
id: 'managers',
title: m.managers,
description: m.managersDescription,
addItemButtonText: m.addManager,
marginTop: 0,
fields: {
manager: {
component: 'nationalIdWithName',
},
constituency: {
component: 'select',
label: m.constituency,
width: 'full',
options: [
{
value: m.allConstituencies.defaultMessage,
label: m.allConstituencies,
},
],
},
},
table: {
header: [m.nationalId, m.name, m.constituency],
rows: ['nationalId', 'name', 'constituency'],
format: {
nationalId: (v) => formatNationalId(v),
},
},
}),
buildTableRepeaterField({
id: 'supervisors',
title: m.supervisors,
description: m.supervisorsDescription,
addItemButtonText: m.addSupervisor,
marginTop: 5,
fields: {
supervisor: {
component: 'nationalIdWithName',
},
constituency: {
component: 'select',
label: m.constituency,
width: 'full',
isMulti: true,
options: (application) => {
return (
application.externalData.parliamentaryCollection
.data as Collection
)?.areas.map((area) => ({
value: `${area.id}|${area.name}`,
label: area.name,
}))
},
},
},
table: {
header: [m.nationalId, m.name, m.constituency],
rows: ['nationalId', 'name', 'constituency'],
format: {
nationalId: (v) => formatNationalId(v),
constituency: (v) => {
return (v as unknown as string[])
.map((e) => e.split('|')[1])
.join(', ')
},
},
},
}),
],
}),
],
}),*/
buildSection({
id: 'overview',
title: m.overview,
Expand Down Expand Up @@ -363,7 +278,10 @@ export const Draft: Form = buildForm({
title: '',
items: ({ answers }) => {
return (answers.constituency as string[]).map((c: string) => ({
heading: 'Flokkur 1 - ' + c.split('|')[1],
heading:
getValueViaPath(answers, 'list.name') +
' - ' +
c.split('|')[1],
progressMeter: {
currentProgress: 0,
maxProgress: 350,
Expand All @@ -372,68 +290,6 @@ export const Draft: Form = buildForm({
}))
},
}),
/*buildDescriptionField({
id: 'space4',
title: '',
space: 'gutter',
}),
buildDescriptionField({
id: 'managersHeader',
title: m.managers,
titleVariant: 'h3',
space: 'gutter',
marginBottom: 3,
condition: (answers) =>
!!(answers.managers as Array<Manager>)?.length,
}),
buildKeyValueField({
label: '',
width: 'full',
value: ({ answers }) => {
return (answers.managers as Array<Manager>)
.map(
(m: Manager) =>
m.manager.name +
' - ' +
formatNationalId(m.manager.nationalId) +
' - ' +
m.constituency,
)
.join('\n')
},
}),
buildDescriptionField({
id: 'space5',
title: '',
space: 'gutter',
}),
buildDescriptionField({
id: 'supervisorsHeader',
title: m.supervisors,
titleVariant: 'h3',
space: 'gutter',
marginBottom: 3,
condition: (answers) =>
!!(answers.supervisors as Array<Supervisor>)?.length,
}),
buildKeyValueField({
label: '',
width: 'full',
value: ({ answers }) => {
return (answers.supervisors as Array<Supervisor>)
.map(
(s: Supervisor) =>
s.supervisor.name +
' - ' +
formatNationalId(s.supervisor.nationalId) +
' - ' +
(s.constituency as unknown as string[])
.map((c) => c.split('|')[1])
.join(', '),
)
.join('\n')
},
}),*/
buildSubmitField({
id: 'submit',
placement: 'footer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ export const m = defineMessages({
defaultMessage: 'Umsjónaraðilar',
description: '',
},
noSupervisors: {
id: 'sp.signatureCollection:noSupervisors',
defaultMessage: 'Enginn umsjónaraðili skráður',
description: '',
},
supervisorsTooltip: {
id: 'sp.signatureCollection:supervisorsTooltip',
defaultMessage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ import { formatNationalId } from '@island.is/portals/core'

const OwnerView = ({
currentCollection,
// list holder is an individual who owns a list or has a delegation of type Procuration Holder
isListHolder,
}: {
currentCollection: SignatureCollection
isListHolder: boolean
}) => {
const navigate = useNavigate()
const location = useLocation()
Expand Down Expand Up @@ -80,7 +83,8 @@ const OwnerView = ({
color="blue400"
/>
</Text>
{!loadingOwnerLists &&
{isListHolder &&
!loadingOwnerLists &&
listsForOwner?.length < currentCollection?.areas.length && (
<AddConstituency
lists={listsForOwner}
Expand Down Expand Up @@ -126,7 +130,7 @@ const OwnerView = ({
: undefined
}
tag={
list.active
list.active && isListHolder
? {
label: 'Cancel collection',
renderTag: () => (
Expand Down Expand Up @@ -168,10 +172,12 @@ const OwnerView = ({
/>
),
}
: {
: !list.active
? {
label: formatMessage(m.listSubmitted),
variant: 'blueberry',
}
: undefined
}
/>
</Box>
Expand Down Expand Up @@ -211,13 +217,15 @@ const OwnerView = ({
<CollectorSkeleton />
</T.Data>
</T.Row>
) : (
) : collectors.length ? (
collectors.map((collector) => (
<T.Row key={collector.nationalId}>
<T.Data width={'35%'}>{collector.name}</T.Data>
<T.Data>{formatNationalId(collector.nationalId)}</T.Data>
</T.Row>
))
) : (
<Text marginTop={2}>{formatMessage(m.noSupervisors)}</Text>
)}
</T.Body>
</T.Table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import { m } from '../../lib/messages'
import OwnerView from './OwnerView'
import SigneeView from '../shared/SigneeView'
import { useGetCurrentCollection, useIsOwner } from '../../hooks'
import { useUserInfo } from '@island.is/auth/react'
import { AuthDelegationType } from '../../types/schema'

const SignatureListsParliamentary = () => {
useNamespaces('sp.signatureCollection')
const { formatMessage } = useLocale()

const { isOwner, loadingIsOwner } = useIsOwner()
const userInfo = useUserInfo()
const { currentCollection, loadingCurrentCollection } =
useGetCurrentCollection()

Expand All @@ -30,7 +33,15 @@ const SignatureListsParliamentary = () => {
<Box>
{!currentCollection?.isPresidential ? (
isOwner.success ? (
<OwnerView currentCollection={currentCollection} />
<OwnerView
currentCollection={currentCollection}
isListHolder={
!userInfo?.profile?.delegationType ||
userInfo?.profile?.delegationType?.includes(
AuthDelegationType.ProcurationHolder,
)
}
/>
albinagu marked this conversation as resolved.
Show resolved Hide resolved
) : (
<SigneeView currentCollection={currentCollection} />
)
Expand Down