Skip to content

Commit a09d15c

Browse files
authored
Merge pull request #94 from GoTeamEpsilon/quick_code_touchups
quick code touchups
2 parents 6d62fd4 + 4f7f89a commit a09d15c

File tree

9 files changed

+79
-43
lines changed

9 files changed

+79
-43
lines changed

samples/react-redux-patient-demographics-example/src/common/FormsyDatePicker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ export const FormsyDatePicker = React.createClass({
2222
<br />
2323
<span className={className}>{this.getErrorMessage()}</span>
2424
</div>
25-
);
25+
)
2626
}
27-
});
27+
})

samples/react-redux-patient-demographics-example/src/common/FormsyHiddenInput.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ export const FormsyHiddenInput = React.createClass({
2424
value={this.getValue()}
2525
name={this.props.name} />
2626
</div>
27-
);
27+
)
2828
}
29-
});
29+
})

samples/react-redux-patient-demographics-example/src/common/FormsyInput.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ export const FormsyInput = React.createClass({
4646
<br />
4747
<span className={className}>{this.getErrorMessage()}</span>
4848
</div>
49-
);
49+
)
5050
}
51-
});
51+
})

samples/react-redux-patient-demographics-example/src/common/FormsyMaskedInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ export const FormsyMaskedInput = React.createClass({
4848
<br />
4949
<span className={className}>{this.getErrorMessage()}</span>
5050
</div>
51-
);
51+
)
5252
}
5353
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react'
2+
import Formsy from 'formsy-react'
3+
4+
export const FormsySelect = React.createClass({
5+
mixins: [Formsy.Mixin],
6+
7+
changeValue(event) {
8+
let value = ''
9+
10+
if (event && event.currentTarget && event.currentTarget.value) {
11+
value = event.currentTarget.value
12+
event.currentTarget.value = value
13+
}
14+
15+
this.props.onChange(event)
16+
this.setValue(value)
17+
},
18+
19+
render() {
20+
const options = this.props.options.map((option, i) => (
21+
<option key={option.title + option.value} value={option.value}>
22+
{option.title}
23+
</option>
24+
))
25+
26+
return (
27+
<div>
28+
<strong>{this.props.label}: </strong>
29+
<select name={this.props.name} onChange={this.changeValue} value={this.getValue()}>
30+
{options}
31+
</select>
32+
</div>
33+
)
34+
}
35+
})

samples/react-redux-patient-demographics-example/src/routes/Patient/Demographics/Basic/BasicComponent.js

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { telephoneFormat, socialSecurityFormat } from '../../../../common/Format
44
import Formsy from 'formsy-react'
55
import { wireUpCustomFormsyValidators } from '../../../../common/CustomValidators'
66
import { FormsyInput } from '../../../../common/FormsyInput'
7+
import { FormsySelect } from '../../../../common/FormsySelect'
78
import { FormsyDatePicker } from '../../../../common/FormsyDatePicker'
89
import { FormsyMaskedInput } from '../../../../common/FormsyMaskedInput'
910

@@ -28,7 +29,7 @@ class Basic extends React.Component {
2829
console.debug('Basic component in edit mode')
2930
this.setLocalStateToStoreValues()
3031
this.setState({ showForm: true })
31-
this.setState({ cachedForm: this.props.info })
32+
this.setState({ cachedForm: this.props.basic })
3233
}
3334

