This commit is contained in:
geek 2017-08-10 18:49:31 +09:00
parent 6828e32f9c
commit 22eaf7e5c2
9 changed files with 66 additions and 84 deletions

View File

@ -2,6 +2,8 @@ import { ReducersMapObject } from 'redux';
import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher'; import SagaWatcher from '@overflow/commons/redux/saga/SagaWatcher';
import signInReducer from '@overflow/member/redux/reducer/signIn'; 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 readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain';
import readProbeReducer from '@overflow/probe/redux/reducer/read'; import readProbeReducer from '@overflow/probe/redux/reducer/read';
@ -47,6 +49,7 @@ const reduxConfig: ReduxConfig = {
readProbeReducer, readProbeReducer,
readAllByTargetReducer, readAllByTargetReducer,
SensorReadReducer, SensorReadReducer,
signUpReducer,
], ],
sagaWatchers: [ sagaWatchers: [
AsyncRequest, AsyncRequest,

View File

@ -5,6 +5,7 @@ import MetaMemberStatus from '@overflow/meta/api/model/MetaMemberStatus';
interface Member { interface Member {
id?: number; id?: number;
email?: string; email?: string;
pw?:string;
name?: string; name?: string;
phone?: string; phone?: string;
companyName?: string; companyName?: string;

View File

@ -8,19 +8,21 @@ import {
} from './components/SignUp'; } from './components/SignUp';
import State from '../redux/state/SignUp'; import State from '../redux/state/SignUp';
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
import * as signupActions from '../redux/action/signUp'; import * as signupActions from '../redux/action/signUp';
export function mapStateToProps(state: any): SignUpStateProps { export function mapStateToProps(state: any): SignUpStateProps {
return { return {
}; };
} }
export function mapDispatchToProps(dispatch: Dispatch<any>): SignUpDispatchProps { export function mapDispatchToProps(dispatch: Dispatch<any>): SignUpDispatchProps {
return { return {
onSignUp: (member: Member) => { onSignUp: (member: Member) => {
dispatch(signupActions.request(member)); dispatch(asyncRequestActions.request('MemberService', 'signup', signupActions.REQUEST, JSON.stringify(member)));
// dispatch(signupActions.request(member));
}, },
}; };
} }

View File

@ -7,6 +7,7 @@ import {
Form, Form,
ButtonProps, ButtonProps,
} from 'semantic-ui-react'; } from 'semantic-ui-react';
import MemberStatus from '../../api/model/MemberStatus';
export interface StateProps { export interface StateProps {
} }
@ -99,9 +100,22 @@ export class SignUp extends React.Component<Props, State> {
); );
} }
private signUpClick(event: React.SyntheticEvent<HTMLButtonElement>, data: ButtonProps):void { private signUpClick = (event: React.SyntheticEvent<HTMLButtonElement>, 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);
} }
} }

View File

@ -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 = '@overflow/member/signup/REQUEST';
export type REQUEST_SUCCESS = '@overflow/member/signup/REQUEST_SUCCESS'; export type REQUEST_SUCCESS = '@overflow/member/signup/REQUEST/SUCCESS';
export type REQUEST_FAILURE = '@overflow/member/signup/REQUEST_FAILURE'; export type REQUEST_FAILURE = '@overflow/member/signup/REQUEST/FAILURE';
export const REQUEST: REQUEST = '@overflow/member/signup/REQUEST'; export const REQUEST: REQUEST = '@overflow/member/signup/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signup/REQUEST_SUCCESS'; 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_FAILURE: REQUEST_FAILURE = '@overflow/member/signup/REQUEST/FAILURE';
// Action Creater
export type request = (member: Member) => Action<Member>;
export type requestSuccess = (member: Member) => Action<Member>;
export type requestFailure = (error: Error) => Action;
export const request: request = (member: Member): Action<Member> => {
return {
type: REQUEST,
payload: member,
};
};
export const requestSuccess: requestSuccess = (member: Member): Action<Member> => {
return {
type: REQUEST_SUCCESS,
payload: member,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -7,6 +7,7 @@ import SigninState, { defaultState as signinDefaultState } from '../state/SignIn
const reducer: ReducersMapObject = { const reducer: ReducersMapObject = {
[SigninActionTypes.REQUEST_SUCCESS]: (state: SigninState = signinDefaultState, action: Action<Member>): SigninState => { [SigninActionTypes.REQUEST_SUCCESS]: (state: SigninState = signinDefaultState, action: Action<Member>): SigninState => {
return state; return state;
}, },
[SigninActionTypes.REQUEST_FAILURE]: (state: SigninState = signinDefaultState, action: Action<Error>): SigninState => { [SigninActionTypes.REQUEST_FAILURE]: (state: SigninState = signinDefaultState, action: Action<Error>): SigninState => {

View File

@ -1,27 +1,17 @@
import Action from '@overflow/commons/redux/Action'; import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import Member from '@overflow/member/api/model/Member'; import Member from '@overflow/member/api/model/Member';
import * as SignoutActionTypes from '../action/signOut'; import * as SignOutActionTypes from '../action/signOut';
import SigninState, { defaultState as signinDefaultState } from '../state/SignIn'; import SignOutState, { defaultState as signOutDefaultState } from '../state/SignOut';
export type reducer = (state: SigninState, action: Action) => SigninState; const reducer: ReducersMapObject = {
[SignOutActionTypes.REQUEST_SUCCESS]: (state: SignOutState = signOutDefaultState, action: Action<Member>): SignOutState => {
export const reducer: reducer = (state: SigninState = signinDefaultState, action: Action): SigninState => { return state;
switch (action.type) { },
case SignoutActionTypes.REQUEST_SUCCESS: [SignOutActionTypes.REQUEST_FAILURE]: (state: SignOutState = signOutDefaultState, action: Action<Error>): SignOutState => {
{ return state;
const aaa: SigninState = { },
...state,
isAuthenticated: true,
};
return aaa;
}
case SignoutActionTypes.REQUEST_FAILURE:
{
return state;
}
default:
return state;
}
}; };
export default reducer;

View File

@ -1,29 +1,20 @@
import Action from '@overflow/commons/redux/Action'; import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import Member from '@overflow/member/api/model/Member'; import Member from '@overflow/member/api/model/Member';
import * as SignupActionTypes from '../action/signUp'; import * as SignUpActionTypes from '../action/signUp';
import SignupState, { defaultState as signupDefaultState } from '../state/SignUp'; import SignUpState, { defaultState as signupDefaultState } from '../state/SignUp';
export type reducer = (state: SignupState, action: Action<Member | Error>) => SignupState; const reducer: ReducersMapObject = {
[SignUpActionTypes.REQUEST_SUCCESS]: (state: SignUpState = signupDefaultState, action: Action<Member>): SignUpState => {
console.log(state);
console.log(action);
export const reducer: reducer = (state: SignupState = signupDefaultState, action: Action<Member | Error>): SignupState => { return state;
switch (action.type) { },
case SignupActionTypes.REQUEST_SUCCESS: [SignUpActionTypes.REQUEST_FAILURE]: (state: SignUpState = signupDefaultState, action: Action<Error>): SignUpState => {
{ return state;
let member = (<Action<Member>>action).payload; },
const aaa: SignupState = {
...state,
isRegistered: true,
};
return aaa;
}
case SignupActionTypes.REQUEST_FAILURE:
{
return state;
}
default:
return state;
}
}; };
export default reducer;

View File

@ -1,3 +1,14 @@
/** /**
* Created by geek on 17. 7. 3. * 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;