bigbuffet-rw/app/soapbox/features/ui/components/unauthorized_modal.js

65 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
2020-06-07 14:55:28 -07:00
import { Link } from 'react-router-dom';
2020-03-27 13:59:38 -07:00
import ImmutablePureComponent from 'react-immutable-pure-component';
2020-05-28 15:52:07 -07:00
import IconButton from 'soapbox/components/icon_button';
2020-03-27 13:59:38 -07:00
const messages = defineMessages({
close: { id: 'lightbox.close', defaultMessage: 'Close' },
});
const mapStateToProps = state => {
const me = state.get('me');
2020-03-27 13:59:38 -07:00
return {
account: state.getIn(['accounts', me]),
2020-04-01 13:31:40 -07:00
siteTitle: state.getIn(['instance', 'title']),
2020-03-27 13:59:38 -07:00
};
};
class UnauthorizedModal extends ImmutablePureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
onClose: PropTypes.func.isRequired,
};
onClickClose = () => {
this.props.onClose('UNAUTHORIZED');
};
render() {
2020-04-14 13:45:38 -07:00
const { intl, siteTitle } = this.props;
2020-03-27 13:59:38 -07:00
return (
<div className='modal-root__modal compose-modal unauthorized-modal'>
<div className='compose-modal__header'>
2020-04-14 11:44:40 -07:00
<h3 className='compose-modal__header__title'><FormattedMessage id='unauthorized_modal.title' defaultMessage='Sign up for {site_title}' values={{ site_title: siteTitle }} /></h3>
2020-03-27 13:59:38 -07:00
<IconButton className='compose-modal__close' title={intl.formatMessage(messages.close)} icon='times' onClick={this.onClickClose} size={20} />
</div>
<div className='compose-modal__content'>
<div className='unauthorized-modal__content'>
<span className='unauthorized-modal-content__text'>
<FormattedMessage id='unauthorized_modal.text' defaultMessage='You need to be logged in to do that.' />
</span>
2020-06-07 14:55:28 -07:00
<Link to='/' className='unauthorized-modal-content__button button'>
2020-03-27 13:59:38 -07:00
<FormattedMessage id='account.register' defaultMessage='Sign up' />
2020-06-07 14:55:28 -07:00
</Link>
2020-03-27 13:59:38 -07:00
</div>
</div>
<div className='unauthorized-modal__footer'>
2020-04-14 11:44:40 -07:00
<FormattedMessage
id='unauthorized_modal.footer' defaultMessage='Already have an account? {login}.' values={{
2020-06-07 14:55:28 -07:00
login: <Link to='/auth/sign_in'><FormattedMessage id='account.login' defaultMessage='Log in' /></Link>,
2020-04-14 11:44:40 -07:00
}}
/>
2020-03-27 13:59:38 -07:00
</div>
</div>
);
}
2020-04-14 11:44:40 -07:00
2020-03-27 13:59:38 -07:00
}
export default injectIntl(connect(mapStateToProps)(UnauthorizedModal));