Commit de88d337 authored by / /\ / /\/'s avatar / /\ / /\/
Browse files

working error handling on account create

parent dcd1b297
......@@ -8,13 +8,24 @@ import { key_utils } from '@steemit/steem-js/lib/auth/ecc';
class CreateCommunity extends React.Component {
constructor() {
super();
this.state = { error: false };
this.state = { error: false, errorMessage: '' };
}
componentDidUpdate(prevProps, prevState) {
if (this.props.hasTransactionError && !prevProps.hasTransactionError) {
this.setState({
errorMessage: 'There was a transaction error.',
});
}
if (this.props.loginError && !prevProps.loginError) {
this.setState({
errorMessage: 'There was a credentials error.',
});
}
}
render() {
const errorCB = () => {
debugger;
// Can we dispatch from within here.
this.setState({ error: true });
};
......@@ -41,8 +52,6 @@ class CreateCommunity extends React.Component {
hasTransactionError,
} = this.props;
console.log(this.state.error);
const handleCommunityTitleInput = e => {
if (e.target.value.length > 32) {
return;
......@@ -70,6 +79,7 @@ class CreateCommunity extends React.Component {
communityOwnerWifPassword,
};
createCommunity(createCommunitypayload, errorCB);
this.setState({ error: false, errorMessage: '' });
};
const generateCommunityOwnerName = () => {
......@@ -148,17 +158,15 @@ class CreateCommunity extends React.Component {
);
const createCommunityErrorMessage = (
<div>{tt('g.community_error')}</div>
<div>
<div>{tt('g.community_error')}</div>
<div>{this.state.errorMessage}</div>
<div>{tt('g.community_create_try_again')} </div>
</div>
);
const createCommunityLoadingMessage = (
<div>{tt('g.community_creating')}</div>
);
const createCommunityPasswordError = (
<div>
<div>{tt('g.community_create_password_error')}</div>
<div>{loginError}</div>
</div>
);
const createCommunityCustomOpsPendingMessage = (
<div>{`${tt(
'g.community_broadcasting_custom_ops'
......@@ -222,12 +230,14 @@ class CreateCommunity extends React.Component {
return (
<div className="row">
<div className="column large-6 small-12">
{loginError && createCommunityPasswordError}
{hasTransactionError && <div>THERE WAS AN ERROR!</div>}
{this.state.error && createCommunityErrorMessage}
{this.state.error && createCommunityForm}
{!communityCreatePending &&
!communityCreateSuccess &&
createCommunityForm}
{communityCreatePending && createCommunityLoadingMessage}
{communityCreatePending &&
!this.state.error &&
createCommunityLoadingMessage}
{communityHivemindOperationPending &&
createCommunityCustomOpsPendingMessage}
{communityCreateSuccess && createCommunitySuccessMessage}
......
......@@ -27,6 +27,7 @@
"community_creating": "Your community is being created...",
"community_create_password_error":
"There was a problem with your credentials:",
"community_create_try_again": "Please try again:",
"community_broadcasting_custom_ops": "Making",
"community_broadcasting_custom_ops_1": "administrator of the",
"community_broadcasting_custom_ops_2": "community.",
......
......@@ -75,7 +75,6 @@ export default function reducer(state = defaultState, action) {
}
case CREATE_COMMUNITY_ERROR: {
const err = fromJS(payload);
debugger;
return state.merge({ communityCreateError: err });
}
case CREATE_COMMUNITY_SUCCESS: {
......@@ -138,7 +137,6 @@ export const createCommunityAccountPending = payload => ({
});
export const createCommunityAccountError = payload => {
debugger;
return {
type: CREATE_COMMUNITY_ACCOUNT_ERROR,
payload,
......
......@@ -40,7 +40,6 @@ export const communityWatches = [
),
];
export function* createAccountError(action) {
debugger;
yield put({
type: communityActions.CREATE_COMMUNITY_ACCOUNT_PENDING,
payload: false,
......@@ -187,8 +186,6 @@ export function* createCommunityAccount(createCommunityAction) {
successCallback();
},
errorCallback: res => {
debugger;
console.log('error', res);
errorCallback(res);
},
})
......
......@@ -28,7 +28,6 @@ export default function reducer(state = defaultState, action) {
const operation = fromJS(payload.operation);
const confirm = payload.confirm;
const warning = payload.warning;
debugger;
return state.merge({
show_confirm_modal: true,
confirmBroadcastOperation: operation,
......
......@@ -132,7 +132,6 @@ export function* broadcastOperation({
const warning = tt('g.post_key_warning.warning');
const checkbox = tt('g.post_key_warning.checkbox');
operationParam.allowPostUnsafe = true;
debugger;
yield put(
transactionActions.confirmOperation({
confirm,
......@@ -183,7 +182,6 @@ export function* broadcastOperation({
serverApiRecordEvent(eventType, page);
} catch (error) {
console.error('TransactionSage', error);
debugger;
if (errorCallback) errorCallback(error.toString());
}
}
......
......@@ -203,7 +203,6 @@ export default function reducer(state = defaultState, action) {
});
case LOGIN_ERROR:
debugger;
return state.merge({
login_error: payload.error,
logged_out: undefined,
......
......@@ -219,7 +219,6 @@ function* usernamePasswordLogin({
Set()
);
if (!fullAuths.size) {
debugger;
console.log('No full auths');
localStorage.removeItem('autopost2');
const generated_type = password[0] === 'P' && password.length > 40;
......
......@@ -23,7 +23,6 @@ export function serverApiLogout() {
const request = Object.assign({}, request_base, {
body: JSON.stringify({ csrf: $STM_csrf }),
});
debugger;
return fetch('/api/v1/logout_account', request);
}
......
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