RegistrationForm: refactor isOpen logic

v1.x.x
Alex Gleason 2021-09-24 11:43:28 -05:00
rodzic 937cc18012
commit 6f7e0c75b4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 26 dodań i 23 usunięć

Wyświetl plik

@ -140,32 +140,11 @@ class RegistrationForm extends ImmutablePureComponent {
render() {
const { instance, intl, supportsEmailList } = this.props;
const { params } = this.state;
const isOpen = instance.get('registrations');
const isLoading = this.state.captchaLoading || this.state.submissionLoading;
if (isOpen === false) {
return (
<div className='registrations-closed'>
<h2>
<FormattedMessage
id='registration.closed_title'
defaultMessage='Registrations Closed'
/>
</h2>
<div className='registrations-closed__message'>
<FormattedMessage
id='registration.closed_message'
defaultMessage='{instance} is not accepting new members'
values={{ instance: <strong>{instance.get('title')}</strong> }}
/>
</div>
</div>
);
}
return (
<SimpleForm onSubmit={this.onSubmit}>
<fieldset disabled={isLoading || !isOpen}>
<fieldset disabled={isLoading}>
<div className='simple_form__overlay-area'>
<div className='fields-group'>
<TextInput

Wyświetl plik

@ -1,5 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
import { FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { Link } from 'react-router-dom';
import RegistrationForm from '../auth_login/components/registration_form';
@ -11,8 +12,31 @@ const mapStateToProps = (state, props) => ({
class LandingPage extends ImmutablePureComponent {
renderClosed = () => {
const { instance } = this.props;
return (
<div className='registrations-closed'>
<h2>
<FormattedMessage
id='registration.closed_title'
defaultMessage='Registrations Closed'
/>
</h2>
<div className='registrations-closed__message'>
<FormattedMessage
id='registration.closed_message'
defaultMessage='{instance} is not accepting new members'
values={{ instance: <strong>{instance.get('title')}</strong> }}
/>
</div>
</div>
);
}
render() {
const { instance } = this.props;
const isOpen = instance.get('registrations', false) === true;
return (
<div className='landing'>
@ -28,7 +52,7 @@ class LandingPage extends ImmutablePureComponent {
</div>
</div>
<div className='landing-columns--right'>
<RegistrationForm />
{isOpen ? <RegistrationForm /> : this.renderClosed()}
</div>
</div>
</div>