Commit 2ea6d70aa1cf9e35a34a2953a4652108e1b9a2e3
1 parent
355f2411e0
Exists in
master
Added some comments and refactored imports
Showing
3 changed files
with
9 additions
and
8 deletions
Show diff stats
imports/client/views/core/Form.js
1 | import React, { Component, PropTypes } from 'react' | 1 | import React, { Component, PropTypes } from 'react' |
2 | import isEqual from 'lodash/isEqual' | 2 | import isEqual from 'lodash/isEqual' |
3 | import get from 'lodash/get' | 3 | import get from 'lodash/get' |
4 | import cloneDeep from 'lodash/cloneDeep' | 4 | import cloneDeep from 'lodash/cloneDeep' |
5 | import set from 'lodash/set' | 5 | import set from 'lodash/set' |
6 | 6 | ||
7 | // github.com/smalldots | ||
7 | class Form extends Component { | 8 | class Form extends Component { |
8 | constructor(props) { | 9 | constructor(props) { |
9 | super(props) | 10 | super(props) |
10 | this.state = { | 11 | this.state = { |
11 | values: props.initialValues || {}, | 12 | values: props.initialValues || {}, |
12 | dirtyValues: [], | 13 | dirtyValues: [], |
13 | submitted: false | 14 | submitted: false |
14 | } | 15 | } |
15 | this.isPristine = this.isPristine.bind(this) | 16 | this.isPristine = this.isPristine.bind(this) |
16 | this.isDirty = this.isDirty.bind(this) | 17 | this.isDirty = this.isDirty.bind(this) |
17 | this.isSubmitted = this.isSubmitted.bind(this) | 18 | this.isSubmitted = this.isSubmitted.bind(this) |
18 | this.getValue = this.getValue.bind(this) | 19 | this.getValue = this.getValue.bind(this) |
19 | this.setValue = this.setValue.bind(this) | 20 | this.setValue = this.setValue.bind(this) |
20 | this.setPristine = this.setPristine.bind(this) | 21 | this.setPristine = this.setPristine.bind(this) |
21 | this.setDirty = this.setDirty.bind(this) | 22 | this.setDirty = this.setDirty.bind(this) |
22 | this.resetSubmitted = this.resetSubmitted.bind(this) | 23 | this.resetSubmitted = this.resetSubmitted.bind(this) |
23 | } | 24 | } |
24 | 25 | ||
25 | componentWillReceiveProps(nextProps) { | 26 | componentWillReceiveProps(nextProps) { |
26 | if (!isEqual(this.props.initialValues, nextProps.initialValues)) { | 27 | if (!isEqual(this.props.initialValues, nextProps.initialValues)) { |
27 | this.setState(prevState => ({ | 28 | this.setState(prevState => ({ |
28 | values: { ...nextProps.initialValues, ...prevState.values } | 29 | values: { ...nextProps.initialValues, ...prevState.values } |
29 | })) | 30 | })) |
30 | } | 31 | } |
31 | } | 32 | } |
32 | 33 | ||
33 | isPristine(path) { | 34 | isPristine(path) { |
34 | if (path) { | 35 | if (path) { |
35 | return !this.state.dirtyValues.find(dirtyValue => dirtyValue === path) | 36 | return !this.state.dirtyValues.find(dirtyValue => dirtyValue === path) |
36 | } | 37 | } |
37 | return !this.state.dirtyValues.length | 38 | return !this.state.dirtyValues.length |
38 | } | 39 | } |
39 | 40 | ||
40 | isDirty(path) { | 41 | isDirty(path) { |
41 | return !this.isPristine(path) | 42 | return !this.isPristine(path) |
42 | } | 43 | } |
43 | 44 | ||
44 | isSubmitted() { | 45 | isSubmitted() { |
45 | return this.state.submitted | 46 | return this.state.submitted |
46 | } | 47 | } |
47 | 48 | ||
48 | resetSubmitted() { | 49 | resetSubmitted() { |
49 | this.setState({ submitted: false }) | 50 | this.setState({ submitted: false }) |
50 | } | 51 | } |
51 | 52 | ||
52 | getValue(path) { | 53 | getValue(path) { |
53 | if (!path) { | 54 | if (!path) { |
54 | throw new Error(`getValue() requires a path`) | 55 | throw new Error(`getValue() requires a path`) |
55 | } | 56 | } |
56 | return get(this.state.values, path, '') | 57 | return get(this.state.values, path, '') |
57 | } | 58 | } |
58 | 59 | ||
59 | setValue (path, value) { | 60 | setValue (path, value) { |
60 | if (!path) { | 61 | if (!path) { |
61 | throw new Error(`setValue() requires a path`) | 62 | throw new Error(`setValue() requires a path`) |
62 | } | 63 | } |
63 | if (value === undefined) { | 64 | if (value === undefined) { |
64 | throw new Error(`setValue() requires a non-undefined value`) | 65 | throw new Error(`setValue() requires a non-undefined value`) |
65 | } | 66 | } |
66 | this.setState(prevState => { | 67 | this.setState(prevState => { |
67 | const prevValues = prevState.values | 68 | const prevValues = prevState.values |
68 | // Lo-Dash's set() mutates the original value, so we need to make a copy | 69 | // Lo-Dash's set() mutates the original value, so we need to make a copy |
69 | const prevValuesCopy = cloneDeep(prevValues) | 70 | const prevValuesCopy = cloneDeep(prevValues) |
70 | const nextValues = set(prevValuesCopy, path, value) | 71 | const nextValues = set(prevValuesCopy, path, value) |
71 | return { values: nextValues } | 72 | return { values: nextValues } |
72 | }) | 73 | }) |
73 | this.setDirty(path) | 74 | this.setDirty(path) |
74 | } | 75 | } |
75 | 76 | ||
76 | setPristine(path) { | 77 | setPristine(path) { |
77 | if (!path) { | 78 | if (!path) { |
78 | throw new Error(`setPristine() requires a path`) | 79 | throw new Error(`setPristine() requires a path`) |
79 | } | 80 | } |
80 | this.setState(prevState => ({ | 81 | this.setState(prevState => ({ |
81 | dirtyValues: ( | 82 | dirtyValues: ( |
82 | this.isPristine(path) | 83 | this.isPristine(path) |
83 | ? prevState.dirtyValues | 84 | ? prevState.dirtyValues |
84 | : prevState.dirtyValues.filter(dirtyValue => dirtyValue !== path) | 85 | : prevState.dirtyValues.filter(dirtyValue => dirtyValue !== path) |
85 | ) | 86 | ) |
86 | })) | 87 | })) |
87 | } | 88 | } |
88 | 89 | ||
89 | setDirty(path) { | 90 | setDirty(path) { |
90 | if (!path) { | 91 | if (!path) { |
91 | throw new Error(`setDirty() requires a path`) | 92 | throw new Error(`setDirty() requires a path`) |
92 | } | 93 | } |
93 | this.setState(prevState => ({ | 94 | this.setState(prevState => ({ |
94 | dirtyValues: ( | 95 | dirtyValues: ( |
95 | this.isDirty(path) | 96 | this.isDirty(path) |
96 | ? prevState.dirtyValues | 97 | ? prevState.dirtyValues |
97 | : [...prevState.dirtyValues, path] | 98 | : [...prevState.dirtyValues, path] |
98 | ) | 99 | ) |
99 | })) | 100 | })) |
100 | } | 101 | } |
101 | 102 | ||
102 | reset() { | 103 | reset() { |
103 | this.setState({ | 104 | this.setState({ |
104 | values: this.props.initialValues, | 105 | values: this.props.initialValues, |
105 | dirtyValues: [], | 106 | dirtyValues: [], |
106 | submitted: false | 107 | submitted: false |
107 | }) | 108 | }) |
108 | } | 109 | } |
109 | 110 | ||
110 | handleSubmit(event) { | 111 | handleSubmit(event) { |
111 | if (event) { | 112 | if (event) { |
112 | event.preventDefault() | 113 | event.preventDefault() |
113 | } | 114 | } |
114 | this.setState({ submitted: true }) | 115 | this.setState({ submitted: true }) |
115 | if (this.props.onSubmit) { | 116 | if (this.props.onSubmit) { |
116 | this.props.onSubmit(this.state.values) | 117 | this.props.onSubmit(this.state.values) |
117 | } | 118 | } |
118 | } | 119 | } |
119 | 120 | ||
120 | render() { | 121 | render() { |
121 | // eslint-disable-next-line | 122 | // eslint-disable-next-line |
122 | const { initialValues, children, ...rest } = this.props | 123 | const { initialValues, children, ...rest } = this.props |
123 | return ( | 124 | return ( |
124 | <form {...rest} onSubmit={this.handleSubmit}> | 125 | <form {...rest} onSubmit={this.handleSubmit}> |
125 | {children({ | 126 | {children({ |
126 | values: this.state.values, | 127 | values: this.state.values, |
127 | isPristine: this.isPristine, | 128 | isPristine: this.isPristine, |
128 | isDirty: this.isDirty, | 129 | isDirty: this.isDirty, |
129 | isSubmitted: this.isSubmitted, | 130 | isSubmitted: this.isSubmitted, |
130 | getValue: this.getValue, | 131 | getValue: this.getValue, |
131 | setValue: this.setValue, | 132 | setValue: this.setValue, |
132 | setPristine: this.setPristine, | 133 | setPristine: this.setPristine, |
133 | setDirty: this.setDirty, | 134 | setDirty: this.setDirty, |
134 | reset: this.reset, | 135 | reset: this.reset, |
135 | resetSubmitted: this.resetSubmitted | 136 | resetSubmitted: this.resetSubmitted |
136 | })} | 137 | })} |
137 | </form> | 138 | </form> |
138 | ) | 139 | ) |
139 | } | 140 | } |
140 | } | 141 | } |
141 | 142 | ||
142 | Form.propTypes = { | 143 | Form.propTypes = { |
143 | initialValues: PropTypes.object, | 144 | initialValues: PropTypes.object, |
144 | onSubmit: PropTypes.func, | 145 | onSubmit: PropTypes.func, |
145 | children: PropTypes.func.isRequired | 146 | children: PropTypes.func.isRequired |
146 | } | 147 | } |
147 | 148 | ||
148 | Form.defaultProps = { initialValues: {} } | 149 | Form.defaultProps = { initialValues: {} } |
149 | 150 | ||
150 | export default Form | 151 | export default Form |
151 | 152 |
imports/client/views/org/admin/students/AddStudentFormContainer.js
1 | import React, { Component } from 'react' | 1 | import React, { Component } from 'react' |
2 | import { AddStudentForm } from './addStudentForm' | 2 | import { AddStudentForm } from './addStudentForm' |
3 | import StudentForm from './StudentForm' | 3 | import StudentForm from './StudentForm' |
4 | import Form from '../../../core/Form' | 4 | import Form from '/imports/client/views/core/Form' |
5 | import Validator from '../../../core/Validator' | 5 | import Validator from '/imports/client/views/core/Validator' |
6 | import { isRequired, isValidEmail } from '../../../core/validations' | 6 | import { isRequired, isValidEmail } from '/imports/client/views/core/validations' |
7 | import { addStudentManually } from '/imports/collections/students/methods'; | 7 | import { addStudentManually } from '/imports/collections/students/methods'; |
8 | 8 | ||
9 | export class AddStudentFormContainer extends Component { | 9 | export class AddStudentFormContainer extends Component { |
10 | 10 | ||
11 | constructor(props) { | 11 | constructor(props) { |
12 | super(props) | 12 | super(props) |
13 | this.state = { currentStep: 0 } | 13 | this.state = { currentStep: 0 } |
14 | this.handleNextClick = this.handleNextClick.bind(this) | 14 | this.handleNextClick = this.handleNextClick.bind(this) |
15 | this.handleBackClick = this.handleBackClick.bind(this) | 15 | this.handleBackClick = this.handleBackClick.bind(this) |
16 | this.handleSubmit = this.handleSubmit.bind(this) | 16 | this.handleSubmit = this.handleSubmit.bind(this) |
17 | } | 17 | } |
18 | 18 | ||
19 | handleNextClick() { | 19 | handleNextClick() { |
20 | this.form.handleSubmit() | 20 | this.form.handleSubmit() |
21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return | 21 | if (this.validator.getErrors() && Object.keys(this.validator.getErrors()).length > 0) return |
22 | this.setState({ currentStep: this.state.currentStep + 1 }) | 22 | this.setState({ currentStep: this.state.currentStep + 1 }) |
23 | this.form.resetSubmitted() | 23 | this.form.resetSubmitted() |
24 | } | 24 | } |
25 | 25 | ||
26 | handleBackClick() { | 26 | handleBackClick() { |
27 | this.setState({ currentStep: this.state.currentStep + -1 }) | 27 | this.setState({ currentStep: this.state.currentStep + -1 }) |
28 | } | 28 | } |
29 | 29 | ||
30 | handleSubmit() { | 30 | handleSubmit() { |
31 | if (this.state.currentStep === 3) { | 31 | if (this.state.currentStep === 3) { |
32 | addStudentManually.call(this.form.state.values) | 32 | addStudentManually.call(this.form.state.values) |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | //render callback | ||
36 | render() { | 37 | render() { |
37 | return ( | 38 | return ( |
38 | <Form | 39 | <Form |
39 | onSubmit={this.handleSubmit} | 40 | onSubmit={this.handleSubmit} |
40 | ref={form => this.form = form} | 41 | ref={form => this.form = form} |
41 | initialValues={{ | 42 | initialValues={{ |
42 | gender: 'male', | 43 | gender: 'male', |
43 | parentGender: 'male', | 44 | parentGender: 'male', |
44 | }} | 45 | }} |
45 | > | 46 | > |
46 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( | 47 | {({ values, setValue, getValue, isSubmitted, isDirty }) => ( |
47 | <Validator | 48 | <Validator |
48 | values={values} | 49 | values={values} |
49 | ref={validator => this.validator = validator} | 50 | ref={validator => this.validator = validator} |
50 | validations={{ | 51 | validations={{ |
51 | admissionId: [(value) => isRequired('Admission id', value)], | 52 | admissionId: [(value) => isRequired('Admission id', value)], |
52 | firstName: [(value) => isRequired('First name', value)], | 53 | firstName: [(value) => isRequired('First name', value)], |
53 | middleName: [(value) => isRequired('Middle name', value)], | 54 | middleName: [(value) => isRequired('Middle name', value)], |
54 | lastName: [(value) => isRequired('Last name', value)], | 55 | lastName: [(value) => isRequired('Last name', value)], |
55 | email: [(value) => isRequired('Email', value), isValidEmail], | 56 | email: [(value) => isRequired('Email', value), isValidEmail], |
56 | dob: [(value) => isRequired('Date of birth', value)], | 57 | dob: [(value) => isRequired('Date of birth', value)], |
57 | gender: [(value) => isRequired('Gender', value)], | 58 | gender: [(value) => isRequired('Gender', value)], |
58 | rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], | 59 | rollNo: [(value) => this.state.currentStep === 1 && isRequired('Roll no', value)], |
59 | class: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], | 60 | class: [(value) => this.state.currentStep === 1 && isRequired('Class', value)], |
60 | section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], | 61 | section: [(value) => this.state.currentStep === 1 && isRequired('Section', value)], |
61 | community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], | 62 | community: [(value) => this.state.currentStep === 1 && isRequired('Community', value)], |
62 | bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], | 63 | bloodGroup: [(value) => this.state.currentStep === 1 && isRequired('Blood group', value)], |
63 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], | 64 | phone: [(value) => this.state.currentStep === 1 && isRequired('Phone', value)], |
64 | address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], | 65 | address: [(value) => this.state.currentStep === 2 && isRequired('Address', value)], |
65 | city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], | 66 | city: [(value) => this.state.currentStep === 2 && isRequired('City', value)], |
66 | state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], | 67 | state: [(value) => this.state.currentStep === 2 && isRequired('State', value)], |
67 | parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], | 68 | parentName: [(value) => this.state.currentStep === 3 && isRequired('Parent name', value)], |
68 | parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], | 69 | parentEmail: [(value) => this.state.currentStep === 3 && isRequired('Parent email', value), (value) => this.state.currentStep === 3 && isValidEmail(value)], |
69 | relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], | 70 | relation: [(value) => this.state.currentStep === 3 && isRequired('Relation', value)], |
70 | profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], | 71 | profession: [(value) => this.state.currentStep === 3 && isRequired('Profession', value)], |
71 | parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], | 72 | parentGender: [(value) => this.state.currentStep === 3 && isRequired('Parent gender', value)], |
72 | parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], | 73 | parentPhone: [(value) => this.state.currentStep === 3 && isRequired('Parent phone', value)], |
73 | parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], | 74 | parentAddress: [(value) => this.state.currentStep === 3 && isRequired('Parent address', value)], |
74 | parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], | 75 | parentCity: [(value) => this.state.currentStep === 3 && isRequired('Parent city', value)], |
75 | parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], | 76 | parentState: [(value) => this.state.currentStep === 3 && isRequired('Parent state', value)], |
76 | parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], | 77 | parentZipcode: [(value) => this.state.currentStep === 3 && isRequired('Parent zip code', value)], |
77 | }} | 78 | }} |
78 | > | 79 | > |
79 | {({ errors }) => ( | 80 | {({ errors }) => ( |
80 | <StudentForm | 81 | <StudentForm |
81 | isDirty={isDirty} | 82 | isDirty={isDirty} |
82 | setValue={setValue} | 83 | setValue={setValue} |
83 | getValue={getValue} | 84 | getValue={getValue} |
84 | isSubmitted={isSubmitted} | 85 | isSubmitted={isSubmitted} |
85 | errors={errors} | 86 | errors={errors} |
86 | onNextClick={this.handleNextClick} | 87 | onNextClick={this.handleNextClick} |
87 | onBackClick={this.handleBackClick} | 88 | onBackClick={this.handleBackClick} |
88 | currentStep={this.state.currentStep} | 89 | currentStep={this.state.currentStep} |
89 | /> | 90 | /> |
90 | )} | 91 | )} |
91 | </Validator> | 92 | </Validator> |
92 | )} | 93 | )} |
93 | </Form> | 94 | </Form> |
94 | ) | 95 | ) |
95 | } | 96 | } |
96 | } | 97 | } |
97 | 98 |
imports/client/views/org/admin/students/StudentForm.js
1 | import React, { PropTypes } from 'react' | 1 | import React, { PropTypes } from 'react' |
2 | import { | 2 | import { |
3 | Row, | 3 | Row, |
4 | Col, | 4 | Col, |
5 | FormGroup, | 5 | FormGroup, |
6 | FormControl, | 6 | FormControl, |
7 | Button | 7 | Button |
8 | } from 'react-bootstrap' | 8 | } from 'react-bootstrap' |
9 | // import DatePicker from 'react-bootstrap-date-picker' | 9 | import DatePicker from '/imports/client/views/core/DatePicker' |
10 | import DatePicker from '../../../core/DatePicker' | 10 | import Label from '/imports/client/views/core/Label' |
11 | import Label from '../../../core/Label' | 11 | import Stepper from '/imports/client/views/core/Stepper' |
12 | import Stepper from '../../../core/Stepper' | 12 | import ErrorLabel from '/imports/client/views/core/ErrorLabel' |
13 | import ErrorLabel from '../../../core/ErrorLabel' | ||
14 | 13 | ||
15 | const StudentForm = props => ( | 14 | const StudentForm = props => ( |
16 | <div className="stepy-validation"> | 15 | <div className="stepy-validation"> |
17 | <Stepper | 16 | <Stepper |
18 | steps={[ | 17 | steps={[ |
19 | { | 18 | { |
20 | label: 'Personal data', | 19 | label: 'Personal data', |
21 | active: props.currentStep === 0, | 20 | active: props.currentStep === 0, |
22 | }, | 21 | }, |
23 | { | 22 | { |
24 | label: 'Academic', | 23 | label: 'Academic', |
25 | active: props.currentStep === 1, | 24 | active: props.currentStep === 1, |
26 | }, | 25 | }, |
27 | { | 26 | { |
28 | label: 'Address', | 27 | label: 'Address', |
29 | active: props.currentStep === 2, | 28 | active: props.currentStep === 2, |
30 | }, | 29 | }, |
31 | { | 30 | { |
32 | label: 'Parent info', | 31 | label: 'Parent info', |
33 | active: props.currentStep === 3, | 32 | active: props.currentStep === 3, |
34 | } | 33 | } |
35 | ]} | 34 | ]} |
36 | /> | 35 | /> |
37 | {props.currentStep === 0 && ( | 36 | {props.currentStep === 0 && ( |
38 | <fieldset title="1"> | 37 | <fieldset title="1"> |
39 | <legend className="text-semibold">Personal data</legend> | 38 | <legend className="text-semibold">Personal data</legend> |
40 | <Row> | 39 | <Row> |
41 | <Col xs={12} sm={6}> | 40 | <Col xs={12} sm={6}> |
42 | <FormGroup controlId="admissionId"> | 41 | <FormGroup controlId="admissionId"> |
43 | <Label required>Admission Id</Label> | 42 | <Label required>Admission Id</Label> |
44 | <FormControl | 43 | <FormControl |
45 | type="text" | 44 | type="text" |
46 | value={props.getValue('admissionId')} | 45 | value={props.getValue('admissionId')} |
47 | placeholder="admission Id" | 46 | placeholder="admission Id" |
48 | onChange={e => props.setValue('admissionId', e.target.value)} | 47 | onChange={e => props.setValue('admissionId', e.target.value)} |
49 | /> | 48 | /> |
50 | {props.isSubmitted() && props.errors && props.errors.admissionId && ( | 49 | {props.isSubmitted() && props.errors && props.errors.admissionId && ( |
51 | <ErrorLabel> {props.errors.admissionId} </ErrorLabel> | 50 | <ErrorLabel> {props.errors.admissionId} </ErrorLabel> |
52 | )} | 51 | )} |
53 | </FormGroup> | 52 | </FormGroup> |
54 | </Col> | 53 | </Col> |
55 | <Col xs={12} sm={6}> | 54 | <Col xs={12} sm={6}> |
56 | <FormGroup controlId="firstName"> | 55 | <FormGroup controlId="firstName"> |
57 | <Label required>First Name</Label> | 56 | <Label required>First Name</Label> |
58 | <FormControl | 57 | <FormControl |
59 | type="text" | 58 | type="text" |
60 | value={props.getValue('firstName')} | 59 | value={props.getValue('firstName')} |
61 | placeholder="First Name" | 60 | placeholder="First Name" |
62 | onChange={e => props.setValue('firstName', e.target.value)} | 61 | onChange={e => props.setValue('firstName', e.target.value)} |
63 | /> | 62 | /> |
64 | {props.isSubmitted() && props.errors && props.errors.firstName && ( | 63 | {props.isSubmitted() && props.errors && props.errors.firstName && ( |
65 | <ErrorLabel> {props.errors.firstName} </ErrorLabel> | 64 | <ErrorLabel> {props.errors.firstName} </ErrorLabel> |
66 | )} | 65 | )} |
67 | </FormGroup> | 66 | </FormGroup> |
68 | </Col> | 67 | </Col> |
69 | </Row> | 68 | </Row> |
70 | <Row> | 69 | <Row> |
71 | <Col xs={12} sm={6}> | 70 | <Col xs={12} sm={6}> |
72 | <FormGroup controlId="middleName"> | 71 | <FormGroup controlId="middleName"> |
73 | <Label required>Middle Name</Label> | 72 | <Label required>Middle Name</Label> |
74 | <FormControl | 73 | <FormControl |
75 | type="text" | 74 | type="text" |
76 | value={props.getValue('middleName')} | 75 | value={props.getValue('middleName')} |
77 | placeholder="Middle Name" | 76 | placeholder="Middle Name" |
78 | onChange={e => props.setValue('middleName', e.target.value)} | 77 | onChange={e => props.setValue('middleName', e.target.value)} |
79 | /> | 78 | /> |
80 | {props.isSubmitted() && props.errors && props.errors.middleName && ( | 79 | {props.isSubmitted() && props.errors && props.errors.middleName && ( |
81 | <ErrorLabel> {props.errors.middleName} </ErrorLabel> | 80 | <ErrorLabel> {props.errors.middleName} </ErrorLabel> |
82 | )} | 81 | )} |
83 | </FormGroup> | 82 | </FormGroup> |
84 | </Col> | 83 | </Col> |
85 | <Col xs={12} sm={6}> | 84 | <Col xs={12} sm={6}> |
86 | <FormGroup controlId="lastName"> | 85 | <FormGroup controlId="lastName"> |
87 | <Label required>Last Name</Label> | 86 | <Label required>Last Name</Label> |
88 | <FormControl | 87 | <FormControl |
89 | type="text" | 88 | type="text" |
90 | value={props.getValue('lastName')} | 89 | value={props.getValue('lastName')} |
91 | placeholder="Last Name" | 90 | placeholder="Last Name" |
92 | onChange={e => props.setValue('lastName', e.target.value)} | 91 | onChange={e => props.setValue('lastName', e.target.value)} |
93 | /> | 92 | /> |
94 | {props.isSubmitted() && props.errors && props.errors.lastName && ( | 93 | {props.isSubmitted() && props.errors && props.errors.lastName && ( |
95 | <ErrorLabel> {props.errors.lastName} </ErrorLabel> | 94 | <ErrorLabel> {props.errors.lastName} </ErrorLabel> |
96 | )} | 95 | )} |
97 | </FormGroup> | 96 | </FormGroup> |
98 | </Col> | 97 | </Col> |
99 | </Row> | 98 | </Row> |
100 | <Row> | 99 | <Row> |
101 | <Col xs={12} sm={6}> | 100 | <Col xs={12} sm={6}> |
102 | <FormGroup controlId="email"> | 101 | <FormGroup controlId="email"> |
103 | <Label required>Email</Label> | 102 | <Label required>Email</Label> |
104 | <FormControl | 103 | <FormControl |
105 | type="email" | 104 | type="email" |
106 | value={props.getValue('email')} | 105 | value={props.getValue('email')} |
107 | placeholder="Email" | 106 | placeholder="Email" |
108 | onChange={e => props.setValue('email', e.target.value)} | 107 | onChange={e => props.setValue('email', e.target.value)} |
109 | /> | 108 | /> |
110 | {props.isSubmitted() && props.errors && props.errors.email && ( | 109 | {props.isSubmitted() && props.errors && props.errors.email && ( |
111 | <ErrorLabel> {props.errors.email} </ErrorLabel> | 110 | <ErrorLabel> {props.errors.email} </ErrorLabel> |
112 | )} | 111 | )} |
113 | </FormGroup> | 112 | </FormGroup> |
114 | </Col> | 113 | </Col> |
115 | <Col xs={12} sm={6}> | 114 | <Col xs={12} sm={6}> |
116 | <FormGroup> | 115 | <FormGroup> |
117 | <Label required>Date of birth</Label> | 116 | <Label required>Date of birth</Label> |
118 | <DatePicker | 117 | <DatePicker |
119 | id="dob" | 118 | id="dob" |
120 | value={props.getValue('dob')} | 119 | value={props.getValue('dob')} |
121 | onChange={(e) => { | 120 | onChange={(e) => { |
122 | props.setValue('dob', e.target.value) | 121 | props.setValue('dob', e.target.value) |
123 | }} | 122 | }} |
124 | /> | 123 | /> |
125 | {props.isSubmitted() && props.errors && props.errors.dob && ( | 124 | {props.isSubmitted() && props.errors && props.errors.dob && ( |
126 | <ErrorLabel> {props.errors.dob} </ErrorLabel> | 125 | <ErrorLabel> {props.errors.dob} </ErrorLabel> |
127 | )} | 126 | )} |
128 | </FormGroup> | 127 | </FormGroup> |
129 | </Col> | 128 | </Col> |
130 | </Row> | 129 | </Row> |
131 | <Row> | 130 | <Row> |
132 | <Col xs={12} sm={6}> | 131 | <Col xs={12} sm={6}> |
133 | <FormGroup controlId="formControlsSelect"> | 132 | <FormGroup controlId="formControlsSelect"> |
134 | <Label>Gender</Label> | 133 | <Label>Gender</Label> |
135 | <FormControl componentClass="select" | 134 | <FormControl componentClass="select" |
136 | placeholder="select" | 135 | placeholder="select" |
137 | value={props.getValue('gender')} | 136 | value={props.getValue('gender')} |
138 | onChange={e => props.setValue('gender', e.target.value)} | 137 | onChange={e => props.setValue('gender', e.target.value)} |
139 | > | 138 | > |
140 | <option value="male">Male</option> | 139 | <option value="male">Male</option> |
141 | <option value="female">Female</option> | 140 | <option value="female">Female</option> |
142 | </FormControl> | 141 | </FormControl> |
143 | {props.isSubmitted() && props.errors && props.errors.gender && ( | 142 | {props.isSubmitted() && props.errors && props.errors.gender && ( |
144 | <ErrorLabel> {props.errors.gender} </ErrorLabel> | 143 | <ErrorLabel> {props.errors.gender} </ErrorLabel> |
145 | )} | 144 | )} |
146 | </FormGroup> | 145 | </FormGroup> |
147 | </Col> | 146 | </Col> |
148 | </Row> | 147 | </Row> |
149 | </fieldset> | 148 | </fieldset> |
150 | )} | 149 | )} |
151 | {props.currentStep === 1 && ( | 150 | {props.currentStep === 1 && ( |
152 | <fieldset title="Academic"> | 151 | <fieldset title="Academic"> |
153 | <legend className="text-semibold">Academic</legend> | 152 | <legend className="text-semibold">Academic</legend> |
154 | <Row> | 153 | <Row> |
155 | <Col xs={12} sm={6}> | 154 | <Col xs={12} sm={6}> |
156 | <FormGroup controlId="rollNo"> | 155 | <FormGroup controlId="rollNo"> |
157 | <Label required>Roll No</Label> | 156 | <Label required>Roll No</Label> |
158 | <FormControl | 157 | <FormControl |
159 | type="text" | 158 | type="text" |
160 | value={props.getValue('rollNo')} | 159 | value={props.getValue('rollNo')} |
161 | placeholder="Roll No" | 160 | placeholder="Roll No" |
162 | onChange={e => props.setValue('rollNo', e.target.value)} | 161 | onChange={e => props.setValue('rollNo', e.target.value)} |
163 | /> | 162 | /> |
164 | {props.isSubmitted() && props.errors && props.errors.rollNo && ( | 163 | {props.isSubmitted() && props.errors && props.errors.rollNo && ( |
165 | <ErrorLabel> {props.errors.rollNo} </ErrorLabel> | 164 | <ErrorLabel> {props.errors.rollNo} </ErrorLabel> |
166 | )} | 165 | )} |
167 | </FormGroup> | 166 | </FormGroup> |
168 | </Col> | 167 | </Col> |
169 | <Col xs={12} sm={6}> | 168 | <Col xs={12} sm={6}> |
170 | <FormGroup controlId="class"> | 169 | <FormGroup controlId="class"> |
171 | <Label required>Class</Label> | 170 | <Label required>Class</Label> |
172 | <FormControl | 171 | <FormControl |
173 | type="text" | 172 | type="text" |
174 | value={props.getValue('class')} | 173 | value={props.getValue('class')} |
175 | placeholder="7" | 174 | placeholder="7" |
176 | onChange={e => props.setValue('class', e.target.value)} | 175 | onChange={e => props.setValue('class', e.target.value)} |
177 | /> | 176 | /> |
178 | {props.isSubmitted() && props.errors && props.errors.class && ( | 177 | {props.isSubmitted() && props.errors && props.errors.class && ( |
179 | <ErrorLabel> {props.errors.class} </ErrorLabel> | 178 | <ErrorLabel> {props.errors.class} </ErrorLabel> |
180 | )} | 179 | )} |
181 | </FormGroup> | 180 | </FormGroup> |
182 | </Col> | 181 | </Col> |
183 | </Row> | 182 | </Row> |
184 | <Row> | 183 | <Row> |
185 | <Col xs={12} sm={6}> | 184 | <Col xs={12} sm={6}> |
186 | <FormGroup controlId="section"> | 185 | <FormGroup controlId="section"> |
187 | <Label required>Section</Label> | 186 | <Label required>Section</Label> |
188 | <FormControl | 187 | <FormControl |
189 | type="text" | 188 | type="text" |
190 | value={props.getValue('section')} | 189 | value={props.getValue('section')} |
191 | placeholder="B" | 190 | placeholder="B" |
192 | onChange={e => props.setValue('section', e.target.value)} | 191 | onChange={e => props.setValue('section', e.target.value)} |
193 | /> | 192 | /> |
194 | {props.isSubmitted() && props.errors && props.errors.section && ( | 193 | {props.isSubmitted() && props.errors && props.errors.section && ( |
195 | <ErrorLabel> {props.errors.section} </ErrorLabel> | 194 | <ErrorLabel> {props.errors.section} </ErrorLabel> |
196 | )} | 195 | )} |
197 | </FormGroup> | 196 | </FormGroup> |
198 | </Col> | 197 | </Col> |
199 | <Col xs={12} sm={6}> | 198 | <Col xs={12} sm={6}> |
200 | <FormGroup controlId="community"> | 199 | <FormGroup controlId="community"> |
201 | <Label required>Community</Label> | 200 | <Label required>Community</Label> |
202 | <FormControl | 201 | <FormControl |
203 | type="text" | 202 | type="text" |
204 | value={props.getValue('community')} | 203 | value={props.getValue('community')} |
205 | placeholder="General" | 204 | placeholder="General" |
206 | onChange={e => props.setValue('community', e.target.value)} | 205 | onChange={e => props.setValue('community', e.target.value)} |
207 | /> | 206 | /> |
208 | {props.isSubmitted() && props.errors && props.errors.community && ( | 207 | {props.isSubmitted() && props.errors && props.errors.community && ( |
209 | <ErrorLabel> {props.errors.community} </ErrorLabel> | 208 | <ErrorLabel> {props.errors.community} </ErrorLabel> |
210 | )} | 209 | )} |
211 | </FormGroup> | 210 | </FormGroup> |
212 | </Col> | 211 | </Col> |
213 | </Row> | 212 | </Row> |
214 | <Row> | 213 | <Row> |
215 | <Col xs={12} sm={6}> | 214 | <Col xs={12} sm={6}> |
216 | <FormGroup controlId="bloodGroup"> | 215 | <FormGroup controlId="bloodGroup"> |
217 | <Label required>bloodGroup</Label> | 216 | <Label required>bloodGroup</Label> |
218 | <FormControl | 217 | <FormControl |
219 | type="text" | 218 | type="text" |
220 | value={props.getValue('bloodGroup')} | 219 | value={props.getValue('bloodGroup')} |
221 | placeholder="B+" | 220 | placeholder="B+" |
222 | onChange={e => props.setValue('bloodGroup', e.target.value)} | 221 | onChange={e => props.setValue('bloodGroup', e.target.value)} |
223 | /> | 222 | /> |
224 | {props.isSubmitted() && props.errors && props.errors.bloodGroup && ( | 223 | {props.isSubmitted() && props.errors && props.errors.bloodGroup && ( |
225 | <ErrorLabel> {props.errors.bloodGroup} </ErrorLabel> | 224 | <ErrorLabel> {props.errors.bloodGroup} </ErrorLabel> |
226 | )} | 225 | )} |
227 | </FormGroup> | 226 | </FormGroup> |
228 | </Col> | 227 | </Col> |
229 | <Col xs={12} sm={6}> | 228 | <Col xs={12} sm={6}> |
230 | <FormGroup controlId="phone"> | 229 | <FormGroup controlId="phone"> |
231 | <Label required>Phone</Label> | 230 | <Label required>Phone</Label> |
232 | <FormControl | 231 | <FormControl |
233 | type="text" | 232 | type="text" |
234 | value={props.getValue('phone')} | 233 | value={props.getValue('phone')} |
235 | placeholder="9999999999" | 234 | placeholder="9999999999" |
236 | onChange={e => props.setValue('phone', e.target.value)} | 235 | onChange={e => props.setValue('phone', e.target.value)} |
237 | /> | 236 | /> |
238 | {props.isSubmitted() && props.errors && props.errors.phone && ( | 237 | {props.isSubmitted() && props.errors && props.errors.phone && ( |
239 | <ErrorLabel> {props.errors.phone} </ErrorLabel> | 238 | <ErrorLabel> {props.errors.phone} </ErrorLabel> |
240 | )} | 239 | )} |
241 | </FormGroup> | 240 | </FormGroup> |
242 | </Col> | 241 | </Col> |
243 | </Row> | 242 | </Row> |
244 | </fieldset> | 243 | </fieldset> |
245 | )} | 244 | )} |
246 | {props.currentStep === 2 && ( | 245 | {props.currentStep === 2 && ( |
247 | <fieldset title="Address"> | 246 | <fieldset title="Address"> |
248 | <legend className="text-semibold">Address</legend> | 247 | <legend className="text-semibold">Address</legend> |
249 | <Row> | 248 | <Row> |
250 | <Col xs={12} sm={6}> | 249 | <Col xs={12} sm={6}> |
251 | <FormGroup controlId="address"> | 250 | <FormGroup controlId="address"> |
252 | <Label required>Address</Label> | 251 | <Label required>Address</Label> |
253 | <FormControl | 252 | <FormControl |
254 | type="text" | 253 | type="text" |
255 | value={props.getValue('address')} | 254 | value={props.getValue('address')} |
256 | placeholder="#876, Street, town" | 255 | placeholder="#876, Street, town" |
257 | onChange={e => props.setValue('address', e.target.value)} | 256 | onChange={e => props.setValue('address', e.target.value)} |
258 | /> | 257 | /> |
259 | {props.isSubmitted() && props.errors && props.errors.address && ( | 258 | {props.isSubmitted() && props.errors && props.errors.address && ( |
260 | <ErrorLabel> {props.errors.address} </ErrorLabel> | 259 | <ErrorLabel> {props.errors.address} </ErrorLabel> |
261 | )} | 260 | )} |
262 | </FormGroup> | 261 | </FormGroup> |
263 | </Col> | 262 | </Col> |
264 | <Col xs={12} sm={6}> | 263 | <Col xs={12} sm={6}> |
265 | <FormGroup controlId="city"> | 264 | <FormGroup controlId="city"> |
266 | <Label required>City</Label> | 265 | <Label required>City</Label> |
267 | <FormControl | 266 | <FormControl |
268 | type="text" | 267 | type="text" |
269 | value={props.getValue('city')} | 268 | value={props.getValue('city')} |
270 | placeholder="Chennai" | 269 | placeholder="Chennai" |
271 | onChange={e => props.setValue('city', e.target.value)} | 270 | onChange={e => props.setValue('city', e.target.value)} |
272 | /> | 271 | /> |
273 | {props.isSubmitted() && props.errors && props.errors.city && ( | 272 | {props.isSubmitted() && props.errors && props.errors.city && ( |
274 | <ErrorLabel> {props.errors.city} </ErrorLabel> | 273 | <ErrorLabel> {props.errors.city} </ErrorLabel> |
275 | )} | 274 | )} |
276 | </FormGroup> | 275 | </FormGroup> |
277 | </Col> | 276 | </Col> |
278 | </Row> | 277 | </Row> |
279 | <Row> | 278 | <Row> |
280 | <Col xs={12} sm={6}> | 279 | <Col xs={12} sm={6}> |
281 | <FormGroup controlId="state"> | 280 | <FormGroup controlId="state"> |
282 | <Label required>State</Label> | 281 | <Label required>State</Label> |
283 | <FormControl | 282 | <FormControl |
284 | type="text" | 283 | type="text" |
285 | value={props.getValue('state')} | 284 | value={props.getValue('state')} |
286 | placeholder="Tamilnadu" | 285 | placeholder="Tamilnadu" |
287 | onChange={e => props.setValue('state', e.target.value)} | 286 | onChange={e => props.setValue('state', e.target.value)} |
288 | /> | 287 | /> |
289 | {props.isSubmitted() && props.errors && props.errors.state && ( | 288 | {props.isSubmitted() && props.errors && props.errors.state && ( |
290 | <ErrorLabel> {props.errors.state} </ErrorLabel> | 289 | <ErrorLabel> {props.errors.state} </ErrorLabel> |
291 | )} | 290 | )} |
292 | </FormGroup> | 291 | </FormGroup> |
293 | </Col> | 292 | </Col> |
294 | </Row> | 293 | </Row> |
295 | </fieldset> | 294 | </fieldset> |
296 | )} | 295 | )} |
297 | {props.currentStep === 3 && ( | 296 | {props.currentStep === 3 && ( |
298 | <fieldset title="2"> | 297 | <fieldset title="2"> |
299 | <legend className="text-semibold">Parent information</legend> | 298 | <legend className="text-semibold">Parent information</legend> |
300 | <Row> | 299 | <Row> |
301 | <Col xs={12} sm={6}> | 300 | <Col xs={12} sm={6}> |
302 | <FormGroup controlId="parentName"> | 301 | <FormGroup controlId="parentName"> |
303 | <Label required>Parent Name</Label> | 302 | <Label required>Parent Name</Label> |
304 | <FormControl | 303 | <FormControl |
305 | type="text" | 304 | type="text" |
306 | value={props.getValue('parentName')} | 305 | value={props.getValue('parentName')} |
307 | placeholder="John" | 306 | placeholder="John" |
308 | onChange={e => props.setValue('parentName', e.target.value)} | 307 | onChange={e => props.setValue('parentName', e.target.value)} |
309 | /> | 308 | /> |
310 | {props.isSubmitted() && props.errors && props.errors.parentName && ( | 309 | {props.isSubmitted() && props.errors && props.errors.parentName && ( |
311 | <ErrorLabel> {props.errors.parentName} </ErrorLabel> | 310 | <ErrorLabel> {props.errors.parentName} </ErrorLabel> |
312 | )} | 311 | )} |
313 | </FormGroup> | 312 | </FormGroup> |
314 | </Col> | 313 | </Col> |
315 | <Col xs={12} sm={6}> | 314 | <Col xs={12} sm={6}> |
316 | <FormGroup controlId="parentEmail"> | 315 | <FormGroup controlId="parentEmail"> |
317 | <Label required>Parent Email</Label> | 316 | <Label required>Parent Email</Label> |
318 | <FormControl | 317 | <FormControl |
319 | type="text" | 318 | type="text" |
320 | value={props.getValue('parentEmail')} | 319 | value={props.getValue('parentEmail')} |
321 | placeholder="john@email.com" | 320 | placeholder="john@email.com" |
322 | onChange={e => props.setValue('parentEmail', e.target.value)} | 321 | onChange={e => props.setValue('parentEmail', e.target.value)} |
323 | /> | 322 | /> |
324 | {props.isSubmitted() && props.errors && props.errors.parentEmail && ( | 323 | {props.isSubmitted() && props.errors && props.errors.parentEmail && ( |
325 | <ErrorLabel> {props.errors.parentEmail} </ErrorLabel> | 324 | <ErrorLabel> {props.errors.parentEmail} </ErrorLabel> |
326 | )} | 325 | )} |
327 | </FormGroup> | 326 | </FormGroup> |
328 | </Col> | 327 | </Col> |
329 | </Row> | 328 | </Row> |
330 | <Row> | 329 | <Row> |
331 | <Col xs={12} sm={6}> | 330 | <Col xs={12} sm={6}> |
332 | <FormGroup controlId="relation"> | 331 | <FormGroup controlId="relation"> |
333 | <Label required>Relation</Label> | 332 | <Label required>Relation</Label> |
334 | <FormControl | 333 | <FormControl |
335 | type="text" | 334 | type="text" |
336 | value={props.getValue('relation')} | 335 | value={props.getValue('relation')} |
337 | placeholder="Father" | 336 | placeholder="Father" |
338 | onChange={e => props.setValue('relation', e.target.value)} | 337 | onChange={e => props.setValue('relation', e.target.value)} |
339 | /> | 338 | /> |
340 | {props.isSubmitted() && props.errors && props.errors.relation && ( | 339 | {props.isSubmitted() && props.errors && props.errors.relation && ( |
341 | <ErrorLabel> {props.errors.relation} </ErrorLabel> | 340 | <ErrorLabel> {props.errors.relation} </ErrorLabel> |
342 | )} | 341 | )} |
343 | </FormGroup> | 342 | </FormGroup> |
344 | </Col> | 343 | </Col> |
345 | <Col xs={12} sm={6}> | 344 | <Col xs={12} sm={6}> |
346 | <FormGroup controlId="profession"> | 345 | <FormGroup controlId="profession"> |
347 | <Label required>Profession</Label> | 346 | <Label required>Profession</Label> |
348 | <FormControl | 347 | <FormControl |
349 | type="text" | 348 | type="text" |
350 | value={props.getValue('profession')} | 349 | value={props.getValue('profession')} |
351 | placeholder="Farmer" | 350 | placeholder="Farmer" |
352 | onChange={e => props.setValue('profession', e.target.value)} | 351 | onChange={e => props.setValue('profession', e.target.value)} |
353 | /> | 352 | /> |
354 | {props.isSubmitted() && props.errors && props.errors.profession && ( | 353 | {props.isSubmitted() && props.errors && props.errors.profession && ( |
355 | <ErrorLabel> {props.errors.profession} </ErrorLabel> | 354 | <ErrorLabel> {props.errors.profession} </ErrorLabel> |
356 | )} | 355 | )} |
357 | </FormGroup> | 356 | </FormGroup> |
358 | </Col> | 357 | </Col> |
359 | </Row> | 358 | </Row> |
360 | <Row> | 359 | <Row> |
361 | <Col xs={12} sm={6}> | 360 | <Col xs={12} sm={6}> |
362 | <FormGroup controlId="parentGender"> | 361 | <FormGroup controlId="parentGender"> |
363 | <Label>Parent Gender</Label> | 362 | <Label>Parent Gender</Label> |
364 | <FormControl componentClass="select" | 363 | <FormControl componentClass="select" |
365 | placeholder="select" | 364 | placeholder="select" |
366 | value={props.getValue('parentGender')} | 365 | value={props.getValue('parentGender')} |
367 | onChange={e => props.setValue('parentGender', e.target.value)} | 366 | onChange={e => props.setValue('parentGender', e.target.value)} |
368 | > | 367 | > |
369 | <option value="male">Male</option> | 368 | <option value="male">Male</option> |
370 | <option value="female">Female</option> | 369 | <option value="female">Female</option> |
371 | </FormControl> | 370 | </FormControl> |
372 | {props.isSubmitted() && props.errors && props.errors.parentGender && ( | 371 | {props.isSubmitted() && props.errors && props.errors.parentGender && ( |
373 | <ErrorLabel> {props.errors.parentGender} </ErrorLabel> | 372 | <ErrorLabel> {props.errors.parentGender} </ErrorLabel> |
374 | )} | 373 | )} |
375 | </FormGroup> | 374 | </FormGroup> |
376 | </Col> | 375 | </Col> |
377 | <Col xs={12} sm={6}> | 376 | <Col xs={12} sm={6}> |
378 | <FormGroup controlId="parentPhone"> | 377 | <FormGroup controlId="parentPhone"> |
379 | <Label required>Parent Phone</Label> | 378 | <Label required>Parent Phone</Label> |
380 | <FormControl | 379 | <FormControl |
381 | type="text" | 380 | type="text" |
382 | value={props.getValue('parentPhone')} | 381 | value={props.getValue('parentPhone')} |
383 | placeholder="9876543210" | 382 | placeholder="9876543210" |
384 | onChange={e => props.setValue('parentPhone', e.target.value)} | 383 | onChange={e => props.setValue('parentPhone', e.target.value)} |
385 | /> | 384 | /> |
386 | {props.isSubmitted() && props.errors && props.errors.parentPhone && ( | 385 | {props.isSubmitted() && props.errors && props.errors.parentPhone && ( |
387 | <ErrorLabel> {props.errors.parentPhone} </ErrorLabel> | 386 | <ErrorLabel> {props.errors.parentPhone} </ErrorLabel> |
388 | )} | 387 | )} |
389 | </FormGroup> | 388 | </FormGroup> |
390 | </Col> | 389 | </Col> |
391 | </Row> | 390 | </Row> |
392 | <Row> | 391 | <Row> |
393 | <Col xs={12} sm={6}> | 392 | <Col xs={12} sm={6}> |
394 | <FormGroup controlId="parentAddress"> | 393 | <FormGroup controlId="parentAddress"> |
395 | <Label required>Parent Address</Label> | 394 | <Label required>Parent Address</Label> |
396 | <FormControl | 395 | <FormControl |
397 | type="text" | 396 | type="text" |
398 | value={props.getValue('parentAddress')} | 397 | value={props.getValue('parentAddress')} |
399 | placeholder="#12, street, town" | 398 | placeholder="#12, street, town" |
400 | onChange={e => props.setValue('parentAddress', e.target.value)} | 399 | onChange={e => props.setValue('parentAddress', e.target.value)} |
401 | /> | 400 | /> |
402 | {props.isSubmitted() && props.errors && props.errors.parentAddress && ( | 401 | {props.isSubmitted() && props.errors && props.errors.parentAddress && ( |
403 | <ErrorLabel> {props.errors.parentAddress} </ErrorLabel> | 402 | <ErrorLabel> {props.errors.parentAddress} </ErrorLabel> |
404 | )} | 403 | )} |
405 | </FormGroup> | 404 | </FormGroup> |
406 | </Col> | 405 | </Col> |
407 | <Col xs={12} sm={6}> | 406 | <Col xs={12} sm={6}> |
408 | <FormGroup controlId="parentCity"> | 407 | <FormGroup controlId="parentCity"> |
409 | <Label required>Parent City</Label> | 408 | <Label required>Parent City</Label> |
410 | <FormControl | 409 | <FormControl |
411 | type="text" | 410 | type="text" |
412 | value={props.getValue('parentCity')} | 411 | value={props.getValue('parentCity')} |
413 | placeholder="Chennai" | 412 | placeholder="Chennai" |
414 | onChange={e => props.setValue('parentCity', e.target.value)} | 413 | onChange={e => props.setValue('parentCity', e.target.value)} |
415 | /> | 414 | /> |
416 | {props.isSubmitted() && props.errors && props.errors.parentCity && ( | 415 | {props.isSubmitted() && props.errors && props.errors.parentCity && ( |
417 | <ErrorLabel> {props.errors.parentCity} </ErrorLabel> | 416 | <ErrorLabel> {props.errors.parentCity} </ErrorLabel> |
418 | )} | 417 | )} |
419 | </FormGroup> | 418 | </FormGroup> |
420 | </Col> | 419 | </Col> |
421 | </Row> | 420 | </Row> |
422 | <Row> | 421 | <Row> |
423 | <Col xs={12} sm={6}> | 422 | <Col xs={12} sm={6}> |
424 | <FormGroup controlId="parentZipcode"> | 423 | <FormGroup controlId="parentZipcode"> |
425 | <Label required>Parent Zipcode</Label> | 424 | <Label required>Parent Zipcode</Label> |
426 | <FormControl | 425 | <FormControl |
427 | type="text" | 426 | type="text" |
428 | value={props.getValue('parentZipcode')} | 427 | value={props.getValue('parentZipcode')} |
429 | placeholder="600031" | 428 | placeholder="600031" |
430 | onChange={e => props.setValue('parentZipcode', e.target.value)} | 429 | onChange={e => props.setValue('parentZipcode', e.target.value)} |
431 | /> | 430 | /> |
432 | {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( | 431 | {props.isSubmitted() && props.errors && props.errors.parentZipcode && ( |
433 | <ErrorLabel> {props.errors.parentZipcode} </ErrorLabel> | 432 | <ErrorLabel> {props.errors.parentZipcode} </ErrorLabel> |
434 | )} | 433 | )} |
435 | </FormGroup> | 434 | </FormGroup> |
436 | </Col> | 435 | </Col> |
437 | </Row> | 436 | </Row> |
438 | </fieldset> | 437 | </fieldset> |
439 | )} | 438 | )} |
440 | <div style={{ textAlign: 'left' }}> | 439 | <div style={{ textAlign: 'left' }}> |
441 | {props.currentStep > 0 && ( | 440 | {props.currentStep > 0 && ( |
442 | <div style={{ display: 'inline-block', marginRight: 10 }}> | 441 | <div style={{ display: 'inline-block', marginRight: 10 }}> |
443 | <Button onClick={props.onBackClick}> | 442 | <Button onClick={props.onBackClick}> |
444 | <i className="icon-arrow-left13 position-left"></i> | 443 | <i className="icon-arrow-left13 position-left"></i> |
445 | BACK | 444 | BACK |
446 | </Button> | 445 | </Button> |
447 | 446 | ||
448 | </div> | 447 | </div> |
449 | )} | 448 | )} |
450 | {props.currentStep < 3 && ( | 449 | {props.currentStep < 3 && ( |
451 | <div style={{ display: 'inline-block' }}> | 450 | <div style={{ display: 'inline-block' }}> |
452 | <Button | 451 | <Button |
453 | bsStyle="primary" | 452 | bsStyle="primary" |
454 | onClick={props.onNextClick} | 453 | onClick={props.onNextClick} |
455 | > | 454 | > |
456 | NEXT | 455 | NEXT |
457 | <i className="icon-arrow-right14 position-right" /> | 456 | <i className="icon-arrow-right14 position-right" /> |
458 | </Button> | 457 | </Button> |
459 | </div> | 458 | </div> |
460 | )} | 459 | )} |
461 | {props.currentStep === 3 && ( | 460 | {props.currentStep === 3 && ( |
462 | <div style={{ display: 'inline-block' }}> | 461 | <div style={{ display: 'inline-block' }}> |
463 | <Button | 462 | <Button |
464 | bsStyle="primary" | 463 | bsStyle="primary" |
465 | onClick={props.onNextClick} | 464 | onClick={props.onNextClick} |
466 | > | 465 | > |
467 | SAVE | 466 | SAVE |
468 | <i className="fa fa-check" /> | 467 | <i className="fa fa-check" /> |
469 | </Button> | 468 | </Button> |
470 | </div> | 469 | </div> |
471 | )} | 470 | )} |
472 | </div> | 471 | </div> |
473 | </div> | 472 | </div> |
474 | ) | 473 | ) |
475 | 474 | ||
476 | StudentForm.propTypes = { | 475 | StudentForm.propTypes = { |
477 | currentStep: PropTypes.number.isRequired, | 476 | currentStep: PropTypes.number.isRequired, |
478 | onNextClick: PropTypes.func.isRequired, | 477 | onNextClick: PropTypes.func.isRequired, |
479 | onBackClick: PropTypes.func.isRequired, | 478 | onBackClick: PropTypes.func.isRequired, |
480 | setValue: PropTypes.func.isRequired, | 479 | setValue: PropTypes.func.isRequired, |
481 | getValue: PropTypes.func.isRequired, | 480 | getValue: PropTypes.func.isRequired, |
482 | } | 481 | } |
483 | 482 | ||
484 | export default StudentForm | 483 | export default StudentForm |
485 | 484 |