member modify

This commit is contained in:
geek 2017-08-23 14:35:39 +09:00
parent 8693fcec24
commit ea9d52e5e5
7 changed files with 86 additions and 11 deletions

View File

@ -3,6 +3,8 @@ 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 modifyMemberReducer from '@overflow/member/redux/reducer/modify';
import readMemberReducer from '@overflow/member/redux/reducer/read';
import readAllProbeReducer from '@overflow/probe/redux/reducer/readAllByDomain';
import readProbeReducer from '@overflow/probe/redux/reducer/read';
@ -50,7 +52,7 @@ export interface RPCConfig {
url: string;
}
const rpcConfig: RPCConfig = {
url: 'ws://192.168.1.209:18081/rpc',
url: 'ws://192.168.1.103:18081/rpc',
};
// Redux Configuration
@ -70,6 +72,8 @@ const reduxConfig: ReduxConfig = {
state: reduxState,
reducerMaps: [
signInReducer,
readMemberReducer,
modifyMemberReducer,
readAllProbeReducer,
readProbeReducer,
sensorReadAllByTargetReducer,

View File

@ -11,9 +11,10 @@ import State from '../redux/state/Modify';
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
import { push as routerPush } from 'react-router-redux';
import * as modifyActions from '../redux/action/modify';
import * as readActions from '../redux/action/read';
export function mapStateToProps(state: any): ModifyStateProps {
export function mapStateToProps(state: State, ownProps?:ModifyStateProps): ModifyStateProps {
return {
member: state.member,
};
@ -23,10 +24,9 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): ModifyDispatchProps
return {
onModify: (member: Member) => {
dispatch(asyncRequestActions.request('MemberService', 'modify', modifyActions.REQUEST, JSON.stringify(member)));
// dispatch(signupActions.request(member));
},
onReadMember: (id: Number) => {
dispatch(asyncRequestActions.request('MemberService', 'read', modifyActions.REQUEST, id));
onReadMember: (id: number) => {
dispatch(asyncRequestActions.request('MemberService', 'read', readActions.REQUEST, JSON.stringify(id)));
},
onRedirectHome: () => {
dispatch(routerPush('/'));

View File

@ -64,9 +64,15 @@ export class Modify extends React.Component<Props, State> {
}
public render(): JSX.Element {
console.log('dddddddddddddddddddddddd');
console.log(this.props.member);
let modifyElement = null;
let modifyElement = <Form>
<Form.Input fluid value={this.state.email} placeholder='Email' disabled/>
if (this.props.member === null || this.props.member === undefined) {
return null;
}
modifyElement = <Form>
<Form.Input fluid value={this.props.member.email} placeholder='Email' disabled/>
<Form.Input fluid placeholder='Name' onChange= {
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
this.setState({ name: data.value });
@ -82,17 +88,17 @@ export class Modify extends React.Component<Props, State> {
this.setState({ passCon: data.value });
}
} />
<Form.Input fluid placeholder='Company' value={this.state.company} onChange={
<Form.Input fluid placeholder='Company' value={this.props.member} onChange={
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
this.setState({ company: data.value });
}
}/>
<Form.Select fluid value={this.state.country} placeholder='Select your country' options={options} onChange={
<Form.Select fluid placeholder='Select your country' options={options} onChange={
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
this.setState({ country: data.value });
}
} />
<Form.Input fluid placeholder='phone' value={this.state.phone} onChange={
<Form.Input fluid placeholder='phone' value={this.props.member} onChange={
(event: React.SyntheticEvent<HTMLInputElement>, data: InputOnChangeData) => {
this.setState({ phone: data.value });
}

View File

@ -1,6 +1,7 @@
import Member from '../../api/model/Member';
interface ModifyPayload {
member: Member;
member?: Member;
id?: number;
}
export default ModifyPayload;

View File

@ -1,3 +1,27 @@
/**
* Created by geek on 17. 7. 3.
*/
import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import Member from '@overflow/member/api/model/Member';
import * as ModifyActionTypes from '../action/modify';
import ModifyState, { defaultState as modifyDefaultState } from '../state/Modify';
const reducer: ReducersMapObject = {
[ModifyActionTypes.REQUEST_SUCCESS]: (state: ModifyState = modifyDefaultState, action: Action<Member>): ModifyState => {
return {
...state,
member: <Member>action.payload,
};
},
[ModifyActionTypes.REQUEST_FAILURE]: (state: ModifyState = modifyDefaultState, action: Action<Error>): ModifyState => {
return {
...state,
error: new Error('SigninIdPwNotMatch'),
};
},
};
export default reducer;

View File

@ -1,3 +1,30 @@
/**
* Created by geek on 17. 7. 3.
*/
/**
* Created by geek on 17. 7. 3.
*/
import Action from '@overflow/commons/redux/Action';
import { ReducersMapObject } from 'redux';
import Member from '@overflow/member/api/model/Member';
import * as ReadActionTypes from '../action/read';
import ReadState, { defaultState as readDefaultState } from '../state/Modify';
const reducer: ReducersMapObject = {
[ReadActionTypes.REQUEST_SUCCESS]: (state: ReadState = readDefaultState, action: Action<Member>): ReadState => {
return {
...state,
member: <Member>action.payload,
};
},
[ReadActionTypes.REQUEST_FAILURE]: (state: ReadState = readDefaultState, action: Action<Error>): ReadState => {
return {
...state,
error: new Error('SigninIdPwNotMatch'),
};
},
};
export default reducer;

View File

@ -1,3 +1,16 @@
/**
* Created by geek on 17. 7. 3.
*/
import Member from '../../api/model/Member';
export interface State {
readonly member?: Member;
readonly error?: Error;
}
export const defaultState: State = {
member: undefined,
error: undefined,
};
export default State;