All files / posts-table/components/PostsTable/components/PostsHeader index.jsx

80% Statements 4/5
100% Branches 0/0
0% Functions 0/1
80% Lines 4/5
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73                1x             1x                                                             1x                                         1x          
import React from 'react';
import PropTypes from 'prop-types';
 
import PostOrderSwitch from './components/PostOrderSwitch';
import TopPostsDropdown from './components/TopPostsDropdown';
import PostsCountBar from './components/PostsCountBar';
import Searchbox from '../Searchbox/index.jsx';
 
const topPostsHeaderContainer = {
  padding: '0.75rem 1.5rem 1.5rem',
  display: 'flex',
  justifyContent: 'space-between',
  alignItems: 'center',
};
 
const TopPostsHeader = ({
  metrics,
  selectedMetric,
  isDropdownOpen,
  isDescendingSelected,
  selectMetric,
  toggleDropdown,
  handlePostsCountClick,
  handlePostsSortClick,
  activePostsCount,
  postsCounts,
  search,
  searchTerms,
}) =>
  <div style={topPostsHeaderContainer}>
    <Searchbox search={search} searchTerms={searchTerms} />
    <TopPostsDropdown
      metrics={metrics}
      selectedMetric={selectedMetric}
      isDropdownOpen={isDropdownOpen}
      isDescendingSelected={isDescendingSelected}
      selectMetric={selectMetric}
      toggleDropdown={toggleDropdown}
    />
    <PostOrderSwitch
      handleClick={handlePostsSortClick}
      isDescendingSelected={isDescendingSelected}
    />
  </div>
  ;
 
TopPostsHeader.propTypes = {
  metrics: PropTypes.arrayOf(PropTypes.shape({
    key: PropTypes.string.isRequired,
    label: PropTypes.string.isRequired,
  })).isRequired,
  selectedMetric: PropTypes.shape({
    key: PropTypes.string,
    label: PropTypes.string,
  }).isRequired,
  isDropdownOpen: PropTypes.bool.isRequired,
  isDescendingSelected: PropTypes.bool.isRequired,
  selectMetric: PropTypes.func.isRequired,
  toggleDropdown: PropTypes.func.isRequired,
  handlePostsCountClick: PropTypes.func.isRequired,
  handlePostsSortClick: PropTypes.func.isRequired,
  activePostsCount: PropTypes.number.isRequired,
  postsCounts: PropTypes.arrayOf(PropTypes.shape({
    value: PropTypes.string,
  })),
};
 
TopPostsHeader.defaultProps = {
  postsCounts: undefined,
};
 
export default TopPostsHeader;