1ff70886a1
Co-authored-by: tobi <tobi.smethurst@protonmail.com> Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88 Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org> Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
55 lines
2.1 KiB
React
55 lines
2.1 KiB
React
import { useCallback } from "react";
|
|
|
|
import { FormattedMessage } from "react-intl";
|
|
|
|
|
|
import { openModal } from "mastodon/actions/modal";
|
|
import { registrationsOpen, sso_redirect } from "mastodon/initial_state";
|
|
import { useAppDispatch, useAppSelector } from "mastodon/store";
|
|
|
|
const SignInBanner = () => {
|
|
const dispatch = useAppDispatch();
|
|
|
|
const openClosedRegistrationsModal = useCallback(
|
|
() => dispatch(openModal({ modalType: "CLOSED_REGISTRATIONS" })),
|
|
[dispatch],
|
|
);
|
|
|
|
let signupButton;
|
|
|
|
const signupUrl = useAppSelector((state) => state.getIn(["server", "server", "registrations", "url"], null) || "/auth/sign_up");
|
|
|
|
if (sso_redirect) {
|
|
return (
|
|
<div className='sign-in-banner'>
|
|
<p><FormattedMessage id='sign_in_banner.text' defaultMessage='Login to follow profiles or hashtags, favorite, share and reply to posts. You can also interact from your account on a different server.' /></p>
|
|
<a href={sso_redirect} data-method='post' className='button button--block button-tertiary'><FormattedMessage id='sign_in_banner.sso_redirect' defaultMessage='Login or Register' /></a>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (registrationsOpen) {
|
|
signupButton = (
|
|
<a href={signupUrl} className='button button--block'>
|
|
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
|
</a>
|
|
);
|
|
} else {
|
|
signupButton = (
|
|
<button className='button button--block' onClick={openClosedRegistrationsModal}>
|
|
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
|
</button>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className='sign-in-banner'>
|
|
<p><FormattedMessage id='sign_in_banner.text' defaultMessage='Login to follow profiles or hashtags, favorite, share and reply to posts. You can also interact from your account on a different server.' /></p>
|
|
{signupButton}
|
|
<a href='/auth/sign_in' className='button button--block button-tertiary'><FormattedMessage id='sign_in_banner.sign_in' defaultMessage='Login' /></a>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SignInBanner;
|