Skip to content

Commit

Permalink
fix: #49 break change on aml checklist and lifetime legal (#237)
Browse files Browse the repository at this point in the history
* fix: #49 break change on aml checklist and lifetime legal

* fix: pipeline error on demo site
  • Loading branch information
duong-se authored Feb 11, 2020
1 parent 4a7abeb commit a827105
Show file tree
Hide file tree
Showing 34 changed files with 368 additions and 490 deletions.
2 changes: 1 addition & 1 deletion packages/aml-checklist/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
snapshotSerializers: ['enzyme-to-json/serializer'],
coverageThreshold: {
global: {
branches: 62,
branches: 59,
functions: 73,
lines: 85,
statements: 85
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ exports[`Identification renderFormHandler should match snapshot when DISABLED fa
/>
<Component
allowClear={true}
id="fileUrl"
id="documentId"
inputProps={
Object {
"disabled": false,
}
}
labelText="Upload File"
name="fileUrl"
name="documentId"
required={true}
/>
<div
Expand Down Expand Up @@ -134,14 +134,14 @@ exports[`Identification renderFormHandler should match snapshot when DISABLED tr
/>
<Component
allowClear={true}
id="fileUrl"
id="documentId"
inputProps={
Object {
"disabled": true,
}
}
labelText="Upload File"
name="fileUrl"
name="documentId"
required={true}
/>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import SelectIdentity from '@/components/ui/inputs/select-identity'
import styles from '@/styles/pages/checklist-detail.scss?mod'

export interface IdentityDocumentForm extends IdentityDocumentModel {
fileUrl: string
documentId: string
}

export const IDENTIFICATION_FORM_DEFAULT_VALUES: IdentityDocumentForm = {
typeId: '',
details: '',
expiry: '',
fileUrl: '',
documentId: '',
}

export type IdentificationProps = {
Expand Down Expand Up @@ -43,8 +43,8 @@ export const renderFormHandler = ({
<Input id="details" name="details" type="text" placeholder="ID Reference" required labelText="ID Reference" />
<DatePicker id="expiry" name="expiry" labelText="Expiry Date" required />
<CameraImageInput
id="fileUrl"
name="fileUrl"
id="documentId"
name="documentId"
labelText="Upload File"
allowClear={true}
inputProps={{ disabled: disabled }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ exports[`AddressInformation AddressInput should render correctly 1`] = `
type="text"
/>
<Component
id="metadata.addresses[0][year]"
id="metadata.primaryAddress[year]"
labelText="Number of Years at Address"
name="metadata.addresses[0][year]"
name="metadata.primaryAddress[year]"
options={
Array [
Object {
Expand Down Expand Up @@ -466,9 +466,9 @@ exports[`AddressInformation AddressInput should render correctly 1`] = `
required={true}
/>
<Component
id="metadata.addresses[0][month]"
id="metadata.primaryAddress[month]"
labelText="Number of Months at Address"
name="metadata.addresses[0][month]"
name="metadata.primaryAddress[month]"
options={
Array [
Object {
Expand Down Expand Up @@ -524,9 +524,9 @@ exports[`AddressInformation AddressInput should render correctly 1`] = `
required={true}
/>
<Component
id="metadata.addresses[0][documentType]"
id="metadata.primaryAddress[documentType]"
labelText="Document Type"
name="metadata.addresses[0][documentType]"
name="metadata.primaryAddress[documentType]"
options={
Array [
Object {
Expand Down Expand Up @@ -595,9 +595,9 @@ exports[`AddressInformation AddressInput should render correctly 1`] = `
/>
<Component
allowClear={true}
id="metadata.addresses[0][documentImage]"
id="metadata.primaryAddress[documentImage]"
labelText="Upload file"
name="metadata.addresses[0][documentImage]"
name="metadata.primaryAddress[documentImage]"
required={true}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('PrimaryIdentification', () => {
typeId: idCheck.identityDocument1?.typeId,
details: idCheck.identityDocument1?.details,
expiry: new Date(idCheck.identityDocument1?.expiry as string),
fileUrl: (idCheck.metadata as any).primaryIdUrl || '',
documentId: 'SOME_ID',
},
}
expect(result).toEqual(expected)
Expand All @@ -60,7 +60,7 @@ describe('PrimaryIdentification', () => {
initFormValues: {
details: '',
expiry: '',
fileUrl: '',
documentId: '',
typeId: '',
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('SecondaryIdentification', () => {
typeId: idCheck.identityDocument2?.typeId,
details: idCheck.identityDocument2?.details,
expiry: new Date(idCheck.identityDocument2?.expiry as string),
documentId: 'SOME_ID',
},
}
expect(result).toEqual(expected)
Expand All @@ -59,7 +60,7 @@ describe('SecondaryIdentification', () => {
initFormValues: {
details: '',
expiry: '',
fileUrl: '',
documentId: '',
typeId: '',
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export const handleMoreThreeYear = ({ setShowMoreThreeYearInput, isShowMoreThree
}

export const AddressInput = ({ addressType }) => {
// To get/set from metadata
const addressMetadataIndex = addressType === 'primaryAddress' ? 0 : 1
return (
<div key={addressType}>
<Input type="hidden" labelText="Type" id={`${addressType}[type]`} name={`${addressType}[type]`} />
Expand Down Expand Up @@ -91,28 +89,28 @@ export const AddressInput = ({ addressType }) => {
<SelectBox
labelText="Number of Years at Address"
options={renderYearOptions()}
id={`metadata.addresses[${addressMetadataIndex}][year]`}
name={`metadata.addresses[${addressMetadataIndex}][year]`}
id={`metadata.${addressType}[year]`}
name={`metadata.${addressType}[year]`}
required
/>
<SelectBox
labelText="Number of Months at Address"
id={`metadata.addresses[${addressMetadataIndex}][month]`}
name={`metadata.addresses[${addressMetadataIndex}][month]`}
id={`metadata.${addressType}[month]`}
name={`metadata.${addressType}[month]`}
options={optionsMonth}
required
/>
<SelectBox
labelText="Document Type"
id={`metadata.addresses[${addressMetadataIndex}][documentType]`}
name={`metadata.addresses[${addressMetadataIndex}][documentType]`}
id={`metadata.${addressType}[documentType]`}
name={`metadata.${addressType}[documentType]`}
options={optionsDocumentType}
required
/>
<CameraImageInput
labelText="Upload file"
id={`metadata.addresses[${addressMetadataIndex}][documentImage]`}
name={`metadata.addresses[${addressMetadataIndex}][documentImage]`}
id={`metadata.${addressType}[documentImage]`}
name={`metadata.${addressType}[documentImage]`}
allowClear={true}
required
/>
Expand Down Expand Up @@ -201,17 +199,14 @@ export const AddressInformation: React.FC<AddressInformationProps> = ({
}) => {
const [isShowMoreThreeYearInput, setShowMoreThreeYearInput] = React.useState(false)
const { primaryAddress, secondaryAddress } = contact
const metadata = contact.metadata || {
addresses: generateMetadata(secondaryAddress),
}

return (
<div>
<Formik
initialValues={{
primaryAddress,
secondaryAddress,
metadata,
metadata: contact.metadata,
}}
onSubmit={onHandleSubmit}
>
Expand Down Expand Up @@ -249,6 +244,7 @@ export type DispatchProps = {
export const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => {
return {
onHandleSubmit: (values: any) => {
console.log({ values })
dispatch(updateAddressHistory({ contact: values }))
},
onNextHandler: (values: any) => () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
selectCheckListDetailIsSubmitting,
} from '@/selectors/checklist-detail'
import { ContactModel } from '@reapit/foundations-ts-definitions'
import { selectCheckListDetailPrimaryIdUrl } from '../../../selectors/checklist-detail'

export type PrimaryIdentiticationProps = DispatchProps & StateProps

Expand Down Expand Up @@ -46,18 +45,17 @@ export const mapStateToProps = (state: ReduxState): StateProps => {
const isSubmitting = selectCheckListDetailIsSubmitting(state)
const contact = selectCheckListDetailContact(state)
const primaryIdDocument = selectCheckListDetailPrimaryId(state)
const primaryIdUrl = selectCheckListDetailPrimaryIdUrl(state)

let initFormValues = IDENTIFICATION_FORM_DEFAULT_VALUES
const DEFAULT_TYPE = ''
if (primaryIdDocument) {
const { typeId, expiry, details } = primaryIdDocument
const { typeId, expiry, details, documentId } = primaryIdDocument

initFormValues = {
typeId: typeId || DEFAULT_TYPE,
expiry: expiry ? new Date(expiry) : '',
details: details,
fileUrl: primaryIdUrl || '',
details: details || '',
documentId: documentId || '',
} as IdentityDocumentForm
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
selectCheckListDetailContact,
selectCheckListDetailSecondaryId,
selectCheckListDetailIsSubmitting,
selectCheckListDetailSecondaryIdUrl,
selectCheckListDetailIdCheck,
} from '@/selectors/checklist-detail'
import { IdentityDocumentModel, ContactModel, IdentityCheckModel } from '@reapit/foundations-ts-definitions'
Expand Down Expand Up @@ -52,20 +51,19 @@ export const mapStateToProps = (state: ReduxState): StateProps => {
const isSubmitting = selectCheckListDetailIsSubmitting(state)
const contact = selectCheckListDetailContact(state)
const secondaryIdDocument = selectCheckListDetailSecondaryId(state)
const secondaryIdUrl = selectCheckListDetailSecondaryIdUrl(state)
const idCheck = selectCheckListDetailIdCheck(state)

let initFormValues = IDENTIFICATION_FORM_DEFAULT_VALUES
const DEFAULT_TYPE = ''

if (secondaryIdDocument) {
const { typeId, expiry, details } = secondaryIdDocument
const { typeId, expiry, details, documentId } = secondaryIdDocument

initFormValues = {
typeId: typeId || DEFAULT_TYPE,
expiry: expiry ? new Date(expiry) : undefined,
details: details,
fileUrl: secondaryIdUrl,
details: details || '',
documentId: documentId || '',
} as IdentityDocumentForm
}

Expand Down
25 changes: 24 additions & 1 deletion packages/aml-checklist/src/sagas/__stubs__/id-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,30 @@ export const idCheck: IdentityCheckModel = {
expiry: '2019-12-21',
details: 'a',
},
metadata: {},
metadata: {
secondaryAddress: {
year: '7',
month: '5',
documentType: 'Recent Utility Bill – Gas, Electricity, Water, Telephone (Not mobile phones)',
documentImage:
'https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/BED14000165-secondary-address-id(1).png',
},
primaryAddress: {
documentType: 'Current Full UK Driving Licence',
month: '6',
year: '10',
documentImage:
'https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/BED14000165-primary-address-id(1).png',
},
declarationRisk: {
reason: '123',
type: 'Simplified',
declarationForm:
'https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/declaration-Simplified-123(1).png',
riskAssessmentForm:
'https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/riskAssessment-Simplified-123(1).png',
},
},
_eTag: '"51F8EECB09FB89903C42CAB63E3D5D0C"',
_links: {
self: {
Expand Down
Loading

0 comments on commit a827105

Please sign in to comment.