2022-10-26 20:35:55 +03:00
import React , { useCallback } from 'react' ;
2022-09-29 05:39:33 +03:00
import { FormattedMessage } from 'react-intl' ;
2022-10-26 20:35:55 +03:00
import { useDispatch } from 'react-redux' ;
2022-09-29 07:21:51 +03:00
import { registrationsOpen } from 'mastodon/initial_state' ;
2022-10-26 20:35:55 +03:00
import { openModal } from 'mastodon/actions/modal' ;
2022-09-29 05:39:33 +03:00
2022-10-26 20:35:55 +03:00
const SignInBanner = ( ) => {
const dispatch = useDispatch ( ) ;
const openClosedRegistrationsModal = useCallback (
( ) => dispatch ( openModal ( 'CLOSED_REGISTRATIONS' ) ) ,
[ dispatch ] ,
) ;
let signupButton ;
if ( registrationsOpen ) {
signupButton = (
< a href = '/auth/sign_up' className = 'button button--block button-tertiary' >
< FormattedMessage id = 'sign_in_banner.create_account' defaultMessage = 'Create account' / >
< / a >
) ;
} else {
signupButton = (
< button className = 'button button--block button-tertiary' onClick = { openClosedRegistrationsModal } >
< FormattedMessage id = 'sign_in_banner.create_account' defaultMessage = 'Create account' / >
< / b u t t o n >
) ;
}
return (
< div className = 'sign-in-banner' >
< p > < FormattedMessage id = 'sign_in_banner.text' defaultMessage = 'Sign in to follow profiles or hashtags, favourite, share and reply to posts, or interact from your account on a different server.' / > < / p >
< a href = '/auth/sign_in' className = 'button button--block' > < FormattedMessage id = 'sign_in_banner.sign_in' defaultMessage = 'Sign in' / > < / a >
{ signupButton }
< / d i v >
) ;
} ;
2022-09-29 05:39:33 +03:00
export default SignInBanner ;