diff --git a/src/ts/commons/api/Service.ts b/src/ts/commons/api/Service.ts index 9d00cb1..2b5974b 100644 --- a/src/ts/commons/api/Service.ts +++ b/src/ts/commons/api/Service.ts @@ -5,7 +5,7 @@ abstract class Service { this.name = name; } - protected send(methodName: string, params?: string[] | string): Promise { + protected send(methodName: string, ...params: any[]): Promise { return new Promise(resolve => { resolve(''); }); @@ -13,15 +13,3 @@ abstract class Service { } export default Service; - - - -export function dService(...methodNames: string[]): Function { - return function(owner: any, methodName?: string): void { - if (!owner.prototype) { - handleActionReducer(owner, methodName); - return; - } - handleRootReducer(owner, methodNames); - } -} diff --git a/src/ts/commons/context/index.ts b/src/ts/commons/context/index.ts new file mode 100644 index 0000000..a49a233 --- /dev/null +++ b/src/ts/commons/context/index.ts @@ -0,0 +1,17 @@ +class AppContext { + private static context: AppContext; + + private constructor() { + + } + + public static getService(): T { + return null; + } + + public static getContext(): AppContext { + return AppContext.context; + } +} + +export default AppContext; diff --git a/src/ts/member/api/service/MemberService.ts b/src/ts/member/api/service/MemberService.ts index 158037f..af289b5 100644 --- a/src/ts/member/api/service/MemberService.ts +++ b/src/ts/member/api/service/MemberService.ts @@ -7,9 +7,13 @@ export class MemberService extends Service { super('MemberService'); } - public signin(signinId: string, signinPw: string): Member { - this.send('signin'); - return null; + public signin(signinId: string, signinPw: string): Promise { + return new Promise(resolve => { + const json = this.send('signin', [signinId, signinPw]); + let member: Member; + // member = ........(json); + resolve(member); + }); } public signout(member: Member): Member { @@ -33,3 +37,5 @@ export class MemberService extends Service { } } + +export default MemberService; diff --git a/src/ts/member/index.ts b/src/ts/member/index.ts index 8b68733..e69de29 100644 --- a/src/ts/member/index.ts +++ b/src/ts/member/index.ts @@ -1,25 +0,0 @@ -import { Action, combineReducers } from 'redux'; -import { SagaIterator } from 'redux-saga'; -import { fork, ForkEffect } from 'redux-saga/effects'; - -import IModule from 'commons/redux/Module'; - -import * as signin from './signin'; -import * as signout from './signout'; -import * as signup from './signup'; - -export interface State { - signin: signin.State; - signout: signin.State; - signup: signin.State; -} - -export const reducer = combineReducers({ - signin: signin.reducer, - signout: signout.reducer, - signup: signup.reducer, -}); - -export function* sagas(): SagaIterator { - yield fork(signin.sagas); -} diff --git a/src/ts/member/react/Signin.tsx b/src/ts/member/react/Signin.tsx index 0ecd3c1..1166315 100644 --- a/src/ts/member/react/Signin.tsx +++ b/src/ts/member/react/Signin.tsx @@ -3,10 +3,10 @@ import { Signin, Props as SigninProps, State as SigninState, -} from '../components/Signin'; -import State from 'member/signin/redux/state'; +} from './components/Signin'; +import State from '../redux/state/Signin'; -import signinActions from 'member/signin/redux/action'; +import signinActions from '../redux/action/signin'; export function mapStateToProps(state: any): SigninProps { diff --git a/src/ts/member/redux/action/signin.ts b/src/ts/member/redux/action/signin.ts index cef6910..3f56927 100644 --- a/src/ts/member/redux/action/signin.ts +++ b/src/ts/member/redux/action/signin.ts @@ -12,9 +12,6 @@ export const REQUEST: REQUEST = '@overflow/member/signin/REQUEST'; export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signin/REQUEST_SUCCESS'; export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signin/REQUEST_FAILURE'; -export type ActionTypes = REQUEST | REQUEST_SUCCESS | REQUEST_FAILURE; - - // Action Creater export type request = (signinId: string, signinPw: string) => Action; export type requestSuccess = (member: Member) => Action; diff --git a/src/ts/member/redux/action/signout.ts b/src/ts/member/redux/action/signout.ts index 414b7e6..2b27be9 100644 --- a/src/ts/member/redux/action/signout.ts +++ b/src/ts/member/redux/action/signout.ts @@ -9,9 +9,6 @@ export const REQUEST: REQUEST = '@overflow/member/signout/REQUEST'; export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/member/signout/REQUEST_SUCCESS'; export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/member/signout/REQUEST_FAILURE'; -export type ActionTypes = REQUEST | REQUEST_SUCCESS | REQUEST_FAILURE; - - // Action Creater export type request = () => Action; export type requestSuccess = () => Action; diff --git a/src/ts/member/redux/action/signup.ts b/src/ts/member/redux/action/signup.ts index b11503d..bde15e8 100644 --- a/src/ts/member/redux/action/signup.ts +++ b/src/ts/member/redux/action/signup.ts @@ -12,9 +12,6 @@ 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 type ActionTypes = REQUEST | REQUEST_SUCCESS | REQUEST_FAILURE; - - // Action Creater export type request = (member: Member) => Action; export type requestSuccess = (member: Member) => Action; diff --git a/src/ts/member/redux/saga/signin.ts b/src/ts/member/redux/saga/signin.ts index 139ece0..581903d 100644 --- a/src/ts/member/redux/saga/signin.ts +++ b/src/ts/member/redux/saga/signin.ts @@ -1,27 +1,15 @@ import { SagaIterator } from 'redux-saga'; import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; + +import AppContext from 'commons/context'; import Action from 'commons/redux/Action'; -import Member from 'member/api/model/Member'; +import Member from '../../api/model/Member'; +import MemberService from '../../api/service/MemberService'; import SigninActions from '../action/signin'; import SigninPayload from '../payload/SigninPayload'; -const apiSignin = (signinId: string, signinPw: string): Promise => { - return new Promise(resolve => { - setTimeout(() => { - let member: Member = { - email: 'crusader@loafle.com', - name: 'crusader', - phone: '02-900-9000', - companyName: 'LOAFLE', - }; - - resolve(member); - }, 1000); - }); -}; - function* signin(action: Action): SagaIterator { try { const {signinId, signinPw} = action.payload; @@ -30,7 +18,7 @@ function* signin(action: Action): SagaIterator { // payload: {sendingRequest: true}, // }); - const member = yield call(apiSignin, signinId, signinPw); + const member = yield call(AppContext.getService().signin, signinId, signinPw); // if (responseBody.token === undefined) { // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); diff --git a/src/ts/member/redux/state/Signin.ts b/src/ts/member/redux/state/Signin.ts index 2abbf40..24e199f 100644 --- a/src/ts/member/redux/state/Signin.ts +++ b/src/ts/member/redux/state/Signin.ts @@ -1,4 +1,4 @@ -import Member from 'member/api/model/Member'; +import Member from '../../api/model/Member'; export interface State { readonly isAuthenticated: boolean; diff --git a/src/ts/member/redux/state/Signup.ts b/src/ts/member/redux/state/Signup.ts index ba372f8..6f774c2 100644 --- a/src/ts/member/redux/state/Signup.ts +++ b/src/ts/member/redux/state/Signup.ts @@ -1,4 +1,4 @@ -import Member from 'member/api/model/Member'; +import Member from '../../api/model/Member'; export interface State { readonly isRegistered: boolean;