Skip to content
Snippets Groups Projects
Commit 1fc6575b authored by Esko Ikkala's avatar Esko Ikkala
Browse files

Simpler suggestions

parent 98b0b2c6
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ function renderSuggestionsContainer(options) { ...@@ -41,7 +41,7 @@ function renderSuggestionsContainer(options) {
} }
function getSuggestionValue(suggestion) { function getSuggestionValue(suggestion) {
return suggestion.label; return suggestion;
} }
const styles = theme => ({ const styles = theme => ({
......
...@@ -8,17 +8,19 @@ const styles = { ...@@ -8,17 +8,19 @@ const styles = {
fontWeight: 300, fontWeight: 300,
height: 10 height: 10
}; };
//
// const getCounts = (suggestion) => suggestion.datasets.map((dataset, index) => (
// <span key={dataset.datasetId}>
// {index > 0 ? ', ' : ''}
// {`${dataset.shortTitle}: ${dataset.count.value}`}
// </span>
// ));
const getCounts = (suggestion) => suggestion.datasets.map((dataset, index) => ( // <span> ({getCounts(suggestion)})</span>
<span key={dataset.datasetId}>
{index > 0 ? ', ' : ''}
{`${dataset.shortTitle}: ${dataset.count.value}`}
</span>
));
const SuggestionItem = ({ suggestion, query, isHighlighted }) => { const SuggestionItem = ({ suggestion, query, isHighlighted }) => {
const matches = match(suggestion.label, query); const matches = match(suggestion, query);
const parts = parse(suggestion.label, matches); const parts = parse(suggestion, matches);
return ( return (
<MenuItem <MenuItem
...@@ -39,14 +41,13 @@ const SuggestionItem = ({ suggestion, query, isHighlighted }) => { ...@@ -39,14 +41,13 @@ const SuggestionItem = ({ suggestion, query, isHighlighted }) => {
</span> </span>
); );
})} })}
<span> ({getCounts(suggestion)})</span>
</div> </div>
</MenuItem> </MenuItem>
); );
}; };
SuggestionItem.propTypes = { SuggestionItem.propTypes = {
suggestion: PropTypes.object.isRequired, suggestion: PropTypes.string.isRequired,
query: PropTypes.string.isRequired, query: PropTypes.string.isRequired,
isHighlighted: PropTypes.bool.isRequired, isHighlighted: PropTypes.bool.isRequired,
}; };
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
UPDATE_RESULTS, UPDATE_RESULTS,
CLEAR_RESULTS CLEAR_RESULTS
} from '../actions'; } from '../actions';
import suggestions from './suggestions'; //import suggestions from './suggestions';
import results from './results'; import results from './results';
export const INITIAL_STATE = { export const INITIAL_STATE = {
...@@ -42,7 +42,7 @@ const search = (state = INITIAL_STATE, action) => { ...@@ -42,7 +42,7 @@ const search = (state = INITIAL_STATE, action) => {
case UPDATE_SUGGESTIONS: case UPDATE_SUGGESTIONS:
return { return {
...state, ...state,
suggestions: suggestions(state.suggestions, action), suggestions: action.suggestions,
suggestionsQuery: state.query, suggestionsQuery: state.query,
fetchingSuggestions: false fetchingSuggestions: false
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment