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

As a user I want to select a template to issue a certified copy with #7727

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from
Draft
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
16 changes: 11 additions & 5 deletions packages/client/src/declarations/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import { IDeclaration, IDeclarationsState } from '@client/declarations/index'
import { IStoreState } from '@client/store'
import { useSelector } from 'react-redux'

export const getDraftsState = (store: IStoreState): IDeclarationsState =>
store.declarationsState
export const getDraftsState = (store: IStoreState): IDeclarationsState => {
return store.declarationsState
}

function getKey<K extends keyof IDeclarationsState>(
store: IStoreState,
Expand All @@ -29,11 +30,16 @@ export const getInitialDeclarationsLoaded = (

export const selectDeclaration =
<T extends IDeclaration | undefined>(declarationId: string) =>
(store: IStoreState) =>
getKey(store, 'declarations').find(({ id }) => declarationId === id) as T
(store: IStoreState) => {
const bar = getKey(store, 'declarations').find(
({ id }) => declarationId === id
) as T
return bar
}

export const useDeclaration = <T extends IDeclaration | undefined>(
declarationId: string
) => {
return useSelector(selectDeclaration<T>(declarationId))
const foo = useSelector(selectDeclaration<T>(declarationId))
return foo
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { identityHelperTextMapper, identityNameMapper } from './messages'
import { Event } from '@client/utils/gateway'
import { IDeclaration } from '@client/declarations'
import { issueMessages } from '@client/i18n/messages/issueCertificate'
import { ICertificateConfigData } from '@client/utils/referenceApi'

interface INameField {
firstNamesField: string
Expand Down Expand Up @@ -1012,7 +1013,8 @@ const marriageIssueCollectorFormOptions = [
]

function getCertCollectorGroupForEvent(
declaration: IDeclaration
declaration: IDeclaration,
certificates?: ICertificateConfigData[]
): IFormSectionGroup {
const informant = (declaration.data.informant.otherInformantType ||
declaration.data.informant.informantType) as string
Expand All @@ -1039,7 +1041,14 @@ function getCertCollectorGroupForEvent(
birthCertCollectorOptions,
marriageCertCollectorOptions
)

const certificateTemplateOptions =
certificates
?.filter((x) => x.event === declaration.event)
.map((x) => ({ label: x.label, value: x.id })) || []
const certTemplateDefaultValue =
certificateTemplateOptions.length > 0
? certificateTemplateOptions[0].value
: ''
return {
id: 'certCollector',
title: certificateMessages.whoToCollect,
Expand All @@ -1055,21 +1064,31 @@ function getCertCollectorGroupForEvent(
initialValue: '',
validator: [],
options: finalOptions
},
{
name: 'certTemplateId',
type: 'SELECT_WITH_OPTIONS',
label: certificateMessages.certificateTemplateSelectLabel,
required: true,
initialValue: certTemplateDefaultValue,
validator: [],
options: certificateTemplateOptions
}
]
}
}

export function getCertificateCollectorFormSection(
declaration: IDeclaration
declaration: IDeclaration,
certificates?: ICertificateConfigData[]
): IFormSection {
return {
id: CertificateSection.Collector,
viewType: 'form',
name: certificateMessages.printCertificate,
title: certificateMessages.certificateCollectionTitle,
groups: [
getCertCollectorGroupForEvent(declaration),
getCertCollectorGroupForEvent(declaration, certificates),
otherCertCollectorFormGroup(declaration.event),
affidavitCertCollectorGroup
]
Expand Down
6 changes: 6 additions & 0 deletions packages/client/src/i18n/messages/views/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface ICertificateMessages
extends Record<string | number | symbol, MessageDescriptor> {
certificateCollectionTitle: MessageDescriptor
addAnotherSignature: MessageDescriptor
certificateTemplateSelectLabel: MessageDescriptor
certificateConfirmationTxt: MessageDescriptor
certificateIsCorrect: MessageDescriptor
certificateReceiptHeader: MessageDescriptor
Expand Down Expand Up @@ -95,6 +96,11 @@ const messagesToDefine: ICertificateMessages = {
description: 'The title of print certificate action',
id: 'print.certificate.section.title'
},
certificateTemplateSelectLabel: {
defaultMessage: 'Select certificate template',
description: 'The title of select certificate template action',
id: 'certificate.selectTemplate'
},
certificateConfirmationTxt: {
defaultMessage: 'Edit',
description: 'Edit',
Expand Down
31 changes: 17 additions & 14 deletions packages/client/src/navigation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ export function goToBirthRegistrationAsParent(declarationId: string) {

export function goToPrintCertificate(
registrationId: string,
event: string,
certTemplateId: string,
groupId?: string
) {
return push(
formatUrl(CERTIFICATE_COLLECTOR, {
registrationId: registrationId.toString(),
eventType: event.toLowerCase().toString(),
registrationId,
certTemplateId,
groupId: groupId || 'certCollector'
})
)
Expand Down Expand Up @@ -360,50 +360,53 @@ export function goToVerifyCorrector(declarationId: string, corrector: string) {
)
}

export function goToReviewCertificate(registrationId: string, event: Event) {
export function goToReviewCertificate(
registrationId: string,
certTemplateId: string
) {
return push(
formatUrl(REVIEW_CERTIFICATE, {
registrationId: registrationId.toString(),
eventType: event
registrationId,
certTemplateId
}),
{ isNavigatedInsideApp: true }
)
}

export function goToVerifyCollector(
registrationId: string,
event: string,
certTemplateId: string,
collector: string
) {
return push(
formatUrl(VERIFY_COLLECTOR, {
registrationId: registrationId.toString(),
eventType: event.toLowerCase().toString(),
certTemplateId: certTemplateId.toLowerCase().toString(),
collector: collector.toLowerCase().toString()
})
)
}

export function goToPrintCertificatePayment(
registrationId: string,
event: Event
certTemplateId: string
) {
return push(
formatUrl(PRINT_CERTIFICATE_PAYMENT, {
registrationId: registrationId.toString(),
eventType: event
registrationId,
certTemplateId
})
)
}

export function goToIssueCertificatePayment(
registrationId: string,
event: Event
certTemplateId: string
) {
return push(
formatUrl(ISSUE_CERTIFICATE_PAYMENT, {
registrationId: registrationId.toString(),
eventType: event
registrationId,
certTemplateId
})
)
}
Expand Down
10 changes: 5 additions & 5 deletions packages/client/src/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ export const VERIFY_CORRECTOR = '/correction/:declarationId/verify/:corrector'
export const SEARCH = '/search'
export const SEARCH_RESULT = '/search-result'
export const CERTIFICATE_COLLECTOR =
'/cert/collector/:registrationId/:eventType/:groupId'
'/cert/collector/:registrationId/:certTemplateId/:groupId'
export const ISSUE_COLLECTOR = '/issue/:registrationId/:pageId'
export const ISSUE_VERIFY_COLLECTOR =
'/issue/check/:registrationId/:eventType/:collector'
export const VERIFY_COLLECTOR =
'/print/check/:registrationId/:eventType/:collector'
export const REVIEW_CERTIFICATE = '/review/:registrationId/:eventType'
'/print/check/:registrationId/:certTemplateId/:collector'
export const REVIEW_CERTIFICATE = '/review/:registrationId/:certTemplateId'

export const PRINT_CERTIFICATE_PAYMENT =
'/print/payment/:registrationId/:eventType'
'/print/payment/:registrationId/:certTemplateId'
export const ISSUE_CERTIFICATE_PAYMENT =
'/issue/payment/:registrationId/:eventType'
'/issue/payment/:registrationId/:certTemplateId'

export const REGISTRAR_HOME = '/registration-home'
export const REGISTRAR_HOME_TAB = '/registration-home/:tabId/:selectorId?'
Expand Down
33 changes: 1 addition & 32 deletions packages/client/src/offline/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import {
LoadFormsResponse,
LoadValidatorsResponse,
LoadConditionalsResponse,
LoadHandlebarHelpersResponse,
CertificateConfiguration
LoadHandlebarHelpersResponse
} from '@client/utils/referenceApi'
import { System } from '@client/utils/gateway'
import { UserDetails } from '@client/utils/userUtils'
Expand Down Expand Up @@ -116,20 +115,6 @@ type CertificateLoadFailedAction = {
payload: Error
}

export const CERTIFICATE_CONFIGURATION_LOADED =
'OFFLINE/CERTIFICATE_CONFIGURATION_LOADED'
type CertificateConfigurationLoadedAction = {
type: typeof CERTIFICATE_CONFIGURATION_LOADED
payload: CertificateConfiguration
}

export const CERTIFICATE_CONFIGURATION_LOAD_FAILED =
'OFFLINE/CERTIFICATE_CONFIGURATION_LOAD_FAILED'
type CertificateConfigurationLoadFailedAction = {
type: typeof CERTIFICATE_CONFIGURATION_LOAD_FAILED
payload: Error
}

export const UPDATE_OFFLINE_CONFIG = 'OFFLINE/UPDATE_OFFLINE_CONFIG' as const
type ApplicationConfigUpdatedAction = {
type: typeof UPDATE_OFFLINE_CONFIG
Expand Down Expand Up @@ -274,20 +259,6 @@ export const certificateLoadFailed = (
payload
})

export const certificateConfigurationLoaded = (
payload: CertificateConfiguration
): CertificateConfigurationLoadedAction => ({
type: CERTIFICATE_CONFIGURATION_LOADED,
payload
})

export const certificateConfigurationLoadFailed = (
payload: CertificateConfigurationLoadFailedAction['payload']
): CertificateConfigurationLoadFailedAction => ({
type: CERTIFICATE_CONFIGURATION_LOAD_FAILED,
payload
})

export const configFailed = (error: Error): ApplicationConfigFailedAction => ({
type: APPLICATION_CONFIG_FAILED,
payload: error
Expand Down Expand Up @@ -362,8 +333,6 @@ export type Action =
| ApplicationConfigFailedAction
| ApplicationConfigUpdatedAction
| CertificateLoadFailedAction
| CertificateConfigurationLoadedAction
| CertificateConfigurationLoadFailedAction
| UpdateOfflineSystemsAction
| IFilterLocationsAction
| ReturnType<typeof offlineDataReady>
Expand Down
Loading
Loading