rest call
This commit is contained in:
parent
6d2e01fa2d
commit
648f9da64a
|
@ -16,7 +16,7 @@ class ResetPassword extends React.Component<RouteComponentProps<Props>, object>
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<ResetPasswordContainer/>
|
<ResetPasswordContainer param={this.props.location.search}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,13 @@ import {
|
||||||
DispatchProps as ResetPasswordDispatchProps,
|
DispatchProps as ResetPasswordDispatchProps,
|
||||||
Props as ResetPasswordProps,
|
Props as ResetPasswordProps,
|
||||||
} from './components/ResetPassword';
|
} from './components/ResetPassword';
|
||||||
// import ResetPasswordState from '../redux/state/ResetPassword';
|
|
||||||
//
|
|
||||||
// import * as ResetPasswordActions from '../redux/action/reset_password';
|
|
||||||
// import { push as routerPush } from 'react-router-redux';
|
|
||||||
// import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
|
||||||
export function mapStateToProps(state: any): ResetPasswordStateProps {
|
|
||||||
return {
|
|
||||||
|
|
||||||
|
import * as ResetPasswordActions from '../redux/action/reset_password';
|
||||||
|
import * as asyncRestRequestAction from '@overflow/commons/redux/action/asyncRestRequest';
|
||||||
|
|
||||||
|
export function mapStateToProps(state: any, ownProps:any): ResetPasswordStateProps {
|
||||||
|
return {
|
||||||
|
params: ownProps.param,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +20,9 @@ export function mapDispatchToProps(dispatch: Dispatch<any>): ResetPasswordDispat
|
||||||
// onConfirmPassword: (pass: string) => {
|
// onConfirmPassword: (pass: string) => {
|
||||||
// dispatch(asyncRequestActions.request('MemberService', 'signin', ResetPasswordActions.REQUEST, 'overflow@loafle.com', pass));
|
// dispatch(asyncRequestActions.request('MemberService', 'signin', ResetPasswordActions.REQUEST, 'overflow@loafle.com', pass));
|
||||||
// },
|
// },
|
||||||
|
onResetPassword: (pw:string, key:string) => {
|
||||||
|
dispatch(asyncRestRequestAction.request('/account/reset_password', 'POST', ResetPasswordActions.REQUEST, {pw:pw, key:key}));
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import * as signinActions from '../redux/action/signIn';
|
||||||
import * as forgotPasswordAction from '../redux/action/forgot_password';
|
import * as forgotPasswordAction from '../redux/action/forgot_password';
|
||||||
|
|
||||||
import { push as routerPush } from 'react-router-redux';
|
import { push as routerPush } from 'react-router-redux';
|
||||||
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
|
||||||
import * as asyncRestRequestAction from '@overflow/commons/redux/action/asyncRestRequest';
|
import * as asyncRestRequestAction from '@overflow/commons/redux/action/asyncRestRequest';
|
||||||
|
|
||||||
export function mapStateToProps(state: SignInState, ownProps?: SignInStateProps): SignInStateProps {
|
export function mapStateToProps(state: SignInState, ownProps?: SignInStateProps): SignInStateProps {
|
||||||
|
@ -26,13 +25,15 @@ export function mapDispatchToProps(dispatch: Dispatch<any>, ownProps?: any): Sig
|
||||||
return {
|
return {
|
||||||
onSignIn: (signinId: string, signinPw: string) => {
|
onSignIn: (signinId: string, signinPw: string) => {
|
||||||
// dispatch(signinActions.request(signinId, signinPw));
|
// dispatch(signinActions.request(signinId, signinPw));
|
||||||
dispatch(asyncRequestActions.request('MemberService', 'signin', signinActions.REQUEST, signinId, signinPw));
|
// dispatch(asyncRequestActions.request('MemberService', 'signin', signinActions.REQUEST, signinId, signinPw));
|
||||||
|
dispatch(asyncRestRequestAction.request(
|
||||||
|
'/account/signin', 'POST', signinActions.REQUEST, {signinId:signinId, signinPw:signinPw}));
|
||||||
},
|
},
|
||||||
onRedirectHome: () => {
|
onRedirectHome: () => {
|
||||||
dispatch(routerPush('/'));
|
dispatch(routerPush('/'));
|
||||||
},
|
},
|
||||||
onForgotPassword: (email:string) => {
|
onForgotPassword: (email:string) => {
|
||||||
dispatch(asyncRestRequestAction.request('/forgot_password', 'POST', forgotPasswordAction.REQUEST, {signinId:email}));
|
dispatch(asyncRestRequestAction.request('/account/forgot_password', 'POST', forgotPasswordAction.REQUEST, {signinId:email}));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,10 @@ import {
|
||||||
StateProps as SignUpStateProps,
|
StateProps as SignUpStateProps,
|
||||||
DispatchProps as SignUpDispatchProps,
|
DispatchProps as SignUpDispatchProps,
|
||||||
} from './components/SignUp';
|
} from './components/SignUp';
|
||||||
import State from '../redux/state/SignUp';
|
|
||||||
|
|
||||||
import * as asyncRequestActions from '@overflow/commons/redux/action/asyncRequest';
|
|
||||||
import { push as routerPush } from 'react-router-redux';
|
import { push as routerPush } from 'react-router-redux';
|
||||||
import * as signupActions from '../redux/action/signUp';
|
import * as signupActions from '../redux/action/signUp';
|
||||||
|
import * as asyncRestRequestAction from '@overflow/commons/redux/action/asyncRestRequest';
|
||||||
|
|
||||||
export function mapStateToProps(state: any): SignUpStateProps {
|
export function mapStateToProps(state: any): SignUpStateProps {
|
||||||
return {
|
return {
|
||||||
|
@ -22,8 +20,10 @@ export function mapStateToProps(state: any): SignUpStateProps {
|
||||||
export function mapDispatchToProps(dispatch: Dispatch<any>): SignUpDispatchProps {
|
export function mapDispatchToProps(dispatch: Dispatch<any>): SignUpDispatchProps {
|
||||||
return {
|
return {
|
||||||
onSignUp: (member: Member) => {
|
onSignUp: (member: Member) => {
|
||||||
dispatch(asyncRequestActions.request('MemberService', 'signup', signupActions.REQUEST, JSON.stringify(member), member.pw));
|
// dispatch(asyncRequestActions.request('MemberService', 'signup', signupActions.REQUEST, JSON.stringify(member), member.pw));
|
||||||
// dispatch(signupActions.request(member));
|
// dispatch(signupActions.request(member));
|
||||||
|
dispatch(asyncRestRequestAction.request('/account/signup', 'POST', signupActions.REQUEST, {member:member}));
|
||||||
|
|
||||||
},
|
},
|
||||||
onRedirectHome: () => {
|
onRedirectHome: () => {
|
||||||
dispatch(routerPush('/'));
|
dispatch(routerPush('/'));
|
||||||
|
|
|
@ -6,11 +6,14 @@ import {
|
||||||
Form,
|
Form,
|
||||||
ButtonProps,
|
ButtonProps,
|
||||||
} from 'semantic-ui-react';
|
} from 'semantic-ui-react';
|
||||||
|
import {multiInject} from 'inversify';
|
||||||
|
|
||||||
export interface StateProps {
|
export interface StateProps {
|
||||||
|
params?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DispatchProps {
|
export interface DispatchProps {
|
||||||
|
onResetPassword?(pw:string, key:string);
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Props = StateProps & DispatchProps;
|
export type Props = StateProps & DispatchProps;
|
||||||
|
@ -29,9 +32,13 @@ export class ResetPassword extends React.Component<Props, State> {
|
||||||
pwConfirm:null,
|
pwConfirm:null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.props.params === null || this.props.params === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<Form.Input placeholder='Password' type='password' onChange={
|
<Form.Input placeholder='Password' type='password' onChange={
|
||||||
|
@ -50,13 +57,14 @@ export class ResetPassword extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PWConfirmClick(event: React.SyntheticEvent<HTMLButtonElement>, data: ButtonProps):void {
|
private PWConfirmClick = (event: React.SyntheticEvent<HTMLButtonElement>, data: ButtonProps):void => {
|
||||||
if (this.state.pw !== this.state.pwConfirm) {
|
if (this.state.pw !== this.state.pwConfirm) {
|
||||||
alert('Password Not Equal');
|
alert('Password Not Equal');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo Password Reset Fetch Communication
|
// Todo Password Reset Fetch Communication
|
||||||
|
this.props.onResetPassword(this.state.pw, this.props.params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
src/ts/@overflow/member/redux/action/reset_password.ts
Normal file
8
src/ts/@overflow/member/redux/action/reset_password.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
// Action Type
|
||||||
|
export type REQUEST = '@overflow/member/reset_password/REQUEST';
|
||||||
|
export type REQUEST_SUCCESS = '@overflow/member/reset_password/REQUEST/SUCCESS';
|
||||||
|
export type REQUEST_FAILURE = '@overflow/member/reset_password/REQUEST/FAILURE';
|
||||||
|
|
||||||
|
export const REQUEST: REQUEST = '@overflow/member/reset_password/REQUEST';
|
||||||
|
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/reset_password/REQUEST/SUCCESS';
|
||||||
|
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/reset_password/REQUEST/FAILURE';
|
6
src/ts/@overflow/member/redux/payload/ResetPassword.ts
Normal file
6
src/ts/@overflow/member/redux/payload/ResetPassword.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
interface ResetPasswordPayload {
|
||||||
|
pw: string;
|
||||||
|
key: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ResetPasswordPayload;
|
23
src/ts/@overflow/member/redux/reducer/resetPassword.ts
Normal file
23
src/ts/@overflow/member/redux/reducer/resetPassword.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import Action from '@overflow/commons/redux/Action';
|
||||||
|
import { ReducersMapObject } from 'redux';
|
||||||
|
import Member from '@overflow/member/api/model/Member';
|
||||||
|
|
||||||
|
import * as ResetPasswordTypes from '../action/reset_password';
|
||||||
|
import ResetPasswordState, { defaultState as resetDefaultState } from '../state/ResetPassword';
|
||||||
|
|
||||||
|
const reducer: ReducersMapObject = {
|
||||||
|
[ResetPasswordTypes.REQUEST_SUCCESS]: (state: ResetPasswordState = resetDefaultState, action: Action<Member>): ResetPasswordState => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
isSuccess: true,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
[ResetPasswordTypes.REQUEST_FAILURE]: (state: ResetPasswordState = resetDefaultState, action: Action<Error>): ResetPasswordState => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
error: new Error('ResetPassword Error'),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reducer;
|
|
@ -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 => {
|
||||||
|
console.log(action.payload);
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
isAuthenticated: true,
|
isAuthenticated: true,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import SignUpState, { defaultState as signupDefaultState } from '../state/SignUp
|
||||||
// },
|
// },
|
||||||
const reducer: ReducersMapObject = {
|
const reducer: ReducersMapObject = {
|
||||||
[SignUpActionTypes.REQUEST_SUCCESS]: (state: SignUpState = signupDefaultState, action: Action<Member>): SignUpState => {
|
[SignUpActionTypes.REQUEST_SUCCESS]: (state: SignUpState = signupDefaultState, action: Action<Member>): SignUpState => {
|
||||||
|
console.log(<Member>action.payload);
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
member: <Member>action.payload,
|
member: <Member>action.payload,
|
||||||
|
|
12
src/ts/@overflow/member/redux/state/ResetPassword.ts
Normal file
12
src/ts/@overflow/member/redux/state/ResetPassword.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
readonly isSuccess: boolean;
|
||||||
|
readonly error?: Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const defaultState: State = {
|
||||||
|
isSuccess: undefined,
|
||||||
|
error: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default State;
|
Loading…
Reference in New Issue
Block a user