Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Fix search no results and error #720

Merged
merged 1 commit into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/containers/Search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class Search extends Component {
currentPage: PropTypes.number,
perPage: PropTypes.number,
query: PropTypes.string,
results: PropTypes.arrayOf(verseType), // eslint-disable-line
results: PropTypes.arrayOf(PropTypes.string),
entities: PropTypes.arrayOf(verseType),
push: PropTypes.func.isRequired,
location: PropTypes.shape({ // eslint-disable-line
q: PropTypes.string,
Expand Down Expand Up @@ -119,9 +120,9 @@ class Search extends Component {
}

renderBody() {
const { isErrored, isLoading, results, options, query } = this.props;
const { isErrored, isLoading, results, entities, options, location: { query } } = this.props;

if (!query) {
if (!query || !query.q) {
return (
<h3 className="text-center" style={{ padding: '15%' }}>
<LocaleFormattedMessage id="search.nothing" defaultMessage="No search query." />
Expand Down Expand Up @@ -151,9 +152,9 @@ class Search extends Component {

return results.map(result => (
<Verse
verse={result}
match={result.match}
key={result.verseKey}
verse={entities[result]}
match={entities[result].match}
key={entities[result].verseKey}
tooltip={options.tooltip}
isSearched
/>
Expand Down Expand Up @@ -208,6 +209,7 @@ function mapStateToProps(state) {
took: state.searchResults.took,
query: state.searchResults.query,
results: state.searchResults.results,
entities: state.searchResults.entities,
options: state.options
};
}
Expand Down
3 changes: 2 additions & 1 deletion src/redux/modules/searchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default function reducer(state = initialState, action = {}) {
perPage: action.result.result.perPage,
took: action.result.result.took,
query: action.result.result.query,
results: action.result.result.results
results: action.result.result.results,
entities: action.result.entities.verses
};
case SEARCH_FAIL:
return {
Expand Down
1 change: 1 addition & 0 deletions src/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export { default as matchType } from './matchType';
export { default as recitationType } from './recitationType';
export { default as translationType } from './translationType';
export { default as contentType } from './contentType';
export { default as footNoteType } from './footNoteType';