|
@ -36,7 +36,7 @@ export default class MemberTable extends React.Component { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
componentDidMount() { |
|
|
fetch('/api/v1/members/') |
|
|
fetch('/api/v1/members/', { credentials: 'same-origin' }) |
|
|
.then(checkStatus) |
|
|
.then(checkStatus) |
|
|
.then(parseJSON) |
|
|
.then(parseJSON) |
|
|
.then((data) => { |
|
|
.then((data) => { |
|
@ -63,11 +63,12 @@ export default class MemberTable extends React.Component { |
|
|
const value = this.state.searchText.trim(); |
|
|
const value = this.state.searchText.trim(); |
|
|
const self = this; |
|
|
const self = this; |
|
|
|
|
|
|
|
|
fetch(`/members/search/${value}/`) |
|
|
fetch(`/members/search/${value}/`, { credentials: 'same-origin' }) |
|
|
.then((response) => { |
|
|
.then((response) => { |
|
|
if (response.status === 200) { |
|
|
if (response.status === 200) { |
|
|
return response.json(); |
|
|
return response.json(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
throw new Error('Bad response from server'); |
|
|
throw new Error('Bad response from server'); |
|
|
}) |
|
|
}) |
|
|
.then((data) => { |
|
|
.then((data) => { |
|
@ -77,15 +78,11 @@ export default class MemberTable extends React.Component { |
|
|
error: '', |
|
|
error: '', |
|
|
filteredMembers: this.state.members.filter((member) => { |
|
|
filteredMembers: this.state.members.filter((member) => { |
|
|
const ids = data.results.map(m => m.id); |
|
|
const ids = data.results.map(m => m.id); |
|
|
console.log(ids); |
|
|
return ids.indexOf(member.id) !== -1; |
|
|
|
|
|
|
|
|
if (ids.indexOf(member.id) !== -1) { |
|
|
|
|
|
return member; |
|
|
|
|
|
} |
|
|
|
|
|
}), |
|
|
}), |
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
self.setState({ ...this.state, error: 'Member not found.' }); |
|
|
self.setState({ ...this.state, filteredMembers: [], error: 'Member not found.' }); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -142,7 +139,7 @@ export default class MemberTable extends React.Component { |
|
|
{memberRows.length && !this.state.searchText ? |
|
|
{memberRows.length && !this.state.searchText ? |
|
|
memberRows : |
|
|
memberRows : |
|
|
<TableRow> |
|
|
<TableRow> |
|
|
<TableRowColumn>{'Members loading.'}</TableRowColumn> |
|
|
<TableRowColumn>{this.state.error || 'Members loading.'}</TableRowColumn> |
|
|
</TableRow> |
|
|
</TableRow> |
|
|
} |
|
|
} |
|
|
</TableBody> |
|
|
</TableBody> |
|
|