2020-03-27 13:59:38 -07:00
|
|
|
import PropTypes from 'prop-types';
|
2022-01-10 14:17:52 -08:00
|
|
|
import React from 'react';
|
2020-03-27 13:59:38 -07:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { connect } from 'react-redux';
|
2020-03-27 13:59:38 -07:00
|
|
|
import { NavLink } from 'react-router-dom';
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
value: state.getIn(['search', 'value']),
|
|
|
|
submitted: state.getIn(['search', 'submitted']),
|
|
|
|
});
|
|
|
|
|
|
|
|
class Header extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
value: PropTypes.string,
|
|
|
|
submitted: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
|
|
|
state = {
|
|
|
|
submittedValue: '',
|
|
|
|
};
|
|
|
|
|
2020-07-04 16:41:41 -07:00
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
if (this.props.submitted) {
|
|
|
|
const submittedValue = this.props.value;
|
2020-04-14 11:44:40 -07:00
|
|
|
this.setState({ submittedValue });
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-14 14:47:35 -07:00
|
|
|
render() {
|
2020-03-27 13:59:38 -07:00
|
|
|
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='account__section-headline'>
|
|
|
|
<div className='search-header__type-filters-tabs'>
|
|
|
|
<NavLink to='/search' activeClassName='active'>
|
|
|
|
<FormattedMessage id='search_results.top' defaultMessage='Top' />
|
|
|
|
</NavLink>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2020-04-14 11:44:40 -07:00
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(Header);
|