Browse Source

Linting.

feature/python-error-tracking
Drew Larson 8 years ago
parent
commit
0cec915218
  1. 74
      bikeshop_project/assets/js/components/SignIn.jsx

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

@ -1,10 +1,11 @@
import fetch from 'isomorphic-fetch'; import fetch from 'isomorphic-fetch';
import moment from 'moment'; import moment from 'moment';
import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';
import { polyFill } from 'es6-promise'; import { polyFill } from 'es6-promise';
import Purpose from './Purpose'; import RaisedButton from 'material-ui/RaisedButton';
import React from 'react';
import Member from './Member'; import Member from './Member';
import Purpose from './Purpose';
import SignedInList from './SignedInList'; import SignedInList from './SignedInList';
export default class SignIn extends React.Component { export default class SignIn extends React.Component {
@ -40,26 +41,15 @@ export default class SignIn extends React.Component {
}); });
} }
handleUpdate(text, dataSource) { chooseMember(chosenRequest, index) {
const self = this; const member = this.state.members[index];
self.setState({ searchText: text }); const purpose = this.state.signOn.purpose;
fetch(`/members/search/${text}/`)
.then((response) => { this.setState({ ...this.state, signOn: { member, purpose } });
if (response.status === 200) { }
return response.json();
} onUpdateSearchText(searchText) {
}) this.setState({ searchText });
.then((data) => {
if (data.results.length > 0) {
self.setState({
...this.state,
error: '',
members: data.results.map(result => ({ text: `${result.name}`, value: `${result.name} <${result.email}>`, id: result.id })),
});
} else {
self.setState({ ...this.state, error: 'Member not found.' });
}
});
} }
signIn() { signIn() {
@ -96,21 +86,32 @@ export default class SignIn extends React.Component {
} }
} }
chooseMember(chosenRequest, index) {
const member = this.state.members[index];
const purpose = this.state.signOn.purpose;
this.setState({ ...this.state, signOn: { member, purpose } });
}
onUpdateSearchText(searchText) {
this.setState({ searchText });
}
handlePurposeChoice(event, index, value) { handlePurposeChoice(event, index, value) {
this.setState({ ...this.state, signOn: { ...this.state.signOn, purpose: value } }); this.setState({ ...this.state, signOn: { ...this.state.signOn, purpose: value } });
} }
handleUpdate(text, dataSource) {
const self = this;
self.setState({ searchText: text });
fetch(`/members/search/${text}/`)
.then((response) => {
if (response.status === 200) {
return response.json();
}
})
.then((data) => {
if (data.results.length > 0) {
self.setState({
...this.state,
error: '',
members: data.results.map(result => ({ text: `${result.name}`, value: `${result.name} <${result.email}>`, id: result.id })),
});
} else {
self.setState({ ...this.state, error: 'Member not found.' });
}
});
}
render() { render() {
return ( return (
<div> <div>
@ -132,7 +133,10 @@ export default class SignIn extends React.Component {
/> />
</div> </div>
<div className="mdl-cell mdl-cell--4-col"> <div className="mdl-cell mdl-cell--4-col">
<Purpose handleChange={this.handlePurposeChoice} default={this.state.signOn.purpose} tabIndex={2} /> <Purpose
handleChange={this.handlePurposeChoice}
default={this.state.signOn.purpose} tabIndex={2}
/>
</div> </div>
</div> </div>

Loading…
Cancel
Save