2023-05-23 17:52:27 +09:00
import { useCallback } from 'react' ;
2022-09-29 11:39:33 +09:00
import { FormattedMessage } from 'react-intl' ;
2022-10-27 02:35:55 +09:00
import { useDispatch } from 'react-redux' ;
2022-09-29 13:21:51 +09:00
import { registrationsOpen } from 'mastodon/initial_state' ;
2022-10-27 02:35:55 +09:00
import { openModal } from 'mastodon/actions/modal' ;
2022-09-29 11:39:33 +09:00
2022-10-27 02:35:55 +09:00
const SignInBanner = ( ) => {
const dispatch = useDispatch ( ) ;
const openClosedRegistrationsModal = useCallback (
( ) => dispatch ( openModal ( 'CLOSED_REGISTRATIONS' ) ) ,
[ dispatch ] ,
) ;
let signupButton ;
if ( registrationsOpen ) {
signupButton = (
2023-05-11 03:17:55 +09:00
< a href = '/auth/sign_up' className = 'button button--block' >
2022-10-27 02:35:55 +09:00
< FormattedMessage id = 'sign_in_banner.create_account' defaultMessage = 'Create account' / >
< / a >
) ;
} else {
signupButton = (
2023-05-11 03:17:55 +09:00
< button className = 'button button--block' onClick = { openClosedRegistrationsModal } >
2022-10-27 02:35:55 +09:00
< FormattedMessage id = 'sign_in_banner.create_account' defaultMessage = 'Create account' / >
< / button >
) ;
}
return (
< div className = 'sign-in-banner' >
2023-05-11 03:17:55 +09:00
< p > < FormattedMessage id = 'sign_in_banner.text' defaultMessage = 'Login to follow profiles or hashtags, favourite, share and reply to posts. You can also interact from your account on a different server.' / > < / p >
2022-10-27 02:35:55 +09:00
{ signupButton }
2023-05-11 03:17:55 +09:00
< a href = '/auth/sign_in' className = 'button button--block button-tertiary' > < FormattedMessage id = 'sign_in_banner.sign_in' defaultMessage = 'Login' / > < / a >
2022-10-27 02:35:55 +09:00
< / div >
) ;
} ;
2022-09-29 11:39:33 +09:00
export default SignInBanner ;