Browse Source

Refactor to use pure function.

feature/python-error-tracking
Drew Larson 8 years ago
parent
commit
5f97e9324b
  1. 39
      bikeshop_project/assets/js/components/Purpose.jsx
  2. 2
      bikeshop_project/assets/js/components/SignIn.jsx

39
bikeshop_project/assets/js/components/Purpose.jsx

@ -1,21 +1,24 @@
import React, { PropTypes } from 'react';
import MenuItem from 'material-ui/MenuItem';
import React from 'react';
import SelectField from 'material-ui/SelectField';
export default class Purpose extends React.Component {
render() {
return (
<SelectField
value={this.props.default}
onChange={this.props.handleChange.bind(this)}
fullWidth
>
<MenuItem value={'VOLUNTEER'} primaryText="Volunteer" caption={'Volunteer'} />
<MenuItem value={'FIX'} primaryText="Fix" caption={'Fix'} />
<MenuItem value={'WORKSHOP'} primaryText="Workshop" caption={'Workshop'} />
<MenuItem value={'DONATE'} primaryText="Donate" caption={'Donate'} />
<MenuItem value={'STAFF'} primaryText="Staff" caption={'Staff'} />
</SelectField>
);
}
}
const Purpose = ({ initialValue, handleChange }) => (
<SelectField
value={initialValue}
onChange={handleChange}
fullWidth
>
<MenuItem value={'VOLUNTEER'} primaryText="Volunteer" />
<MenuItem value={'FIX'} primaryText="Fix" />
<MenuItem value={'WORKSHOP'} primaryText="Workshop" />
<MenuItem value={'DONATE'} primaryText="Donate" />
<MenuItem value={'STAFF'} primaryText="Staff" />
</SelectField>
);
Purpose.propTypes = {
initialValue: PropTypes.string,
handleChange: PropTypes.func,
};
export default Purpose;

2
bikeshop_project/assets/js/components/SignIn.jsx

@ -134,7 +134,7 @@ export default class SignIn extends React.Component {
<div className="mdl-cell mdl-cell--4-col">
<Purpose
handleChange={this.handlePurposeChoice}
default={this.state.signOn.purpose}
initialValue={this.state.signOn.purpose}
/>
</div>
</div>

Loading…
Cancel
Save