Ergonomic improvements

This commit is contained in:
greg 2019-01-26 02:23:50 -08:00
parent 0327c545d2
commit 6953ebad52
1 changed files with 17 additions and 10 deletions

27
App.jsx
View File

@ -41,9 +41,10 @@ class Results extends Component {
}
content() {
const num = this.props.searchResults.length;
const header = (
<div className="searchResultHeader">
Searched for <b>{ this.props.searchTerm }</b> search type: { this.props.searchType }
Searched for <b>{ this.props.searchTerm }</b> search type: { this.props.searchType }, found { num } result(s)
</div>);
const entries = this.props.searchResults.map(
(entry, idx) => <Entry entry={ entry } key= { entry.id } />
@ -55,7 +56,7 @@ class Results extends Component {
const results = this.props.searchResults;
return(
<div className='results'>
{ results ? this.content() : "No results" }
{ results ? this.content() : "No search" }
</div>
);
}
@ -78,19 +79,25 @@ class App extends Component {
searchSaimiar(evt) {
const searchTerm = this.input.current.value;
const request = `saimiar?sai=like.*${searchTerm}*`
makeRequest(request, (json) => {
const searchResults = json.length === 0 ? null : json;
this.setState({ searchResults, searchType: "saimiar", searchTerm });
});
if (searchTerm === "") {
this.setState({ searchResults: null, searchTerm: null, searchType: null });
} else {
makeRequest(request, (json) => {
this.setState({ searchResults: json, searchType: "saimiar", searchTerm });
});
}
}
searchEng(evt) {
const searchTerm = this.input.current.value;
const request = `saimiar?eng=like.*${searchTerm}*`
makeRequest(request, (json) => {
const searchResults = json.length === 0 ? null : json;
this.setState({ searchResults, searchType: "eng-saimiar", searchTerm });
});
if (searchTerm === "") {
this.setState({ searchResults: null, searchTerm: null, searchType: null });
} else {
makeRequest(request, (json) => {
this.setState({ searchResults: json, searchType: "eng-saimiar", searchTerm });
});
}
}
render() {