From efce4ccbe92bf4a9549683d5ecc29cf20816c49b Mon Sep 17 00:00:00 2001 From: geek Date: Mon, 14 Aug 2017 15:16:52 +0900 Subject: [PATCH] member signup redirect --- src/ts/@overflow/member/react/SignUp.tsx | 6 +- .../member/react/components/SignUp.tsx | 92 ++++++++++--------- .../@overflow/member/redux/reducer/signUp.ts | 16 +++- src/ts/@overflow/member/redux/state/SignUp.ts | 2 +- 4 files changed, 68 insertions(+), 48 deletions(-) diff --git a/src/ts/@overflow/member/react/SignUp.tsx b/src/ts/@overflow/member/react/SignUp.tsx index 87beda6..2648b74 100644 --- a/src/ts/@overflow/member/react/SignUp.tsx +++ b/src/ts/@overflow/member/react/SignUp.tsx @@ -9,12 +9,13 @@ import { import State from '../redux/state/SignUp'; import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; - +import { push as routerPush } from 'react-router-redux'; import * as signupActions from '../redux/action/signUp'; export function mapStateToProps(state: any): SignUpStateProps { return { + member: state.member, }; } @@ -24,6 +25,9 @@ export function mapDispatchToProps(dispatch: Dispatch): SignUpDispatchProps dispatch(asyncRequestActions.request('MemberService', 'signup', signupActions.REQUEST, JSON.stringify(member))); // dispatch(signupActions.request(member)); }, + onRedirectHome: () => { + dispatch(routerPush('/')); + }, }; } diff --git a/src/ts/@overflow/member/react/components/SignUp.tsx b/src/ts/@overflow/member/react/components/SignUp.tsx index 08eccb4..504574e 100644 --- a/src/ts/@overflow/member/react/components/SignUp.tsx +++ b/src/ts/@overflow/member/react/components/SignUp.tsx @@ -10,10 +10,12 @@ import { import MemberStatus from '../../api/model/MemberStatus'; export interface StateProps { + member?:Member; } export interface DispatchProps { onSignUp?(member: Member): void; + onRedirectHome():void; } export type Props = StateProps & DispatchProps; @@ -56,48 +58,54 @@ export class SignUp extends React.Component { } public render(): JSX.Element { - return ( -
- , data: InputOnChangeData) => { - this.setState({ email: data.value }); - }} /> - , data: InputOnChangeData) => { - this.setState({ name: data.value }); - } - }/> - , data: InputOnChangeData) => { - this.setState({ pass: data.value }); - } - } /> - , data: InputOnChangeData) => { - this.setState({ passCon: data.value }); - } - } /> - , data: InputOnChangeData) => { - this.setState({ company: data.value }); - } - }/> - , data: InputOnChangeData) => { - this.setState({ country: data.value }); - } - } /> - , data: InputOnChangeData) => { - this.setState({ phone: data.value }); - } - } /> - - - - - - ); + + let signupElement =
+ , data: InputOnChangeData) => { + this.setState({ email: data.value }); + }} /> + , data: InputOnChangeData) => { + this.setState({ name: data.value }); + } + }/> + , data: InputOnChangeData) => { + this.setState({ pass: data.value }); + } + } /> + , data: InputOnChangeData) => { + this.setState({ passCon: data.value }); + } + } /> + , data: InputOnChangeData) => { + this.setState({ company: data.value }); + } + }/> + , data: InputOnChangeData) => { + this.setState({ country: data.value }); + } + } /> + , data: InputOnChangeData) => { + this.setState({ phone: data.value }); + } + } /> + + + + + ; + if (this.props.member !== undefined && this.props.member.id > 0) { + // Todo Please check the member registration e-mail. + this.props.onRedirectHome(); + } else { + return signupElement; + } + } private signUpClick = (event: React.SyntheticEvent, data: ButtonProps):void => { diff --git a/src/ts/@overflow/member/redux/reducer/signUp.ts b/src/ts/@overflow/member/redux/reducer/signUp.ts index 3665a40..380e98f 100644 --- a/src/ts/@overflow/member/redux/reducer/signUp.ts +++ b/src/ts/@overflow/member/redux/reducer/signUp.ts @@ -5,12 +5,20 @@ import Member from '@overflow/member/api/model/Member'; import * as SignUpActionTypes from '../action/signUp'; import SignUpState, { defaultState as signupDefaultState } from '../state/SignUp'; +// +// [SignUpActionTypes.REQUEST_SUCCESS]: (state: SignUpState = signupDefaultState, action: Action): SignUpState => { +// return { +// ...state, +// member: action.payload, +// }; +// }, const reducer: ReducersMapObject = { [SignUpActionTypes.REQUEST_SUCCESS]: (state: SignUpState = signupDefaultState, action: Action): SignUpState => { - console.log(state); - console.log(action); - - return state; + return { + ...state, + member: action.payload, + isRegistered: true, + }; }, [SignUpActionTypes.REQUEST_FAILURE]: (state: SignUpState = signupDefaultState, action: Action): SignUpState => { return state; diff --git a/src/ts/@overflow/member/redux/state/SignUp.ts b/src/ts/@overflow/member/redux/state/SignUp.ts index 6f774c2..b2bf488 100644 --- a/src/ts/@overflow/member/redux/state/SignUp.ts +++ b/src/ts/@overflow/member/redux/state/SignUp.ts @@ -1,7 +1,7 @@ import Member from '../../api/model/Member'; export interface State { - readonly isRegistered: boolean; + readonly isRegistered?: boolean; readonly member?: Member; readonly error?: Error; }