Skip to content

Commit

Permalink
[WIP] fix: #52 AML app add etag and fix breaking changes (#219)
Browse files Browse the repository at this point in the history
* fix: #52 [wip] fix breaking changes

* fix: #52 [wip] fix breaking changes

* fix: tests pass

Co-authored-by: Will McVay <[email protected]>
  • Loading branch information
vuhuucuong and willmcvay authored Feb 10, 2020
1 parent c723b6e commit 0fbf574
Show file tree
Hide file tree
Showing 57 changed files with 11,142 additions and 838 deletions.
5 changes: 3 additions & 2 deletions packages/aml-checklist/src/actions/checklist-detail.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ContactModel, IdentityCheckModel, IdentityDocumentModel } from '@reapit/foundations-ts-definitions'
import { ContactModel, IdentityCheckModel } from '@reapit/foundations-ts-definitions'
import { actionCreator } from '../utils/actions'
import ActionTypes from '../constants/action-types'
import { DynamicLinkParams } from '@reapit/elements'
import { IdentityDocumentForm } from '../components/ui/forms/identification'

export const checklistDetailRequestData = actionCreator<string>(ActionTypes.CHECKLIST_DETAIL_REQUEST_DATA)

Expand Down Expand Up @@ -31,7 +32,7 @@ export const pepSearchResult = actionCreator<any>(ActionTypes.CHECKLIST_DETAIL_S

export type UpdateIdentityCheckParams = {
nextSection?: string
identityChecks: IdentityDocumentModel
identityChecks: IdentityDocumentForm
}

export const checklistDetailPrimaryIdUpdateData = actionCreator<UpdateIdentityCheckParams>(
Expand Down
3 changes: 2 additions & 1 deletion packages/aml-checklist/src/components/pages/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ export const generateColumns = history => () => {
const addressKeys = ['buildingName', 'buildingNumber', 'line1', 'line2']
const filteredAddressEntries = Object.entries(primaryAddress)
.filter(([key, value]) => addressKeys.includes(key) && value)
.map(([value]) => value)
.map(([, value]) => value)
.join(', ')

return (
<div>
<span>{filteredAddressEntries}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ exports[`AMLProgressBar AMLProgressBar should match snapshot 1`] = `
dynamicLinkParams={
Object {
"appMode": "WEB",
"entityCode": "MKC13000122",
"entityCode": "AYL19000001",
"entityType": "contacts",
}
}
>
Msss Holly Rees
Mrs H Phillips
</Component>
</Component>
<Component />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports[`Identification renderFormHandler should match snapshot when DISABLED fa
<span
className="ml-1"
>
MKC13000122
AYL19000001
</span>
</div>
</div>
Expand Down Expand Up @@ -162,7 +162,7 @@ exports[`Identification renderFormHandler should match snapshot when DISABLED tr
<span
className="ml-1"
>
MKC13000122
AYL19000001
</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import React from 'react'
import { shallow } from 'enzyme'
import { contact } from '@/sagas/__stubs__/contact'
import Identification, { renderFormHandler, onSubmitHandler } from '../identification'
import { IdentificationProps, IDENTIFICATION_FORM_DEFAULT_VALUES } from '../identification'

describe('Identification', () => {
describe('renderFormHandler', () => {
it('should match snapshot when DISABLED true', () => {
const mockProps = {
contact: contact,
initFormValues: IDENTIFICATION_FORM_DEFAULT_VALUES,
loading: false,
disabled: true,
onNextHandler: jest.fn(),
onPrevHandler: jest.fn(),
}
onSaveHandler: jest.fn(),
} as IdentificationProps
const component = renderFormHandler(mockProps)({ values: {} })
const wrapper = shallow(<div>{component}</div>)
expect(wrapper).toMatchSnapshot()
Expand All @@ -21,11 +24,13 @@ describe('Identification', () => {
it('should match snapshot when DISABLED false', () => {
const mockProps = {
contact: contact,
initFormValues: IDENTIFICATION_FORM_DEFAULT_VALUES,
loading: false,
disabled: false,
onNextHandler: jest.fn(),
onPrevHandler: jest.fn(),
}
onSaveHandler: jest.fn(),
} as IdentificationProps
const component = renderFormHandler(mockProps)({ values: {} })
const wrapper = shallow(<div>{component}</div>)
expect(wrapper).toMatchSnapshot()
Expand All @@ -35,8 +40,8 @@ describe('Identification', () => {
describe('onSubmitHandler', () => {
it('should run correctly', () => {
const mockOnSaveHandler = jest.fn()
onSubmitHandler(mockOnSaveHandler)({})
expect(mockOnSaveHandler).toBeCalledWith({})
onSubmitHandler(mockOnSaveHandler)(IDENTIFICATION_FORM_DEFAULT_VALUES)
expect(mockOnSaveHandler).toBeCalledWith(IDENTIFICATION_FORM_DEFAULT_VALUES)
})
})
describe('Identification', () => {
Expand Down
37 changes: 19 additions & 18 deletions packages/aml-checklist/src/components/ui/forms/identification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,34 @@ import { Button, Input, DatePicker, CameraImageInput, Formik, Form } from '@reap
import SelectIdentity from '@/components/ui/inputs/select-identity'
import styles from '@/styles/pages/checklist-detail.scss?mod'

export const IDENTIFICATION_FORM_DEFAULT_VALUES: IdentityDocumentModel = {
export interface IdentityDocumentForm extends IdentityDocumentModel {
fileUrl: string
}

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

export type IdentificationProps = {
contact: ContactModel | null
initFormValues: IdentityDocumentModel
initFormValues: IdentityDocumentForm
loading: boolean
disabled?: boolean
onSaveHandler: (values: any) => void
onNextHandler: (values: any) => () => void
onPrevHandler: () => void
}

export const renderFormHandler = ({ contact, loading, onNextHandler, onPrevHandler, disabled = false }) => ({
values,
}) => {
export const renderFormHandler = ({
contact,
loading,
onNextHandler,
onPrevHandler,
disabled = false,
}: IdentificationProps) => ({ values }) => {
const id = contact?.id || ''
return (
<>
Expand Down Expand Up @@ -69,21 +78,13 @@ export const renderFormHandler = ({ contact, loading, onNextHandler, onPrevHandl
)
}

export const onSubmitHandler = (onSaveHandler: (formValues: IdentityDocumentModel) => void) => (
formValues: IdentityDocumentModel,
export const onSubmitHandler = (onSaveHandler: (formValues: IdentityDocumentForm) => void) => (
formValues: IdentityDocumentForm,
) => onSaveHandler(formValues)

export const Identification: React.FC<IdentificationProps> = ({
loading,
contact,
disabled,
initFormValues,
onSaveHandler,
onNextHandler,
onPrevHandler,
}) => (
<Formik initialValues={initFormValues} onSubmit={onSubmitHandler(onSaveHandler)}>
{renderFormHandler({ contact, loading, onNextHandler, onPrevHandler, disabled })}
export const Identification: React.FC<IdentificationProps> = props => (
<Formik initialValues={props.initFormValues} onSubmit={onSubmitHandler(props.onSaveHandler)}>
{renderFormHandler(props)}
</Formik>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,48 +608,28 @@ exports[`AddressInformation should match snapshot 1`] = `
<Formik
initialValues={
Object {
"metadata": Object {
"addresses": Array [
Object {
"documentImage": "https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/home-12-Larch Cottage-LU7 0EP.png",
"documentType": "Bank / Building Society / Statement",
"month": "2",
"year": "2",
},
Object {
"documentImage": "https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/previous-7-Larch Cottage-LU7 0PX(1).jpg",
"documentType": "Credit Card Statements from main provider",
"month": "1",
"year": "3",
},
],
"declarationRisk": Object {
"reason": "Test",
"riskAssessmentForm": "https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/riskAssessment-Simplified-Test(1).png",
"type": "Simplified",
},
},
"metadata": Object {},
"primaryAddress": Object {
"buildingName": "Larch Cottage",
"buildingNumber": "12",
"buildingName": "aa",
"buildingNumber": "37",
"countryId": "GB",
"line1": "High Street North",
"line2": "Stewkley",
"line3": "Leighton Buzzard",
"line4": "Buckinghamshire",
"postcode": "LU7 0EP",
"type": "home",
"line1": "Kingsway Place",
"line2": "London",
"line3": "a",
"line4": "a",
"postcode": "EC1R 0LU",
"type": "primary",
},
"secondaryAddress": Object {
"buildingName": "Larch Cottage",
"buildingNumber": "7",
"countryId": "",
"line1": "Ledburn",
"line2": "Leighton Buzzard",
"line3": "Buckinghamshire",
"line4": "",
"postcode": "LU7 0PX",
"type": "previous",
"buildingName": "cuong",
"buildingNumber": "1",
"countryId": "GB",
"line1": "Line1",
"line2": "Line2",
"line3": "Line3",
"line4": "Line4",
"postcode": "EC1R 0LU",
"type": "secondary",
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,7 @@ exports[`DeclarationAndRiskAssessment should match snapshot 1`] = `
<Formik
initialValues={
Object {
"metadata": Object {
"addresses": Array [
Object {
"documentImage": "https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/home-12-Larch Cottage-LU7 0EP.png",
"documentType": "Bank / Building Society / Statement",
"month": "2",
"year": "2",
},
Object {
"documentImage": "https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/previous-7-Larch Cottage-LU7 0PX(1).jpg",
"documentType": "Credit Card Statements from main provider",
"month": "1",
"year": "3",
},
],
"declarationRisk": Object {
"reason": "Test",
"riskAssessmentForm": "https://reapit-dev-app-store-media.s3.eu-west-2.amazonaws.com/riskAssessment-Simplified-Test(1).png",
"type": "Simplified",
},
},
"metadata": Object {},
}
}
onSubmit={[MockFunction]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`pep-search PepSearch should match snapshot 1`] = `
<Formik
initialValues={
Object {
"name": "Holly Rees",
"name": "H Phillips",
}
}
onSubmit={[MockFunction]}
Expand Down
Loading

0 comments on commit 0fbf574

Please sign in to comment.