3435
componentDidMount() {
@@ -61,7 +62,7 @@ class Basic extends React.Component {
6162
let value
6263
switch (event.target.name) {
6364
case 'phone':
64-
case 'ss':
65+
case 'ssn':
6566
value = this.sanitizeToJustNumbers(event.target.value.toString())
6667
break
6768
default:
@@ -79,22 +80,22 @@ class Basic extends React.Component {
7980
}
8081

8182
setLocalStateToStoreValues() {
82-
const keys = ['name', 'dob', 'ss', 'martialStatus', 'gender', 'address', 'postal', 'city', 'state',
83+
const keys = ['name', 'dob', 'ssn', 'martialStatus', 'gender', 'address', 'postal', 'city', 'state',
8384
'country', 'phone', 'email', 'billingNote', 'otherNote']
8485

8586
keys.forEach((keyName) => {
8687
let value
8788

8889
switch (keyName) {
8990
case 'dob':
90-
value = moment(this.props.info[keyName])
91+
value = moment(this.props.basic[keyName])
9192
break
9293
case 'phone':
93-
case 'ss':
94-
value = this.sanitizeToJustNumbers(this.props.info[keyName].toString())
94+
case 'ssn':
95+
value = this.sanitizeToJustNumbers(this.props.basic[keyName].toString())
9596
break
9697
default:
97-
value = this.props.info[keyName]
98+
value = this.props.basic[keyName]
9899
}
99100

100101
this.setState({
@@ -104,46 +105,46 @@ class Basic extends React.Component {
104105
}
105106

106107
render() {
107-
if (this.props.info && this.state.showForm === false) {
108+
if (this.props.basic && this.state.showForm === false) {
108109
return (
109110
<div>
110111
<table className='table'>
111112
<tbody>
112113
<tr>
113-
<td><strong>Name:</strong> {this.props.info.name}</td>
114-
<td><strong>DOB:</strong> {this.props.info.dob}</td>
114+
<td><strong>Name:</strong> {this.props.basic.name}</td>
115+
<td><strong>DOB:</strong> {this.props.basic.dob}</td>
115116
</tr>
116117
<tr>
117-
<td><strong>S.S.:</strong> {socialSecurityFormat(this.props.info.ss)}</td>
118-
<td><strong>Martial Status:</strong> {this.props.info.martialStatus}</td>
118+
<td><strong>SSN:</strong> {socialSecurityFormat(this.props.basic.ssn)}</td>
119+
<td><strong>Martial Status:</strong> {this.props.basic.martialStatus}</td>
119120
</tr>
120121
<tr>
121-
<td><strong>Gender:</strong> {this.props.info.gender}</td>
122-
<td><strong>Address:</strong> {this.props.info.address}</td>
122+
<td><strong>Gender:</strong> {this.props.basic.gender}</td>
123+
<td><strong>Address:</strong> {this.props.basic.address}</td>
123124
</tr>
124125
<tr>
125-
<td><strong>City:</strong> {this.props.info.address}</td>
126-
<td><strong>Postal:</strong> {this.props.info.postal}</td>
126+
<td><strong>City:</strong> {this.props.basic.address}</td>
127+
<td><strong>Postal:</strong> {this.props.basic.postal}</td>
127128
</tr>
128129
<tr>
129-
<td><strong>State:</strong> {this.props.info.state}</td>
130-
<td><strong>Country:</strong> {this.props.info.country}</td>
130+
<td><strong>State:</strong> {this.props.basic.state}</td>
131+
<td><strong>Country:</strong> {this.props.basic.country}</td>
131132
</tr>
132133
<tr>
133-
<td><strong>Phone:</strong> {telephoneFormat(this.props.info.phone)}</td>
134-
<td><strong>Email:</strong> {this.props.info.email}</td>
134+
<td><strong>Phone:</strong> {telephoneFormat(this.props.basic.phone)}</td>
135+
<td><strong>Email:</strong> {this.props.basic.email}</td>
135136
</tr>
136137
<tr>
137-
<td><strong>Billing Note:</strong> {this.props.info.billingNote}</td>
138-
<td><strong>Other Note:</strong> {this.props.info.otherNote}</td>
138+
<td><strong>Billing Note:</strong> {this.props.basic.billingNote}</td>
139+
<td><strong>Other Note:</strong> {this.props.basic.otherNote}</td>
139140
</tr>
140141
</tbody>
141142
</table>
142143

143144
<button type='button' className='btn btn-default btn-sm' onClick={this.handleEdit}>EDIT</button>
144145
</div>
145146
)
146-
} else if (this.props.info && this.state.showForm === true) {
147+
} else if (this.props.basic && this.state.showForm === true) {
147148
return (
148149
<Formsy.Form onValidSubmit={this.handleSubmit.bind(this)}
149150
name='basicInfoForm'
@@ -187,7 +188,7 @@ class Basic extends React.Component {
187188
<tr>
188189
<td>
189190
<FormsyMaskedInput mask={[/\d/,/\d/,/\d/,'-',/\d/,/\d/,'-',/\d/,/\d/,/\d/,/\d/]}
190-
value={this.state.ss}
191+
value={this.state.ssn}
191192
onChange={this.handleInputChange}
192193
validations={{
193194
isLength: 9
@@ -197,7 +198,7 @@ class Basic extends React.Component {
197198
isDefaultRequiredValue: 'Valid SSN is required',
198199
isLength: 'Valid SSN is required'
199200
}}
200-
name='ss'
201+
name='ssn'
201202
label='SSN'
202203
required />
203204
</td>
@@ -220,14 +221,14 @@ class Basic extends React.Component {
220221
</tr>
221222
<tr>
222223
<td>
223-
<strong>Gender: </strong>
224-
<select onChange={this.handleInputChange}
225-
name='gender'
226-
value={this.state.gender}>
227-
<option value='male'>Male</option>
228-
<option value='female'>Female</option>
229-
<option value='other'>Other</option>
230-
</select>
224+
<FormsySelect value={this.state.gender}
225+
onChange={this.handleInputChange}
226+
name='gender'
227+
label='Gender'
228+
options={[{option: 'male', title: 'Male'},
229+
{option: 'female', title: 'Female'},
230+
{option: 'other', title: 'Other'}]}
231+
required />
231232
</td>
232233
<td>
233234
<FormsyInput value={this.state.address}

samples/react-redux-patient-demographics-example/src/routes/Patient/Demographics/PatientDemographicsComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PatientDemographics extends React.Component {
5858

5959
switch (this.state.tab) {
6060
case this.TABS.BASIC:
61-
children = <Basic info={this.props.info}
61+
children = <Basic basic={this.props.basic}
6262
updatePatientData={this.props.updatePatientData} />
6363
break;
6464
case this.TABS.CONTACTS:

samples/react-redux-patient-demographics-example/src/routes/Patient/Demographics/PatientDemographicsContainer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const extractContactsInfo = (state) => {
3131

3232
const mapStateToProps = (state) => ({
3333
patientInContext: state.patient.patientInContext,
34-
info: extractBasicInfo(state),
34+
basic: extractBasicInfo(state),
3535
contacts: extractContactsInfo(state)
3636
})
3737

samples/react-redux-patient-demographics-example/src/routes/Patient/PatientModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const testData = {
1313
basic: {
1414
name: 'John Doe',
1515
dob: '1990-11-04',
16-
ss: '999999999',
16+
ssn: '999999999',
1717
martialStatus: 'Single',
1818
gender: 'Male',
1919
billingNote: 'N/A',

0 commit comments

Comments
 (0)