Skip to content

Commit

Permalink
refactored collector form as per design
Browse files Browse the repository at this point in the history
  • Loading branch information
tareq89 committed Oct 31, 2024
1 parent 3193159 commit 04a5535
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ const marriageIssueCollectorFormOptions = [

function getCertCollectorGroupForEvent(
declaration: IDeclaration,
certificates?: ICertificateConfigData[]
certificates: ICertificateConfigData[]
): IFormSectionGroup {
const informant = (declaration.data.informant.otherInformantType ||
declaration.data.informant.informantType) as string
Expand Down Expand Up @@ -1043,14 +1043,23 @@ function getCertCollectorGroupForEvent(
)
const certificateTemplateOptions =
certificates
?.filter((x) => x.event === declaration.event)
.filter((x) => x.event === declaration.event)
.map((x) => ({ label: x.label, value: x.id })) || []
const certTemplateDefaultValue = certificates?.find((x) => x.isDefault)?.id
const certTemplateDefaultValue = certificates.find((x) => x.isDefault)?.id
return {
id: 'certCollector',
title: certificateMessages.whoToCollect,
error: certificateMessages.certificateCollectorError,
fields: [
{
name: 'certificateTemplateId',
type: 'SELECT_WITH_OPTIONS',
label: certificateMessages.certificateTemplateSelectLabel,
required: true,
initialValue: certTemplateDefaultValue,
validator: [],
options: certificateTemplateOptions
},
{
name: 'type',
type: RADIO_GROUP,
Expand All @@ -1061,23 +1070,14 @@ function getCertCollectorGroupForEvent(
initialValue: '',
validator: [],
options: finalOptions
},
{
name: 'certificateTemplateId',
type: 'SELECT_WITH_OPTIONS',
label: certificateMessages.certificateTemplateSelectLabel,
required: true,
initialValue: certTemplateDefaultValue,
validator: [],
options: certificateTemplateOptions
}
]
}
}

export function getCertificateCollectorFormSection(
declaration: IDeclaration,
certificates?: ICertificateConfigData[]
certificates: ICertificateConfigData[]
): IFormSection {
return {
id: CertificateSection.Collector,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/i18n/messages/views/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const messagesToDefine: ICertificateMessages = {
id: 'print.certificate.section.title'
},
certificateTemplateSelectLabel: {
defaultMessage: 'Select certificate template',
defaultMessage: 'Type',
description: 'The title of select certificate template action',
id: 'certificate.selectTemplate'
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ const mapStateToProps = (
const registeringOfficeId = getRegisteringOfficeId(declaration)
const certFormSection = getCertificateCollectorFormSection(
declaration,
state.offline.offlineData.templates?.certificates
state.offline.offlineData.templates?.certificates || []
)

const isAllowPrintInAdvance =
Expand Down

0 comments on commit 04a5535

Please sign in to comment.