aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/components/container/Results.tsx
blob: 21d33786697f95d6f5d2ec569e66d420f36f3cc2 (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
import * as React from 'react';
import { connect } from 'react-redux';
import * as classnames from 'classnames';
import Result from '../presentational/Result';
import { User } from '../../users';
import { State } from '../../reducers';

const Results: React.StatelessComponent<{ results: string[], isExactMatch: boolean, selectedResult: string }> = (props) => (
  <div
    className={classnames('search__results', {
      'search__results--has-results': !props.isExactMatch && props.results.length > 0,
    })}
  >
    {!props.isExactMatch && props.results.map(userId => (
      <Result key={userId} userId={userId} isSelected={userId === props.selectedResult} />
    ))}
  </div>
);

const mapStateToProps = (state: State) => ({
  results: state.search.results,
  isExactMatch: state.search.isExactMatch,
  selectedResult: state.search.selectedResult,
});

export default connect(mapStateToProps)(Results);