diff --git a/src/ts/@overflow/app/views/member/ResetPassword.tsx b/src/ts/@overflow/app/views/member/ResetPassword.tsx index ad2814d..76034f9 100644 --- a/src/ts/@overflow/app/views/member/ResetPassword.tsx +++ b/src/ts/@overflow/app/views/member/ResetPassword.tsx @@ -16,7 +16,7 @@ class ResetPassword extends React.Component, object> public render(): JSX.Element { return ( - + ); } diff --git a/src/ts/@overflow/member/react/ResetPassword.tsx b/src/ts/@overflow/member/react/ResetPassword.tsx index 877d44e..e617572 100644 --- a/src/ts/@overflow/member/react/ResetPassword.tsx +++ b/src/ts/@overflow/member/react/ResetPassword.tsx @@ -5,14 +5,13 @@ import { DispatchProps as ResetPasswordDispatchProps, Props as ResetPasswordProps, } 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): ResetPasswordDispat // onConfirmPassword: (pass: string) => { // 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})); + }, }; } diff --git a/src/ts/@overflow/member/react/SignIn.tsx b/src/ts/@overflow/member/react/SignIn.tsx index bd4db79..e9c51b2 100644 --- a/src/ts/@overflow/member/react/SignIn.tsx +++ b/src/ts/@overflow/member/react/SignIn.tsx @@ -11,7 +11,6 @@ import * as signinActions from '../redux/action/signIn'; import * as forgotPasswordAction from '../redux/action/forgot_password'; 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'; export function mapStateToProps(state: SignInState, ownProps?: SignInStateProps): SignInStateProps { @@ -26,13 +25,15 @@ export function mapDispatchToProps(dispatch: Dispatch, ownProps?: any): Sig return { onSignIn: (signinId: string, signinPw: string) => { // 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: () => { dispatch(routerPush('/')); }, onForgotPassword: (email:string) => { - dispatch(asyncRestRequestAction.request('/forgot_password', 'POST', forgotPasswordAction.REQUEST, {signinId:email})); + dispatch(asyncRestRequestAction.request('/account/forgot_password', 'POST', forgotPasswordAction.REQUEST, {signinId:email})); }, }; } diff --git a/src/ts/@overflow/member/react/SignUp.tsx b/src/ts/@overflow/member/react/SignUp.tsx index 7d90d93..9dca8e0 100644 --- a/src/ts/@overflow/member/react/SignUp.tsx +++ b/src/ts/@overflow/member/react/SignUp.tsx @@ -6,12 +6,10 @@ import { StateProps as SignUpStateProps, DispatchProps as SignUpDispatchProps, } 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 * as signupActions from '../redux/action/signUp'; - +import * as asyncRestRequestAction from '@overflow/commons/redux/action/asyncRestRequest'; export function mapStateToProps(state: any): SignUpStateProps { return { @@ -22,8 +20,10 @@ export function mapStateToProps(state: any): SignUpStateProps { export function mapDispatchToProps(dispatch: Dispatch): SignUpDispatchProps { return { 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(asyncRestRequestAction.request('/account/signup', 'POST', signupActions.REQUEST, {member:member})); + }, onRedirectHome: () => { dispatch(routerPush('/')); diff --git a/src/ts/@overflow/member/react/components/ResetPassword.tsx b/src/ts/@overflow/member/react/components/ResetPassword.tsx index 21f0ab5..b225821 100644 --- a/src/ts/@overflow/member/react/components/ResetPassword.tsx +++ b/src/ts/@overflow/member/react/components/ResetPassword.tsx @@ -6,11 +6,14 @@ import { Form, ButtonProps, } from 'semantic-ui-react'; +import {multiInject} from 'inversify'; export interface StateProps { + params?: string; } export interface DispatchProps { + onResetPassword?(pw:string, key:string); } export type Props = StateProps & DispatchProps; @@ -29,9 +32,13 @@ export class ResetPassword extends React.Component { pwConfirm:null, }; + if (this.props.params === null || this.props.params === '') { + return; + } } public render(): JSX.Element { + return (
{ ); } - private PWConfirmClick(event: React.SyntheticEvent, data: ButtonProps):void { + private PWConfirmClick = (event: React.SyntheticEvent, data: ButtonProps):void => { if (this.state.pw !== this.state.pwConfirm) { alert('Password Not Equal'); return; } // Todo Password Reset Fetch Communication + this.props.onResetPassword(this.state.pw, this.props.params); } } diff --git a/src/ts/@overflow/member/redux/action/reset_password.ts b/src/ts/@overflow/member/redux/action/reset_password.ts new file mode 100644 index 0000000..c14dd3b --- /dev/null +++ b/src/ts/@overflow/member/redux/action/reset_password.ts @@ -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'; \ No newline at end of file diff --git a/src/ts/@overflow/member/redux/payload/ResetPassword.ts b/src/ts/@overflow/member/redux/payload/ResetPassword.ts new file mode 100644 index 0000000..d21300e --- /dev/null +++ b/src/ts/@overflow/member/redux/payload/ResetPassword.ts @@ -0,0 +1,6 @@ +interface ResetPasswordPayload { + pw: string; + key: string; +} + +export default ResetPasswordPayload; diff --git a/src/ts/@overflow/member/redux/reducer/resetPassword.ts b/src/ts/@overflow/member/redux/reducer/resetPassword.ts new file mode 100644 index 0000000..a51b3aa --- /dev/null +++ b/src/ts/@overflow/member/redux/reducer/resetPassword.ts @@ -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): ResetPasswordState => { + return { + ...state, + isSuccess: true, + }; + }, + [ResetPasswordTypes.REQUEST_FAILURE]: (state: ResetPasswordState = resetDefaultState, action: Action): ResetPasswordState => { + return { + ...state, + error: new Error('ResetPassword Error'), + }; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/member/redux/reducer/signIn.ts b/src/ts/@overflow/member/redux/reducer/signIn.ts index 6512d53..856fa6d 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 => { + console.log(action.payload); return { ...state, isAuthenticated: true, diff --git a/src/ts/@overflow/member/redux/reducer/signUp.ts b/src/ts/@overflow/member/redux/reducer/signUp.ts index 380e98f..73bfc8e 100644 --- a/src/ts/@overflow/member/redux/reducer/signUp.ts +++ b/src/ts/@overflow/member/redux/reducer/signUp.ts @@ -14,6 +14,7 @@ import SignUpState, { defaultState as signupDefaultState } from '../state/SignUp // }, const reducer: ReducersMapObject = { [SignUpActionTypes.REQUEST_SUCCESS]: (state: SignUpState = signupDefaultState, action: Action): SignUpState => { + console.log(action.payload); return { ...state, member: action.payload, diff --git a/src/ts/@overflow/member/redux/state/ResetPassword.ts b/src/ts/@overflow/member/redux/state/ResetPassword.ts new file mode 100644 index 0000000..b47a0ae --- /dev/null +++ b/src/ts/@overflow/member/redux/state/ResetPassword.ts @@ -0,0 +1,12 @@ + +export interface State { + readonly isSuccess: boolean; + readonly error?: Error; +} + +export const defaultState: State = { + isSuccess: undefined, + error: undefined, +}; + +export default State;