kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
RegistrationForm: refactor isOpen logic
rodzic
937cc18012
commit
6f7e0c75b4
|
@ -140,32 +140,11 @@ class RegistrationForm extends ImmutablePureComponent {
|
||||||
render() {
|
render() {
|
||||||
const { instance, intl, supportsEmailList } = this.props;
|
const { instance, intl, supportsEmailList } = this.props;
|
||||||
const { params } = this.state;
|
const { params } = this.state;
|
||||||
const isOpen = instance.get('registrations');
|
|
||||||
const isLoading = this.state.captchaLoading || this.state.submissionLoading;
|
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 (
|
return (
|
||||||
<SimpleForm onSubmit={this.onSubmit}>
|
<SimpleForm onSubmit={this.onSubmit}>
|
||||||
<fieldset disabled={isLoading || !isOpen}>
|
<fieldset disabled={isLoading}>
|
||||||
<div className='simple_form__overlay-area'>
|
<div className='simple_form__overlay-area'>
|
||||||
<div className='fields-group'>
|
<div className='fields-group'>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import RegistrationForm from '../auth_login/components/registration_form';
|
import RegistrationForm from '../auth_login/components/registration_form';
|
||||||
|
@ -11,8 +12,31 @@ const mapStateToProps = (state, props) => ({
|
||||||
|
|
||||||
class LandingPage extends ImmutablePureComponent {
|
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() {
|
render() {
|
||||||
const { instance } = this.props;
|
const { instance } = this.props;
|
||||||
|
const isOpen = instance.get('registrations', false) === true;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='landing'>
|
<div className='landing'>
|
||||||
|
@ -28,7 +52,7 @@ class LandingPage extends ImmutablePureComponent {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='landing-columns--right'>
|
<div className='landing-columns--right'>
|
||||||
<RegistrationForm />
|
{isOpen ? <RegistrationForm /> : this.renderClosed()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Ładowanie…
Reference in New Issue