2020-03-27 13:59:38 -07:00
import React from 'react' ;
import PropTypes from 'prop-types' ;
import ImmutablePropTypes from 'react-immutable-proptypes' ;
import { connect } from 'react-redux' ;
import { defineMessages , injectIntl , FormattedMessage } from 'react-intl' ;
import Avatar from '../../../components/avatar' ;
import ImmutablePureComponent from 'react-immutable-pure-component' ;
import IconButton from 'gabsocial/components/icon_button' ;
const messages = defineMessages ( {
close : { id : 'lightbox.close' , defaultMessage : 'Close' } ,
} ) ;
const mapStateToProps = state => {
2020-04-01 19:20:47 -07:00
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-01 13:31:40 -07:00
const { intl , onClose , account , 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' >
< h3 className = 'compose-modal__header__title' > < FormattedMessage id = 'unauthorized_modal.title' defaultMessage = 'Sign up for {site_title}' values = { { site _title : siteTitle } } / > < / h 3 >
< IconButton className = 'compose-modal__close' title = { intl . formatMessage ( messages . close ) } icon = 'times' onClick = { this . onClickClose } size = { 20 } / >
< / d i v >
< 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.' / >
< / s p a n >
< a href = '/auth/sign_up' className = 'unauthorized-modal-content__button button' >
< FormattedMessage id = 'account.register' defaultMessage = 'Sign up' / >
< / a >
< / d i v >
< / d i v >
< div className = 'unauthorized-modal__footer' >
< FormattedMessage id = 'unauthorized_modal.footer' defaultMessage = 'Already have an account? {login}.' values = { {
login : < a href = '/auth/sign_in' > < FormattedMessage id = 'account.login' defaultMessage = 'Log in' / > < / a >
} } / >
< / d i v >
< / d i v >
) ;
}
}
export default injectIntl ( connect ( mapStateToProps ) ( UnauthorizedModal ) ) ;