/
index.tsx
152 lines (146 loc) · 5.14 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import React from "react";
import { Form, Field } from "react-final-form";
import { Container } from "../../../../styles/bases";
import { Margin } from "../../../../styles/utils";
import { RouteComponentProps, withRouter } from "react-router-dom";
import { AppPath } from "../../../../constant/appPath";
import {
Breadcrumb,
Row,
Col,
TextField,
Checkbox,
Button,
FieldError
} from "../../../lib";
import { StepLoanOfferWrapper } from "../styled";
import {
requiredField,
emailFormat,
composeValidators
} from "../../../../constant/validation";
import createDecorator from "final-form-focus";
import FormIllustration from "../../../../images/illustration/form.svg";
interface PersonalInfoProps extends RouteComponentProps<any> {}
const focusOnErrors = createDecorator();
const bredcrumbData = [
{ title: " Personal information", active: true },
{ title: "Detail amount", active: false }
];
class PersonalInfo extends React.Component<PersonalInfoProps, {}> {
constructor(props: PersonalInfoProps) {
super(props);
this.onSubmit = this.onSubmit.bind(this);
}
onSubmit = (data: any) => {
const { history } = this.props;
console.log(data);
history.push(AppPath.LoanOfferAmount);
};
render() {
const { history } = this.props;
return (
<StepLoanOfferWrapper>
<Container>
<Row>
<Col lg={6} md={12}>
<h4>One step closer to helping Ines!</h4>
<p>
For starters, please let us know your name and email address.
</p>
<Form
onSubmit={this.onSubmit}
decorators={[focusOnErrors]}
render={({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Margin top={24} bottom={48}>
<Breadcrumb data={bredcrumbData} />
</Margin>
<Margin bottom={32}>
<Field
name="name"
validate={requiredField}
render={({ input, meta }) => (
<React.Fragment>
<TextField
label="Name"
placeholder="Enter your name"
autoFocus={true}
{...input}
{...meta}
/>
{meta.touched && meta.error && (
<FieldError>{meta.error}</FieldError>
)}
</React.Fragment>
)}
/>
<Margin top={16}>
<Checkbox
id="anonymous"
name="anonymous"
label="Stay anonymous"
/>
</Margin>
</Margin>
<Margin bottom={32}>
<Field
name="email"
validate={composeValidators(requiredField, emailFormat)}
render={({ input, meta }) => (
<React.Fragment>
<TextField
type="email"
label="Email"
placeholder="Enter your email"
{...input}
{...meta}
/>
{meta.touched && meta.error && (
<FieldError>{meta.error}</FieldError>
)}
</React.Fragment>
)}
/>
</Margin>
<Margin vertical={32}>
<Checkbox
id="videoInterview"
name="videoInterview"
label="I would like to have a video interview with the borrower"
/>
</Margin>
<Row>
<Col lg={6} md={12}>
<Margin top={8}>
<Button onClick={() => history.push(AppPath.home)}>
Back
</Button>
</Margin>
</Col>
<Col lg={6} md={12}>
<Margin top={8}>
<Button type="submit" color="purple">
Continue
</Button>
</Margin>
</Col>
</Row>
</form>
)}
/>
</Col>
<Col lg={6} md="hidden" text="center">
<img
src={FormIllustration}
alt="Form - Illustraion"
width={340}
/>
</Col>
</Row>
</Container>
</StepLoanOfferWrapper>
);
}
}
export default withRouter<PersonalInfoProps>(PersonalInfo);