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() {
|
content() {
|
||||||
|
const num = this.props.searchResults.length;
|
||||||
const header = (
|
const header = (
|
||||||
<div className="searchResultHeader">
|
<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>);
|
</div>);
|
||||||
const entries = this.props.searchResults.map(
|
const entries = this.props.searchResults.map(
|
||||||
(entry, idx) => <Entry entry={ entry } key= { entry.id } />
|
(entry, idx) => <Entry entry={ entry } key= { entry.id } />
|
||||||
@ -55,7 +56,7 @@ class Results extends Component {
|
|||||||
const results = this.props.searchResults;
|
const results = this.props.searchResults;
|
||||||
return(
|
return(
|
||||||
<div className='results'>
|
<div className='results'>
|
||||||
{ results ? this.content() : "No results" }
|
{ results ? this.content() : "No search" }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -78,19 +79,25 @@ class App extends Component {
|
|||||||
searchSaimiar(evt) {
|
searchSaimiar(evt) {
|
||||||
const searchTerm = this.input.current.value;
|
const searchTerm = this.input.current.value;
|
||||||
const request = `saimiar?sai=like.*${searchTerm}*`
|
const request = `saimiar?sai=like.*${searchTerm}*`
|
||||||
makeRequest(request, (json) => {
|
if (searchTerm === "") {
|
||||||
const searchResults = json.length === 0 ? null : json;
|
this.setState({ searchResults: null, searchTerm: null, searchType: null });
|
||||||
this.setState({ searchResults, searchType: "saimiar", searchTerm });
|
} else {
|
||||||
});
|
makeRequest(request, (json) => {
|
||||||
|
this.setState({ searchResults: json, searchType: "saimiar", searchTerm });
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchEng(evt) {
|
searchEng(evt) {
|
||||||
const searchTerm = this.input.current.value;
|
const searchTerm = this.input.current.value;
|
||||||
const request = `saimiar?eng=like.*${searchTerm}*`
|
const request = `saimiar?eng=like.*${searchTerm}*`
|
||||||
makeRequest(request, (json) => {
|
if (searchTerm === "") {
|
||||||
const searchResults = json.length === 0 ? null : json;
|
this.setState({ searchResults: null, searchTerm: null, searchType: null });
|
||||||
this.setState({ searchResults, searchType: "eng-saimiar", searchTerm });
|
} else {
|
||||||
});
|
makeRequest(request, (json) => {
|
||||||
|
this.setState({ searchResults: json, searchType: "eng-saimiar", searchTerm });
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
Loading…
Reference in New Issue
Block a user