Sign in page after register, account create dialog dismissal, ref accounts - id undefined, default messages for empty lists (transfers & accounts).

This commit is contained in:
Andrew Revinsky (DART)
2016-03-24 02:55:43 +03:00
parent 2c5b5b4132
commit 70b552a961
8 changed files with 63 additions and 77 deletions

View File

@@ -53,14 +53,15 @@ export function accountCreate(customerId, payload) {
id: accountId,
...payload
}));
dispatch(entityReceived(accountId, payload));
return dispatch(authenticate(true));
// dispatch(entityReceived(accountId, payload));
dispatch(authenticate(true));
return accountId;
})
.catch(err => {
debugger;
dispatch(accountCreateError(err));
return Promise.resolve({ error: err });
})
// return Promise.resolve({ error: err });
});
};
}

View File

@@ -10,7 +10,8 @@ import { entityReceived } from './entities';
import { storeCurrentEndpointKey } from "./configure";
//import { parseResponse } from "../utils/handleFetchResponse";
import { apiSignUp } from "../utils/api";
import { emailSignIn } from './signIn';
import { emailSignInFormUpdate } from './signIn';
import { push } from 'redux-router';
import T from '../constants/ACTION_TYPES';
@@ -38,9 +39,8 @@ export function emailSignUp(body) {
.then(({data}) => {
dispatch(emailSignUpComplete(data));
const { email } = body;
return new Promise((rs, rj) => {
dispatch(emailSignIn({ email })).then(rs).catch(rj);
});
dispatch(emailSignInFormUpdate('email', email));
dispatch(push('/signin'));
})
.catch(({errors}) => dispatch(emailSignUpError(errors)));

View File

@@ -20,7 +20,7 @@ export class TransfersTable extends React.Component {
return (<div className="text-danger">Errors..</div>);
}
const transfers = data.map(({
const transfers = data.length ? data.map(({
amount,
fromAccountId,
toAccountId,
@@ -35,7 +35,10 @@ export class TransfersTable extends React.Component {
<td><Money amount={ amount } /></td>
<td>{ description || 'N/a'}</td>
<td>{ status || 'N/a' }</td>
</tr>));
</tr>)) : (<tr>
<td colSpan={6}>No transfers for this account just yet.</td>
</tr>);
return (
<BS.Table striped bordered condensed hover>

View File

@@ -40,6 +40,10 @@ export default defineActionTypes({
CREATE_COMPLETE
CREATE_ERROR
CREATE_FORM_UPDATE
EDIT_START
EDIT_COMPLETE
EDIT_ERROR
EDIT_FORM_UPDATE
CREATE_REF_START
CREATE_REF_COMPLETE
CREATE_REF_ERROR

View File

@@ -18,23 +18,6 @@ import {emailSignUpFormUpdate, emailSignUp} from '../../actions/signUp';
class EmailSignUpForm extends React.Component {
static propTypes = {
//endpoint: PropTypes.string,
inputProps: PropTypes.shape({
email: PropTypes.object,
password: PropTypes.object,
passwordConfirmation: PropTypes.object,
submit: PropTypes.object
})
};
static defaultProps = {
inputProps: {
email: {},
password: {},
submit: {}
}
};
getEndpoint () {
return (
@@ -52,19 +35,15 @@ class EmailSignUpForm extends React.Component {
event.preventDefault();
let formData = { ...this.props.auth.signUp.form };
console.log(customerInfoMap(formData));
this.props.dispatch(emailSignUp(customerInfoMap(formData)));
}
render () {
try {
const disabled = (
this.props.auth.user.isSignedIn ||
this.props.auth.signUp.loading
);
const disabled = (
this.props.auth.user.isSignedIn ||
this.props.auth.signUp.loading
);
return (
<form className='redux-auth email-sign-up-form clearfix'
@@ -80,7 +59,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.fname', '')}
errors={read(this.props.auth, 'signUp.errors.fname', [])}
onChange={this.handleInput.bind(this, "fname")}
{...this.props.inputProps.fname} />
/>
<Input type="text"
label="Last name"
@@ -90,7 +69,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.lname', '')}
errors={read(this.props.auth, 'signUp.errors.lname', [])}
onChange={this.handleInput.bind(this, "lname")}
{...this.props.inputProps.lname} />
/>
<Input type="text"
label="Email"
@@ -100,7 +79,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.email', '')}
errors={read(this.props.auth, 'signUp.errors.email', [])}
onChange={this.handleInput.bind(this, "email")}
{...this.props.inputProps.email} />
/>
</IndexPanel>
@@ -115,7 +94,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.ssn', '')}
errors={read(this.props.auth, 'signUp.errors.ssn', [])}
onChange={this.handleInput.bind(this, "ssn")}
{...this.props.inputProps.ssn} />
/>
<Input type="text"
label="Phone"
@@ -126,7 +105,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.phoneNumber', '')}
errors={read(this.props.auth, 'signUp.errors.phoneNumber', [])}
onChange={this.handleInput.bind(this, "phoneNumber")}
{...this.props.inputProps.phoneNumber} />
/>
<Input type="text"
label="Address 1"
@@ -137,7 +116,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.address1', '')}
errors={read(this.props.auth, 'signUp.errors.address1', [])}
onChange={this.handleInput.bind(this, "address1")}
{...this.props.inputProps.address1} />
/>
<Input type="text"
label="Address 2"
@@ -148,7 +127,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.address2', '')}
errors={read(this.props.auth, 'signUp.errors.address2', [])}
onChange={this.handleInput.bind(this, "address2")}
{...this.props.inputProps.address2} />
/>
<Input type="text"
label="City"
@@ -159,7 +138,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.city', '')}
errors={read(this.props.auth, 'signUp.errors.city', {})}
onChange={this.handleInput.bind(this, "city")}
{...this.props.inputProps.city} />
/>
<Input type="text"
label="State"
@@ -170,7 +149,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.state', '')}
errors={read(this.props.auth, 'signUp.errors.state', [])}
onChange={this.handleInput.bind(this, "state")}
{...this.props.inputProps.state} />
/>
<Input type="text"
label="ZIP"
@@ -181,7 +160,7 @@ class EmailSignUpForm extends React.Component {
value={read(this.props.auth, 'signUp.form.zip', '')}
errors={read(this.props.auth, 'signUp.errors.zip', [])}
onChange={this.handleInput.bind(this, "zip")}
{...this.props.inputProps.zip} />
/>
</IndexPanel>
@@ -193,15 +172,12 @@ class EmailSignUpForm extends React.Component {
icon={<Glyphicon glyph="send" />}
disabled={disabled}
onClick={this.handleSubmit.bind(this)}
{ ...this.props.inputProps.submit } >
>
Sign Up
</ButtonLoader>
</form>
);
} catch (ex){
console.error('Render exception: ', ex);
return [' ERROR '];
}
}
}

View File

@@ -35,7 +35,7 @@ const otherAccountsReducer = (state = [], action ) => {
case T.ACCOUNTS.LIST_REF_COMPLETE: {
const { payload = {} } = action;
const accounts = Object.keys(payload).map(key => ((payload[key].id = payload[key].accountId), payload[key]));
const accounts = Object.keys(payload).map(key => payload[key]);
return [
...accounts
];
@@ -53,9 +53,17 @@ const createAccountReducer = createFormReducer([
T.ACCOUNTS.CREATE_FORM_UPDATE
]);
const editAccountReducer = createFormReducer([
T.ACCOUNTS.EDIT_START,
T.ACCOUNTS.EDIT_COMPLETE,
T.ACCOUNTS.EDIT_ERROR,
T.ACCOUNTS.EDIT_FORM_UPDATE
]);
export const accounts = combineReducers({
own: ownAccountsReducer,
other: otherAccountsReducer,
create: createAccountReducer
create: createAccountReducer,
edit: editAccountReducer
});

View File

@@ -50,8 +50,8 @@ class MyAccounts extends React.Component {
} = this.props.auth.user.attributes;
this.props.dispatch(A.accountCreate(customerId, payload))
.then(() => {
this.close.bind(this);
.then((accountId) => {
this.close();
return this.props.dispatch(A.fetchOwnAccounts(customerId));
})
.catch(err => {
@@ -61,7 +61,6 @@ class MyAccounts extends React.Component {
}
create3rdPartyAccountModal() {
this.setState({
show3rdPartyAccountModal: true
});
@@ -74,7 +73,7 @@ class MyAccounts extends React.Component {
this.props.dispatch(A.accountRefCreate(customerId, payload))
.then(() => {
this.close.bind(this);
this.close();
return this.props.dispatch(A.fetchOwnAccounts(customerId));
})
.catch(err => {
@@ -94,7 +93,9 @@ class MyAccounts extends React.Component {
remove3rdPartyAccountModalConfirmed(accountId) {
const { customerId } = this.props;
this.props.dispatch(A.deleteAccount(customerId, accountId))
.then(this.close.bind(this),
.then(() => {
this.close();
},
err => {
this.props.dispatch(A.errorMessageTimedOut(err && err.message || err));
this.close();
@@ -134,7 +135,11 @@ class MyAccounts extends React.Component {
zipCode
} = address;
const { showAccountModal, show3rdPartyAccountModal, showDeleteAccountModal } = this.state;
const {
showAccountModal,
show3rdPartyAccountModal,
showDeleteAccountModal } = this.state;
const { accountToRemove = null} = this.state;
const { error } = this.props;
@@ -182,6 +187,10 @@ class MyAccounts extends React.Component {
</tr>
));
const accounts = (!!(ownAccounts.length + refAccounts.length)) ? [].concat(ownAccounts, refAccounts) : (<tr>
<td colSpan={3}>No account exists: <Button bsStyle={"link"} onClick={this.createAccountModal.bind(this)}>create a new one</Button> or <Button bsStyle={"link"} onClick={this.create3rdPartyAccountModal.bind(this)}>add a recipient</Button></td>
</tr>);
return (
<div>
<PageHeader>
@@ -223,6 +232,7 @@ class MyAccounts extends React.Component {
</IndexPanel>
</Row>
<Table>
<thead>
<tr>
@@ -232,8 +242,7 @@ class MyAccounts extends React.Component {
</tr>
</thead>
<tbody>
{ ownAccounts }
{ refAccounts }
{ accounts }
</tbody>
</Table>

View File

@@ -50,25 +50,10 @@ const formValidation = (payload) => ['title', 'balance', 'description'].reduce((
export class NewAccountModal extends React.Component {
static propTypes = {
inputProps: PropTypes.shape({
title: PropTypes.object,
balance: PropTypes.object,
description: PropTypes.object,
submit: PropTypes.object
}),
action: PropTypes.func,
account: PropTypes.object.isRequired
};
static defaultProps = {
inputProps: {
title: {},
balance: {},
description: {},
submit: {}
}
};
handleSubmit(event) {
event.preventDefault();
@@ -156,7 +141,7 @@ export class NewAccountModal extends React.Component {
icon={<BS.Glyphicon glyph="plus" />}
disabled={disabled}
onClick={this.handleSubmit.bind(this)}
{...this.props.inputProps.submit}>
>
{actionLabel}
</ButtonLoader>
</BS.Modal.Footer>