From 22eaf7e5c284bc5d4ca4776fc72bb1cc383bc5e4 Mon Sep 17 00:00:00 2001 From: geek Date: Thu, 10 Aug 2017 18:49:31 +0900 Subject: [PATCH] signup --- src/ts/@overflow/app/config/index.ts | 3 ++ src/ts/@overflow/member/api/model/Member.ts | 1 + src/ts/@overflow/member/react/SignUp.tsx | 6 ++- .../member/react/components/SignUp.tsx | 18 ++++++++- .../@overflow/member/redux/action/signUp.ts | 39 ++----------------- .../@overflow/member/redux/reducer/signIn.ts | 1 + .../@overflow/member/redux/reducer/signOut.ts | 34 ++++++---------- .../@overflow/member/redux/reducer/signUp.ts | 37 +++++++----------- .../@overflow/member/redux/state/SignOut.ts | 11 ++++++ 9 files changed, 66 insertions(+), 84 deletions(-) diff --git a/src/ts/@overflow/app/config/index.ts b/src/ts/@overflow/app/config/index.ts index 25d011c..888c3b2 100644 --- a/src/ts/@overflow/app/config/index.ts +++ b/src/ts/@overflow/app/config/index.ts @@ -2,6 +2,8 @@ import { ReducersMapObject } from 'redux'; import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher'; import signInReducer from '@overflow/member/redux/reducer/signIn'; +import signUpReducer from '@overflow/member/redux/reducer/signUp'; + import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain'; import readProbeReducer from '@overflow/probe/redux/reducer/read'; @@ -47,6 +49,7 @@ const reduxConfig: ReduxConfig = { readProbeReducer, readAllByTargetReducer, SensorReadReducer, + signUpReducer, ], sagaWatchers: [ AsyncRequest, diff --git a/src/ts/@overflow/member/api/model/Member.ts b/src/ts/@overflow/member/api/model/Member.ts index 2e28822..0a73c8b 100644 --- a/src/ts/@overflow/member/api/model/Member.ts +++ b/src/ts/@overflow/member/api/model/Member.ts @@ -5,6 +5,7 @@ import MetaMemberStatus from '@overflow/meta/api/model/MetaMemberStatus'; interface Member { id?: number; email?: string; + pw?:string; name?: string; phone?: string; companyName?: string; diff --git a/src/ts/@overflow/member/react/SignUp.tsx b/src/ts/@overflow/member/react/SignUp.tsx index 888966c..87beda6 100644 --- a/src/ts/@overflow/member/react/SignUp.tsx +++ b/src/ts/@overflow/member/react/SignUp.tsx @@ -8,19 +8,21 @@ import { } from './components/SignUp'; import State from '../redux/state/SignUp'; +import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest'; + import * as signupActions from '../redux/action/signUp'; export function mapStateToProps(state: any): SignUpStateProps { return { - }; } export function mapDispatchToProps(dispatch: Dispatch): SignUpDispatchProps { return { onSignUp: (member: Member) => { - dispatch(signupActions.request(member)); + dispatch(asyncRequestActions.request('MemberService', 'signup', signupActions.REQUEST, JSON.stringify(member))); + // dispatch(signupActions.request(member)); }, }; } diff --git a/src/ts/@overflow/member/react/components/SignUp.tsx b/src/ts/@overflow/member/react/components/SignUp.tsx index e041f0c..08eccb4 100644 --- a/src/ts/@overflow/member/react/components/SignUp.tsx +++ b/src/ts/@overflow/member/react/components/SignUp.tsx @@ -7,6 +7,7 @@ import { Form, ButtonProps, } from 'semantic-ui-react'; +import MemberStatus from '../../api/model/MemberStatus'; export interface StateProps { } @@ -99,9 +100,22 @@ export class SignUp extends React.Component { ); } - private signUpClick(event: React.SyntheticEvent, data: ButtonProps):void { + private signUpClick = (event: React.SyntheticEvent, data: ButtonProps):void => { - // this.props.onSignUp(member); + let member:Member = {}; + member.pw = this.state.pass; + + if (member.pw !== this.state.passCon) { + return; + } + + member.email = this.state.email; + member.name = this.state.name; + member.companyName = this.state.company; + member.phone = this.state.phone; + // member.status = MemberStatus.NOAUTH; + + this.props.onSignUp(member); } } diff --git a/src/ts/@overflow/member/redux/action/signUp.ts b/src/ts/@overflow/member/redux/action/signUp.ts index 00a90f8..6b5b7dd 100644 --- a/src/ts/@overflow/member/redux/action/signUp.ts +++ b/src/ts/@overflow/member/redux/action/signUp.ts @@ -1,39 +1,8 @@ -import Action from '@overflow/commons/redux/Action'; -import Member from '@overflow/member/api/model/Member'; - -import SigninPayload from '../payload/SignInPayload'; - -// Action Type export type REQUEST = '@overflow/member/signup/REQUEST'; -export type REQUEST_SUCCESS = '@overflow/member/signup/REQUEST_SUCCESS'; -export type REQUEST_FAILURE = '@overflow/member/signup/REQUEST_FAILURE'; +export type REQUEST_SUCCESS = '@overflow/member/signup/REQUEST/SUCCESS'; +export type REQUEST_FAILURE = '@overflow/member/signup/REQUEST/FAILURE'; export const REQUEST: REQUEST = '@overflow/member/signup/REQUEST'; -export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signup/REQUEST_SUCCESS'; -export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signup/REQUEST_FAILURE'; +export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signup/REQUEST/SUCCESS'; +export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signup/REQUEST/FAILURE'; -// Action Creater -export type request = (member: Member) => Action; -export type requestSuccess = (member: Member) => Action; -export type requestFailure = (error: Error) => Action; - -export const request: request = (member: Member): Action => { - return { - type: REQUEST, - payload: member, - }; -}; - -export const requestSuccess: requestSuccess = (member: Member): Action => { - return { - type: REQUEST_SUCCESS, - payload: member, - }; -}; - -export const requestFailure: requestFailure = (error: Error): Action => { - return { - type: REQUEST_FAILURE, - error: error, - }; -}; diff --git a/src/ts/@overflow/member/redux/reducer/signIn.ts b/src/ts/@overflow/member/redux/reducer/signIn.ts index b17099f..367c878 100644 --- a/src/ts/@overflow/member/redux/reducer/signIn.ts +++ b/src/ts/@overflow/member/redux/reducer/signIn.ts @@ -7,6 +7,7 @@ import SigninState, { defaultState as signinDefaultState } from '../state/SignIn const reducer: ReducersMapObject = { [SigninActionTypes.REQUEST_SUCCESS]: (state: SigninState = signinDefaultState, action: Action): SigninState => { + return state; }, [SigninActionTypes.REQUEST_FAILURE]: (state: SigninState = signinDefaultState, action: Action): SigninState => { diff --git a/src/ts/@overflow/member/redux/reducer/signOut.ts b/src/ts/@overflow/member/redux/reducer/signOut.ts index 6c3d3bc..02f6d4c 100644 --- a/src/ts/@overflow/member/redux/reducer/signOut.ts +++ b/src/ts/@overflow/member/redux/reducer/signOut.ts @@ -1,27 +1,17 @@ import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; import Member from '@overflow/member/api/model/Member'; -import * as SignoutActionTypes from '../action/signOut'; -import SigninState, { defaultState as signinDefaultState } from '../state/SignIn'; +import * as SignOutActionTypes from '../action/signOut'; +import SignOutState, { defaultState as signOutDefaultState } from '../state/SignOut'; -export type reducer = (state: SigninState, action: Action) => SigninState; - -export const reducer: reducer = (state: SigninState = signinDefaultState, action: Action): SigninState => { - switch (action.type) { - case SignoutActionTypes.REQUEST_SUCCESS: - { - const aaa: SigninState = { - ...state, - isAuthenticated: true, - }; - - return aaa; - } - case SignoutActionTypes.REQUEST_FAILURE: - { - return state; - } - default: - return state; - } +const reducer: ReducersMapObject = { + [SignOutActionTypes.REQUEST_SUCCESS]: (state: SignOutState = signOutDefaultState, action: Action): SignOutState => { + return state; + }, + [SignOutActionTypes.REQUEST_FAILURE]: (state: SignOutState = signOutDefaultState, action: Action): SignOutState => { + return state; + }, }; + +export default reducer; diff --git a/src/ts/@overflow/member/redux/reducer/signUp.ts b/src/ts/@overflow/member/redux/reducer/signUp.ts index 8085dc5..3665a40 100644 --- a/src/ts/@overflow/member/redux/reducer/signUp.ts +++ b/src/ts/@overflow/member/redux/reducer/signUp.ts @@ -1,29 +1,20 @@ import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; import Member from '@overflow/member/api/model/Member'; -import * as SignupActionTypes from '../action/signUp'; -import SignupState, { defaultState as signupDefaultState } from '../state/SignUp'; +import * as SignUpActionTypes from '../action/signUp'; +import SignUpState, { defaultState as signupDefaultState } from '../state/SignUp'; -export type reducer = (state: SignupState, action: Action) => SignupState; +const reducer: ReducersMapObject = { + [SignUpActionTypes.REQUEST_SUCCESS]: (state: SignUpState = signupDefaultState, action: Action): SignUpState => { + console.log(state); + console.log(action); -export const reducer: reducer = (state: SignupState = signupDefaultState, action: Action): SignupState => { - switch (action.type) { - case SignupActionTypes.REQUEST_SUCCESS: - { - let member = (>action).payload; - - const aaa: SignupState = { - ...state, - isRegistered: true, - }; - - return aaa; - } - case SignupActionTypes.REQUEST_FAILURE: - { - return state; - } - default: - return state; - } + return state; + }, + [SignUpActionTypes.REQUEST_FAILURE]: (state: SignUpState = signupDefaultState, action: Action): SignUpState => { + return state; + }, }; + +export default reducer; diff --git a/src/ts/@overflow/member/redux/state/SignOut.ts b/src/ts/@overflow/member/redux/state/SignOut.ts index 5c15c15..c04181e 100644 --- a/src/ts/@overflow/member/redux/state/SignOut.ts +++ b/src/ts/@overflow/member/redux/state/SignOut.ts @@ -1,3 +1,14 @@ /** * Created by geek on 17. 7. 3. */ +import Member from '../../api/model/Member'; + +export interface State { + readonly error?: Error; +} + +export const defaultState: State = { + error: undefined, +}; + +export default State; \ No newline at end of file