blob: 1fb5f44a93f87e410442778b8d83fccd79ed1bde (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import classnames from 'classnames';
import Result from '../presentational/Result';
const Results = (({ results, isExactMatch, selectedResult }) => (
<div
className={classnames('search__results', {
'search__results--has-results': !isExactMatch && results.length > 0,
})}
style={{
minHeight: isExactMatch ? 0 : results.length * 54,
}}
>
{!isExactMatch && results.map(userId => (
<Result key={userId} userId={userId} isSelected={userId === selectedResult} />
))}
</div>
));
Results.propTypes = {
results: PropTypes.arrayOf(PropTypes.string).isRequired,
isExactMatch: PropTypes.bool.isRequired,
selectedResult: PropTypes.string,
};
Results.defaultProps = {
selectedResult: null,
};
const mapStateToProps = state => ({
results: state.search.results,
isExactMatch: state.search.isExactMatch,
selectedResult: state.search.selectedResult,
});
export default connect(mapStateToProps)(Results);
|