Ergonomic improvements
This commit is contained in:
parent
0327c545d2
commit
6953ebad52
27
App.jsx
27
App.jsx
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user