gab-social/app/javascript/gabsocial/features/search/components/header/header.js
mgabdev 3d509c84a2 Another large update for all components
reorganization, linting, updating file imports, consolidation
warning: there will be errors in this commit
todo: update webpack, add missing styles, scss files, consolidate group page components.
2019-08-09 12:06:27 -04:00

57 lines
1.4 KiB
JavaScript

import { FormattedMessage } from 'react-intl';
import SectionHeadlineBar from '../../../../components/section_headline_bar';
const mapStateToProps = state => ({
value: state.getIn(['search', 'value']),
submitted: state.getIn(['search', 'submitted']),
});
export default @connect(mapStateToProps)
class Header extends PureComponent {
static propTypes = {
value: PropTypes.string,
submitted: PropTypes.bool,
};
state = {
submittedValue: '',
};
componentWillReceiveProps (nextProps) {
if (nextProps.submitted) {
const submittedValue = nextProps.value;
this.setState({submittedValue})
}
}
render () {
const { submittedValue } = this.state;
if (!submittedValue) {
return null;
}
return (
<div className='search-header'>
<div className='search-header__text-container'>
<h1 className='search-header__title-text'>
{submittedValue}
</h1>
</div>
<div className='search-header__type-filters'>
<div className='search-header__type-filters-tabs'>
<SectionHeadlineBar
items={[
{
to: '/search',
title: <FormattedMessage id='search_results.top' defaultMessage='Top' />
}
]}
/>
</div>
</div>
</div>
);
}
}