import React, { PropTypes } from 'react' import { connect } from 'react-redux' import classnames from 'classnames' import columns from './FlowColumns' import { updateSorter } from '../../ducks/views/main' FlowTableHead.propTypes = { onSort: PropTypes.func.isRequired, sortDesc: React.PropTypes.bool.isRequired, sortColumn: React.PropTypes.string, } function FlowTableHead({ sortColumn, sortDesc, onSort }) { const sortType = sortDesc ? 'sort-desc' : 'sort-asc' return ( {columns.map(Column => ( onSort(Column.name, Column.name !== sortColumn ? false : !sortDesc)}> {Column.headerName} ))} ) } export default connect( state => ({ sortDesc: state.flows.views.main.sorter.desc, sortColumn: state.flows.views.main.sorter.column, }), { onSort: updateSorter, } )(FlowTableHead)