2019-07-02 08:10:25 +01:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2019-08-03 07:00:45 +01:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import Icon from '../icon';
|
|
|
|
|
|
|
|
import './index.scss';
|
2019-07-02 08:10:25 +01:00
|
|
|
|
2019-07-29 20:20:00 +01:00
|
|
|
export default class ColumnBackButton extends PureComponent {
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
2019-08-03 07:00:45 +01:00
|
|
|
static propTypes = {
|
|
|
|
slim: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
2019-07-02 08:10:25 +01:00
|
|
|
handleClick = () => {
|
|
|
|
if (window.history && window.history.length === 1) {
|
2019-07-04 00:29:54 +01:00
|
|
|
this.context.router.history.push('/home'); // homehack
|
2019-07-02 08:10:25 +01:00
|
|
|
} else {
|
|
|
|
this.context.router.history.goBack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2019-08-03 07:00:45 +01:00
|
|
|
const { slim } = this.props;
|
|
|
|
|
|
|
|
const btnClasses = classNames('column-back-button', {
|
|
|
|
'column-back-button--slim': slim,
|
|
|
|
});
|
|
|
|
|
2019-07-02 08:10:25 +01:00
|
|
|
return (
|
2019-08-03 07:00:45 +01:00
|
|
|
<button className={btnClasses} onClick={this.handleClick}>
|
2019-07-02 08:10:25 +01:00
|
|
|
<Icon id='chevron-left' className='column-back-button__icon' fixedWidth />
|
|
|
|
<FormattedMessage id='column_back_button.label' defaultMessage='Back' />
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-08-03 07:00:45 +01:00
|
|
|
}
|