Commit 35e2fcda authored by roadscape's avatar roadscape
Browse files

form cleanup

parent ce1bb0f3
...@@ -4,6 +4,7 @@ import { connect } from 'react-redux'; ...@@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import * as communityActions from 'app/redux/CommunityReducer'; import * as communityActions from 'app/redux/CommunityReducer';
import tt from 'counterpart'; import tt from 'counterpart';
import { key_utils } from '@steemit/steem-js/lib/auth/ecc'; import { key_utils } from '@steemit/steem-js/lib/auth/ecc';
import LoadingIndicator from 'app/components/elements/LoadingIndicator';
class CreateCommunity extends React.Component { class CreateCommunity extends React.Component {
constructor() { constructor() {
...@@ -32,6 +33,7 @@ class CreateCommunity extends React.Component { ...@@ -32,6 +33,7 @@ class CreateCommunity extends React.Component {
updateCommunityOwnerWifPassword, updateCommunityOwnerWifPassword,
broadcastOps, broadcastOps,
communityCreationPending, communityCreationPending,
socialUrl,
} = this.props; } = this.props;
const handleAccountCreateError = error => { const handleAccountCreateError = error => {
...@@ -160,49 +162,41 @@ class CreateCommunity extends React.Component { ...@@ -160,49 +162,41 @@ class CreateCommunity extends React.Component {
/> />
); );
const createCommunityAccountSuccessMessage = ( const createAccountOk = (
<div className="community-message community-message--progress"> <div className="community-message">
Community account created on the blockchain. Setting current Account created. Setting @{accountName} as admin...
user to be community admin...
</div> </div>
); );
const createCommunityAccountErrorMessage = ( const createAccountErr = (
<div className="community-message community-message--error"> <div className="community-message community-message--error">
Unable to create that community. Please ensure you used the Unable to create the community. Please ensure you used the
correct key. correct key.
</div> </div>
); );
const createCommunityBroadcastOpsErrorMessage = ( const updateSettingsErr = (
<div className="community-message community-message--error"> <div className="community-message community-message--error">
The community was created but setting current user to be admin The community was created but settings update failed.
failed. Wait a moment and try again
</div> </div>
); );
const createCommunitySuccessMessage = ( const createSuccess = (
<div className="community-message community-message--success"> <div className="community-message">
<p>Your community was created!</p> Your community was created!<br />
<a <strong>
href={`https://steemitdev.com/trending/${communityOwnerName}`} <a href={`${socialUrl}/trending/${communityOwnerName}`}>
> Get started.
{tt('g.community_visit')} </a>
</a> </strong>
</div> </div>
); );
const createCommunityErrorMessage = ( const createError = (
<div className="community-message community-message--error"> <div className="community-message community-message--error">
{tt('g.community_error')} {tt('g.community_error')}
</div> </div>
); );
const createCommunityLoading = (
<div className="community-message community-message--progress">
{tt('g.community_creating')}
</div>
);
const createCommunityForm = ( const createCommunityForm = (
<form onSubmit={handleCommunitySubmit}> <form onSubmit={handleCommunitySubmit}>
<label htmlFor="community_title" className="community__label"> <label htmlFor="community_title" className="community__label">
...@@ -227,11 +221,9 @@ class CreateCommunity extends React.Component { ...@@ -227,11 +221,9 @@ class CreateCommunity extends React.Component {
id="community_description" id="community_description"
name="community_description" name="community_description"
type="text" type="text"
minLength="10" maxLength="120"
maxLength="140"
onChange={handleCommunityDescriptionInput} onChange={handleCommunityDescriptionInput}
value={communityDescription} value={communityDescription}
required
/> />
</label> </label>
{communityOwnerWifPassword.length <= 0 && {communityOwnerWifPassword.length <= 0 &&
...@@ -250,13 +242,11 @@ class CreateCommunity extends React.Component { ...@@ -250,13 +242,11 @@ class CreateCommunity extends React.Component {
<div className="row"> <div className="row">
<div className="column large-6 small-12"> <div className="column large-6 small-12">
<div>{tt('g.community_create')}</div> <div>{tt('g.community_create')}</div>
{this.state.accountError && {this.state.accountError && createAccountErr}
createCommunityAccountErrorMessage}
{this.state.accountCreated && {this.state.accountCreated &&
!communityCreateSuccess && !communityCreateSuccess &&
createCommunityAccountSuccessMessage} createAccountOk}
{this.state.broadcastOpsError && {this.state.broadcastOpsError && updateSettingsErr}
createCommunityBroadcastOpsErrorMessage}
{this.state.accountError && createCommunityForm} {this.state.accountError && createCommunityForm}
{this.state.broadcastOpsError && createCommunityForm} {this.state.broadcastOpsError && createCommunityForm}
{!communityCreatePending && {!communityCreatePending &&
...@@ -264,10 +254,11 @@ class CreateCommunity extends React.Component { ...@@ -264,10 +254,11 @@ class CreateCommunity extends React.Component {
createCommunityForm} createCommunityForm}
{communityCreatePending && {communityCreatePending &&
!this.state.accountError && !this.state.accountError &&
!this.state.broadcastOpsError && !this.state.broadcastOpsError && (
createCommunityLoading} <LoadingIndicator type="circle" />
{communityCreateSuccess && createCommunitySuccessMessage} )}
{communityCreateError && createCommunityErrorMessage} {communityCreateSuccess && createSuccess}
{communityCreateError && createError}
</div> </div>
</div> </div>
); );
...@@ -282,11 +273,13 @@ export default connect( ...@@ -282,11 +273,13 @@ export default connect(
const current = state.user.get('current'); const current = state.user.get('current');
const username = current && current.get('username'); const username = current && current.get('username');
const isMyAccount = username === accountName; const isMyAccount = username === accountName;
const socialUrl = state.app.get('socialUrl');
return { return {
...ownProps, ...ownProps,
...state.community.toJS(), ...state.community.toJS(),
isMyAccount, isMyAccount,
accountName, accountName,
socialUrl,
}; };
}, },
// mapDispatchToProps // mapDispatchToProps
......
...@@ -26,15 +26,7 @@ ...@@ -26,15 +26,7 @@
} }
.community-message { .community-message {
font-weight: bold; font-weight: normal;
}
.community-message--progress {
color: rgb(0, 153, 0)
}
.community-message--success {
color: rgb(0,0,204)
} }
.community-message--error { .community-message--error {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment