Skip to content

Commit

Permalink
tweak - create list
Browse files Browse the repository at this point in the history
  • Loading branch information
albina committed Oct 15, 2024
1 parent 1a076f7 commit 407969b
Showing 1 changed file with 8 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ import {
buildPhoneField,
buildSection,
buildSubmitField,
buildTableRepeaterField,
buildTextField,
getValueViaPath,
} from '@island.is/application/core'
import { DefaultEvents, Form, FormModes } from '@island.is/application/types'
import { Application, UserProfile } from '@island.is/api/schema'
import {
Application,
UserProfile,
} from '@island.is/api/schema'
import { format as formatNationalId } from 'kennitala'
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 +176,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 +281,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 +293,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

0 comments on commit 407969b

Please sign in to comment.