Refactoring
This commit is contained in:
parent
821cde7afd
commit
e72d731907
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
target: 'web',
|
target: 'web',
|
||||||
entry: {
|
entry: {
|
||||||
app: [
|
app: [
|
||||||
Path.resolve(__dirname, '../../src/ts/index.tsx')
|
Path.resolve(__dirname, '../../src/ts/app/index.tsx')
|
||||||
],
|
],
|
||||||
vendor: Object.keys(packages.dependencies)
|
vendor: Object.keys(packages.dependencies)
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
interface IModule<IComponentType, IContainerType, IViewType, IReduxType> {
|
|
||||||
components: IComponentType;
|
|
||||||
containers: IContainerType;
|
|
||||||
views: IViewType;
|
|
||||||
redux: IReduxType;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default IModule;
|
|
|
@ -1,8 +0,0 @@
|
||||||
import Action from './Action';
|
|
||||||
|
|
||||||
export interface IModule<State = {}, Payload = {}> {
|
|
||||||
state: State;
|
|
||||||
reducer: (state: State, action: Action<Payload>) => State;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default IModule;
|
|
|
@ -1,14 +0,0 @@
|
||||||
import Action from 'commons/redux/Action';
|
|
||||||
import { RouterState, LocationActionPayload, LOCATION_CHANGE } from 'react-router-redux';
|
|
||||||
|
|
||||||
export const initRouterState: RouterState = {
|
|
||||||
location: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export function routerReducer(state: RouterState = initRouterState, action: Action<LocationActionPayload>): RouterState {
|
|
||||||
if (action.type === LOCATION_CHANGE) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { colors, getMuiTheme, MuiTheme, spacing } from 'material-ui/styles';
|
|
||||||
import { fade } from 'material-ui/utils/colorManipulator';
|
|
||||||
|
|
||||||
const muiTheme:MuiTheme = getMuiTheme({
|
|
||||||
spacing: spacing,
|
|
||||||
fontFamily: 'Roboto, sans-serif',
|
|
||||||
palette: {
|
|
||||||
primary1Color: colors.cyan500,
|
|
||||||
primary2Color: colors.cyan700,
|
|
||||||
primary3Color: colors.grey400,
|
|
||||||
accent1Color: colors.pinkA200,
|
|
||||||
accent2Color: colors.grey100,
|
|
||||||
accent3Color: colors.grey500,
|
|
||||||
textColor: colors.darkBlack,
|
|
||||||
alternateTextColor: colors.white,
|
|
||||||
canvasColor: colors.white,
|
|
||||||
borderColor: colors.grey300,
|
|
||||||
disabledColor: fade(colors.darkBlack, 0.3),
|
|
||||||
pickerHeaderColor: colors.cyan500,
|
|
||||||
clockCircleColor: fade(colors.darkBlack, 0.07),
|
|
||||||
shadowColor: colors.fullBlack,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default muiTheme;
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { Action, combineReducers } from 'redux';
|
|
||||||
import { RouterState, LocationActionPayload, LOCATION_CHANGE } from 'react-router-redux';
|
|
||||||
import { SagaIterator } from 'redux-saga';
|
|
||||||
import { fork } from 'redux-saga/effects';
|
|
||||||
import { routerReducer } from 'commons/redux/router';
|
|
||||||
|
|
||||||
import * as Member from 'member';
|
|
||||||
|
|
||||||
export interface State {
|
|
||||||
member: Member.State;
|
|
||||||
router: RouterState;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const reducer = combineReducers<State>({
|
|
||||||
member: Member.reducer,
|
|
||||||
router: routerReducer,
|
|
||||||
});
|
|
||||||
|
|
||||||
export function* sagas(): SagaIterator {
|
|
||||||
yield fork(Member.sagas);
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { applyMiddleware, compose, createStore, Store } from 'redux';
|
|
||||||
import { routerMiddleware } from 'react-router-redux';
|
|
||||||
import { SagaMiddleware } from 'redux-saga';
|
|
||||||
import { History } from 'history';
|
|
||||||
|
|
||||||
import { reducer, State } from './configureRedux';
|
|
||||||
|
|
||||||
export default function configureStore(history: History, sagaMiddleware: SagaMiddleware<any>): Store<State> {
|
|
||||||
const middlewares = [sagaMiddleware, routerMiddleware(history)];
|
|
||||||
const store = createStore<State>(
|
|
||||||
reducer,
|
|
||||||
applyMiddleware(...middlewares),
|
|
||||||
);
|
|
||||||
|
|
||||||
// sagaMiddleware.run(rootSaga);
|
|
||||||
|
|
||||||
return store;
|
|
||||||
}
|
|
3
src/ts/member/api/service/MemberService.ts
Normal file
3
src/ts/member/api/service/MemberService.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export class MemberService {
|
||||||
|
|
||||||
|
}
|
45
src/ts/member/redux/action/signin.ts
Normal file
45
src/ts/member/redux/action/signin.ts
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import Action from 'commons/redux/Action';
|
||||||
|
import Member from 'member/api/model/Member';
|
||||||
|
|
||||||
|
import SigninPayload from '../payload/SigninPayload';
|
||||||
|
|
||||||
|
// Action Type
|
||||||
|
export type REQUEST = '@overflow/member/signin/REQUEST';
|
||||||
|
export type REQUEST_SUCCESS = '@overflow/member/signin/REQUEST_SUCCESS';
|
||||||
|
export type REQUEST_FAILURE = '@overflow/member/signin/REQUEST_FAILURE';
|
||||||
|
|
||||||
|
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<SigninPayload>;
|
||||||
|
export type requestSuccess = (member: Member) => Action<Member>;
|
||||||
|
export type requestFailure = (error: Error) => Action;
|
||||||
|
|
||||||
|
export const request: request = (signinId: string, signinPw: string): Action<SigninPayload> => {
|
||||||
|
return {
|
||||||
|
type: REQUEST,
|
||||||
|
payload: {
|
||||||
|
signinId: signinId,
|
||||||
|
signinPw: signinPw,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
};
|
37
src/ts/member/redux/action/signout.ts
Normal file
37
src/ts/member/redux/action/signout.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import Action from 'commons/redux/Action';
|
||||||
|
|
||||||
|
// Action Type
|
||||||
|
export type REQUEST = '@overflow/member/signout/REQUEST';
|
||||||
|
export type REQUEST_SUCCESS = '@overflow/member/signout/REQUEST_SUCCESS';
|
||||||
|
export type REQUEST_FAILURE = '@overflow/member/signout/REQUEST_FAILURE';
|
||||||
|
|
||||||
|
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;
|
||||||
|
export type requestFailure = (error: Error) => Action;
|
||||||
|
|
||||||
|
export const request: request = (): Action => {
|
||||||
|
return {
|
||||||
|
type: REQUEST,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const requestSuccess: requestSuccess = (): Action => {
|
||||||
|
return {
|
||||||
|
type: REQUEST_SUCCESS,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const requestFailure: requestFailure = (error: Error): Action => {
|
||||||
|
return {
|
||||||
|
type: REQUEST_FAILURE,
|
||||||
|
error: error,
|
||||||
|
};
|
||||||
|
};
|
42
src/ts/member/redux/action/signup.ts
Normal file
42
src/ts/member/redux/action/signup.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import Action from 'commons/redux/Action';
|
||||||
|
import Member from 'member/api/model/Member';
|
||||||
|
|
||||||
|
import SigninPayload from '../payload/SigninPayload';
|
||||||
|
|
||||||
|
// Action Type
|
||||||
|
export type REQUEST = '@overflow/member/signup/REQUEST';
|
||||||
|
export type REQUEST_SUCCESS = '@overflow/member/signup/REQUEST_SUCCESS';
|
||||||
|
export type REQUEST_FAILURE = '@overflow/member/signup/REQUEST_FAILURE';
|
||||||
|
|
||||||
|
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<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,
|
||||||
|
};
|
||||||
|
};
|
29
src/ts/member/redux/reducer/signin.ts
Normal file
29
src/ts/member/redux/reducer/signin.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import Action from 'commons/redux/Action';
|
||||||
|
import Member from 'member/api/model/Member';
|
||||||
|
|
||||||
|
import SigninActionTypes from '../action/signin';
|
||||||
|
import SigninState, { defaultState as signinDefaultState } from '../state/Signin';
|
||||||
|
|
||||||
|
export type reducer = (state: SigninState, action: Action<Member | Error>) => SigninState;
|
||||||
|
|
||||||
|
export const reducer: reducer = (state: SigninState = signinDefaultState, action: Action<Member | Error>): SigninState => {
|
||||||
|
switch (action.type) {
|
||||||
|
case SigninActionTypes.REQUEST_SUCCESS:
|
||||||
|
{
|
||||||
|
let member = (<Action<Member>>action).payload;
|
||||||
|
|
||||||
|
const aaa: SigninState = {
|
||||||
|
...state,
|
||||||
|
isAuthenticated: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return aaa;
|
||||||
|
}
|
||||||
|
case SigninActionTypes.REQUEST_FAILURE:
|
||||||
|
{
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
27
src/ts/member/redux/reducer/signout.ts
Normal file
27
src/ts/member/redux/reducer/signout.ts
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import Action from 'commons/redux/Action';
|
||||||
|
import Member from 'member/api/model/Member';
|
||||||
|
|
||||||
|
import SignoutActionTypes from '../action/signout';
|
||||||
|
import SigninState, { defaultState as signinDefaultState } from '../state/Signin';
|
||||||
|
|
||||||
|
export type reducer = (state: SigninState, action: Action) => SigninState;
|
||||||
|
|
||||||
|
export const reducer: reducer = (state: SigninState = signinDefaultState, action: Action): SigninState => {
|
||||||
|
switch (action.type) {
|
||||||
|
case SignoutActionTypes.REQUEST_SUCCESS:
|
||||||
|
{
|
||||||
|
const aaa: SigninState = {
|
||||||
|
...state,
|
||||||
|
isAuthenticated: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return aaa;
|
||||||
|
}
|
||||||
|
case SignoutActionTypes.REQUEST_FAILURE:
|
||||||
|
{
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
29
src/ts/member/redux/reducer/signup.ts
Normal file
29
src/ts/member/redux/reducer/signup.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import Action from 'commons/redux/Action';
|
||||||
|
import Member from 'member/api/model/Member';
|
||||||
|
|
||||||
|
import SignupActionTypes from '../action/signup';
|
||||||
|
import SignupState, { defaultState as signupDefaultState } from '../state/Signup';
|
||||||
|
|
||||||
|
export type reducer = (state: SignupState, action: Action<Member | Error>) => SignupState;
|
||||||
|
|
||||||
|
export const reducer: reducer = (state: SignupState = signupDefaultState, action: Action<Member | Error>): SignupState => {
|
||||||
|
switch (action.type) {
|
||||||
|
case SignupActionTypes.REQUEST_SUCCESS:
|
||||||
|
{
|
||||||
|
let member = (<Action<Member>>action).payload;
|
||||||
|
|
||||||
|
const aaa: SignupState = {
|
||||||
|
...state,
|
||||||
|
isRegistered: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return aaa;
|
||||||
|
}
|
||||||
|
case SignupActionTypes.REQUEST_FAILURE:
|
||||||
|
{
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,11 +1,10 @@
|
||||||
import { takeLatest, SagaIterator } from 'redux-saga';
|
import { SagaIterator } from 'redux-saga';
|
||||||
import { call, Effect, fork, put } from 'redux-saga/effects';
|
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
|
||||||
|
|
||||||
import Action from 'commons/redux/Action';
|
import Action from 'commons/redux/Action';
|
||||||
|
|
||||||
import Member from 'member/api/model/Member';
|
import Member from 'member/api/model/Member';
|
||||||
import actions from '../action';
|
import SigninActions from '../action/signin';
|
||||||
import actionTypes from '../action/type';
|
|
||||||
import SigninPayload from '../payload/SigninPayload';
|
import SigninPayload from '../payload/SigninPayload';
|
||||||
|
|
||||||
const apiSignin = (signinId: string, signinPw: string): Promise<Member> => {
|
const apiSignin = (signinId: string, signinPw: string): Promise<Member> => {
|
||||||
|
@ -36,9 +35,9 @@ function* signin(action: Action<SigninPayload>): Iterable<Effect> {
|
||||||
// if (responseBody.token === undefined) {
|
// if (responseBody.token === undefined) {
|
||||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
||||||
// }
|
// }
|
||||||
yield put(actions.requestSuccess(member));
|
yield put(SigninActions.requestSuccess(member));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
yield put(actions.requestFailure(e));
|
yield put(SigninActions.requestFailure(e));
|
||||||
} finally {
|
} finally {
|
||||||
// yield put({
|
// yield put({
|
||||||
// type: types.SENDING_REQUEST,
|
// type: types.SENDING_REQUEST,
|
|
@ -1,14 +1,12 @@
|
||||||
import Member from 'member/api/model/Member';
|
import Member from 'member/api/model/Member';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
isAuthenticated: boolean;
|
readonly isAuthenticated: boolean;
|
||||||
member?: Member;
|
readonly error?: Error;
|
||||||
error?: Error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultState: State = {
|
export const defaultState: State = {
|
||||||
isAuthenticated: undefined,
|
isAuthenticated: undefined,
|
||||||
member: undefined,
|
|
||||||
error: undefined,
|
error: undefined,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import Member from 'member/api/model/Member';
|
import Member from 'member/api/model/Member';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
isRegistered: boolean;
|
readonly isRegistered: boolean;
|
||||||
member?: Member;
|
readonly member?: Member;
|
||||||
error?: Error;
|
readonly error?: Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultState: State = {
|
export const defaultState: State = {
|
|
@ -1 +0,0 @@
|
||||||
export * from './redux';
|
|
|
@ -1,41 +0,0 @@
|
||||||
import Action from 'commons/redux/Action';
|
|
||||||
|
|
||||||
import Member from 'member/api/model/Member';
|
|
||||||
|
|
||||||
import actionTypes from './type';
|
|
||||||
import SigninPayload from '../payload/SigninPayload';
|
|
||||||
|
|
||||||
|
|
||||||
export interface Actions {
|
|
||||||
request: (signinId: string, signinPw: string) => Action<SigninPayload>;
|
|
||||||
requestSuccess: (member: Member) => Action<Member>;
|
|
||||||
requestFailure: (error: Error) => Action;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const actions: Actions = {
|
|
||||||
request(signinId: string, signinPw: string): Action<SigninPayload> {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST,
|
|
||||||
payload: {
|
|
||||||
signinId: signinId,
|
|
||||||
signinPw: signinPw,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
requestSuccess(member: Member): Action<Member> {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST_SUCCESS,
|
|
||||||
payload: member,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
requestFailure(error: Error): Action {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST_FAILURE,
|
|
||||||
error: error,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default actions;
|
|
|
@ -1,17 +0,0 @@
|
||||||
export type REQUEST = '@overflow/member/signin/REQUEST';
|
|
||||||
export type REQUEST_SUCCESS = '@overflow/member/signin/REQUEST_SUCCESS';
|
|
||||||
export type REQUEST_FAILURE = '@overflow/member/signin/REQUEST_FAILURE';
|
|
||||||
|
|
||||||
export interface ActionTypes {
|
|
||||||
REQUEST: REQUEST;
|
|
||||||
REQUEST_SUCCESS: REQUEST_SUCCESS;
|
|
||||||
REQUEST_FAILURE: REQUEST_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const actionTypes: ActionTypes = {
|
|
||||||
REQUEST: '@overflow/member/signin/REQUEST',
|
|
||||||
REQUEST_SUCCESS: '@overflow/member/signin/REQUEST_SUCCESS',
|
|
||||||
REQUEST_FAILURE: '@overflow/member/signin/REQUEST_FAILURE',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default actionTypes;
|
|
|
@ -1,3 +0,0 @@
|
||||||
export * from './state';
|
|
||||||
export * from './reducer';
|
|
||||||
export * from './saga';
|
|
|
@ -1,25 +0,0 @@
|
||||||
import Action from 'commons/redux/Action';
|
|
||||||
import IModule from 'commons/redux/Module';
|
|
||||||
|
|
||||||
import Member from 'member/api/model/Member';
|
|
||||||
|
|
||||||
import actionTypes from '../action/type';
|
|
||||||
import State, { defaultState } from '../state';
|
|
||||||
|
|
||||||
|
|
||||||
export function reducer(state: State = defaultState, action: Action<Member | Error>): State {
|
|
||||||
switch (action.type) {
|
|
||||||
case actionTypes.REQUEST_SUCCESS:
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
case actionTypes.REQUEST_FAILURE:
|
|
||||||
{
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
import { SagaIterator } from 'redux-saga';
|
|
||||||
import { fork, ForkEffect } from 'redux-saga/effects';
|
|
||||||
|
|
||||||
import { watchSignin } from './signin';
|
|
||||||
|
|
||||||
export function* sagas(): SagaIterator {
|
|
||||||
yield fork(watchSignin);
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
export * from './redux';
|
|
|
@ -1,33 +0,0 @@
|
||||||
import Action from 'commons/redux/Action';
|
|
||||||
|
|
||||||
import actionTypes from './type';
|
|
||||||
import SignoutPayload from '../payload/SignoutPayload';
|
|
||||||
|
|
||||||
export interface Actions {
|
|
||||||
request: () => Action;
|
|
||||||
requestSuccess: () => Action;
|
|
||||||
requestFailure: (error: Error) => Action;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const actions: Actions = {
|
|
||||||
request(): Action {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
requestSuccess(): Action {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST_SUCCESS,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
requestFailure(error: Error): Action {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST_FAILURE,
|
|
||||||
error: error,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default actions;
|
|
|
@ -1,17 +0,0 @@
|
||||||
export type REQUEST = '@overflow/member/signout/REQUEST';
|
|
||||||
export type REQUEST_SUCCESS = '@overflow/member/signout/REQUEST_SUCCESS';
|
|
||||||
export type REQUEST_FAILURE = '@overflow/member/signout/REQUEST_FAILURE';
|
|
||||||
|
|
||||||
export interface ActionTypes {
|
|
||||||
REQUEST: REQUEST;
|
|
||||||
REQUEST_SUCCESS: REQUEST_SUCCESS;
|
|
||||||
REQUEST_FAILURE: REQUEST_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const actionTypes: ActionTypes = {
|
|
||||||
REQUEST: '@overflow/member/signout/REQUEST',
|
|
||||||
REQUEST_SUCCESS: '@overflow/member/signout/REQUEST_SUCCESS',
|
|
||||||
REQUEST_FAILURE: '@overflow/member/signout/REQUEST_FAILURE',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default actionTypes;
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from './state';
|
|
||||||
export * from './reducer';
|
|
|
@ -1,4 +0,0 @@
|
||||||
interface SignoutPayload {
|
|
||||||
}
|
|
||||||
|
|
||||||
export default SignoutPayload;
|
|
|
@ -1,21 +0,0 @@
|
||||||
import Action from 'commons/redux/Action';
|
|
||||||
import IModule from 'commons/redux/Module';
|
|
||||||
import actionTypes from '../action/type';
|
|
||||||
import State, { defaultState } from '../state';
|
|
||||||
|
|
||||||
|
|
||||||
export function reducer(state: State = defaultState, action: Action): State {
|
|
||||||
switch (action.type) {
|
|
||||||
case actionTypes.REQUEST_SUCCESS:
|
|
||||||
{
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
case actionTypes.REQUEST_FAILURE:
|
|
||||||
{
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
// import Action from 'commons/redux/Action';
|
|
||||||
// import { SigninPayload } from 'member/signin/redux';
|
|
||||||
// import { takeLatest } from 'redux-saga';
|
|
||||||
// import { call, put } from 'redux-saga/effects';
|
|
||||||
|
|
||||||
// export function * signin(action: Action<SigninPayload>) {
|
|
||||||
// try {
|
|
||||||
// const {signinId, signinPw} = action.payload;
|
|
||||||
// yield put({
|
|
||||||
// type: types.SENDING_REQUEST,
|
|
||||||
// payload: {sendingRequest: true},
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const responseBody = yield call(api.login, signinId, signinPw);
|
|
||||||
|
|
||||||
// if (responseBody.token === undefined) {
|
|
||||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// yield put({
|
|
||||||
// type: types.LOGIN__SUCCEEDED,
|
|
||||||
// payload: {
|
|
||||||
// idToken: responseBody.token,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// } catch (e) {
|
|
||||||
// yield put({
|
|
||||||
// type: types.LOGIN__FAILED,
|
|
||||||
// payload: {
|
|
||||||
// message: e.message,
|
|
||||||
// statusCode: e.statusCode,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// } finally {
|
|
||||||
// yield put({
|
|
||||||
// type: types.SENDING_REQUEST,
|
|
||||||
// payload: {sendingRequest: false},
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export function * watchSignin() {
|
|
||||||
// yield * takeLatest(types.LOGIN__REQUESTED, signin);
|
|
||||||
// }
|
|
|
@ -1,15 +0,0 @@
|
||||||
import Member from 'member/api/model/Member';
|
|
||||||
|
|
||||||
export interface State {
|
|
||||||
isAuthenticated: boolean;
|
|
||||||
member?: Member;
|
|
||||||
error?: Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultState: State = {
|
|
||||||
isAuthenticated: undefined,
|
|
||||||
member: undefined,
|
|
||||||
error: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default State;
|
|
|
@ -1,85 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
import * as ReactDOM from 'react-dom';
|
|
||||||
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
Divider,
|
|
||||||
FlatButton,
|
|
||||||
MenuItem,
|
|
||||||
Paper,
|
|
||||||
RaisedButton,
|
|
||||||
SelectField,
|
|
||||||
Slider,
|
|
||||||
TextField,
|
|
||||||
} from 'material-ui';
|
|
||||||
|
|
||||||
export interface Props {
|
|
||||||
onSignin?: (signinId: string, signinPw: string) => void;
|
|
||||||
onSignup?: () => void;
|
|
||||||
onResetPassword?: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface State {
|
|
||||||
signinId: string;
|
|
||||||
signinPw: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Signin extends React.Component<Props, State> {
|
|
||||||
public static defaultProps: Partial<Props> = {
|
|
||||||
onSignin: (signinId: string, signinPw: string): void => {
|
|
||||||
console.log('onSignin');
|
|
||||||
},
|
|
||||||
onSignup: (): void => {
|
|
||||||
console.log('onSignup');
|
|
||||||
},
|
|
||||||
onResetPassword: (): void => {
|
|
||||||
console.log('onResetPassword');
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
public constructor(props: Props, context: State) {
|
|
||||||
super(props, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public render(): JSX.Element {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<TextField
|
|
||||||
hintText='smith@gmail.com'
|
|
||||||
floatingLabelText='Email address*'
|
|
||||||
errorText=''
|
|
||||||
underlineShow={true}
|
|
||||||
value={this.state.signinId}
|
|
||||||
onChange={(e, newValue) => this.setState({ signinId: newValue })}
|
|
||||||
/>
|
|
||||||
<br />
|
|
||||||
<TextField
|
|
||||||
hintText='Password'
|
|
||||||
floatingLabelText='Password'
|
|
||||||
type='password'
|
|
||||||
value={this.state.signinPw}
|
|
||||||
onChange={(e, newValue) => this.setState({ signinPw: newValue })}
|
|
||||||
/>
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<RaisedButton
|
|
||||||
label='Sign In'
|
|
||||||
primary={true}
|
|
||||||
onClick={(e) => this.props.onSignin(this.state.signinId, this.state.signinPw)}
|
|
||||||
/>
|
|
||||||
<RaisedButton
|
|
||||||
label='Sign Up'
|
|
||||||
primary={false}
|
|
||||||
onClick={this.props.onSignup}
|
|
||||||
/>
|
|
||||||
<RaisedButton
|
|
||||||
label='Reset Password'
|
|
||||||
primary={false}
|
|
||||||
onClick={this.props.onResetPassword}
|
|
||||||
/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
export * from './redux';
|
|
|
@ -1,37 +0,0 @@
|
||||||
import Action from 'commons/redux/Action';
|
|
||||||
|
|
||||||
import Member from 'member/api/model/Member';
|
|
||||||
|
|
||||||
import actionTypes from './type';
|
|
||||||
import SignupPayload from '../payload/SignupPayload';
|
|
||||||
|
|
||||||
export interface Actions {
|
|
||||||
request: (signupPayload: SignupPayload) => Action<SignupPayload>;
|
|
||||||
requestSuccess: (member: Member) => Action<Member>;
|
|
||||||
requestFailure: (error: Error) => Action;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const actions: Actions = {
|
|
||||||
request(signupPayload: SignupPayload): Action<SignupPayload> {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST,
|
|
||||||
payload: signupPayload,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
requestSuccess(member: Member): Action<Member> {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST_SUCCESS,
|
|
||||||
payload: member,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
requestFailure(error: Error): Action {
|
|
||||||
return {
|
|
||||||
type: actionTypes.REQUEST_FAILURE,
|
|
||||||
error: error,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default actions;
|
|
|
@ -1,17 +0,0 @@
|
||||||
export type REQUEST = '@overflow/member/signup/REQUEST';
|
|
||||||
export type REQUEST_SUCCESS = '@overflow/member/signup/REQUEST_SUCCESS';
|
|
||||||
export type REQUEST_FAILURE = '@overflow/member/signup/REQUEST_FAILURE';
|
|
||||||
|
|
||||||
export interface ActionTypes {
|
|
||||||
REQUEST: REQUEST;
|
|
||||||
REQUEST_SUCCESS: REQUEST_SUCCESS;
|
|
||||||
REQUEST_FAILURE: REQUEST_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const actionTypes: ActionTypes = {
|
|
||||||
REQUEST: '@overflow/member/signup/REQUEST',
|
|
||||||
REQUEST_SUCCESS: '@overflow/member/signup/REQUEST_SUCCESS',
|
|
||||||
REQUEST_FAILURE: '@overflow/member/signup/REQUEST_FAILURE',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default actionTypes;
|
|
|
@ -1,2 +0,0 @@
|
||||||
export * from './state';
|
|
||||||
export * from './reducer';
|
|
|
@ -1,6 +0,0 @@
|
||||||
import Member from 'member/api/model/Member';
|
|
||||||
|
|
||||||
interface SignupPayload extends Member {
|
|
||||||
}
|
|
||||||
|
|
||||||
export default SignupPayload;
|
|
|
@ -1,24 +0,0 @@
|
||||||
import Action from 'commons/redux/Action';
|
|
||||||
import IModule from 'commons/redux/Module';
|
|
||||||
|
|
||||||
import Member from 'member/api/model/Member';
|
|
||||||
|
|
||||||
import actionTypes from '../action/type';
|
|
||||||
import State, { defaultState } from '../state';
|
|
||||||
|
|
||||||
|
|
||||||
export function reducer(state: State = defaultState, action: Action<Member | Error>): State {
|
|
||||||
switch (action.type) {
|
|
||||||
case actionTypes.REQUEST_SUCCESS:
|
|
||||||
{
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
case actionTypes.REQUEST_FAILURE:
|
|
||||||
{
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
// import Action from 'commons/redux/Action';
|
|
||||||
// import { SigninPayload } from 'member/signin/redux';
|
|
||||||
// import { takeLatest } from 'redux-saga';
|
|
||||||
// import { call, put } from 'redux-saga/effects';
|
|
||||||
|
|
||||||
// export function * signin(action: Action<SigninPayload>) {
|
|
||||||
// try {
|
|
||||||
// const {signinId, signinPw} = action.payload;
|
|
||||||
// yield put({
|
|
||||||
// type: types.SENDING_REQUEST,
|
|
||||||
// payload: {sendingRequest: true},
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const responseBody = yield call(api.login, signinId, signinPw);
|
|
||||||
|
|
||||||
// if (responseBody.token === undefined) {
|
|
||||||
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// yield put({
|
|
||||||
// type: types.LOGIN__SUCCEEDED,
|
|
||||||
// payload: {
|
|
||||||
// idToken: responseBody.token,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// } catch (e) {
|
|
||||||
// yield put({
|
|
||||||
// type: types.LOGIN__FAILED,
|
|
||||||
// payload: {
|
|
||||||
// message: e.message,
|
|
||||||
// statusCode: e.statusCode,
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
// } finally {
|
|
||||||
// yield put({
|
|
||||||
// type: types.SENDING_REQUEST,
|
|
||||||
// payload: {sendingRequest: false},
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// export function * watchSignin() {
|
|
||||||
// yield * takeLatest(types.LOGIN__REQUESTED, signin);
|
|
||||||
// }
|
|
|
@ -1,85 +0,0 @@
|
||||||
import * as React from 'react';
|
|
||||||
import * as ReactDOM from 'react-dom';
|
|
||||||
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
Divider,
|
|
||||||
FlatButton,
|
|
||||||
MenuItem,
|
|
||||||
Paper,
|
|
||||||
RaisedButton,
|
|
||||||
SelectField,
|
|
||||||
Slider,
|
|
||||||
TextField,
|
|
||||||
} from 'material-ui';
|
|
||||||
|
|
||||||
export interface Props {
|
|
||||||
onSignin?: (signinId: string, signinPw: string) => void;
|
|
||||||
onSignup?: () => void;
|
|
||||||
onResetPassword?: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface State {
|
|
||||||
signinId: string;
|
|
||||||
signinPw: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Signin extends React.Component<Props, State> {
|
|
||||||
public static defaultProps: Partial<Props> = {
|
|
||||||
onSignin: (signinId: string, signinPw: string): void => {
|
|
||||||
console.log('onSignin');
|
|
||||||
},
|
|
||||||
onSignup: (): void => {
|
|
||||||
console.log('onSignup');
|
|
||||||
},
|
|
||||||
onResetPassword: (): void => {
|
|
||||||
console.log('onResetPassword');
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
public constructor(props: Props, context: State) {
|
|
||||||
super(props, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public render(): JSX.Element {
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<TextField
|
|
||||||
hintText='smith@gmail.com'
|
|
||||||
floatingLabelText='Email address*'
|
|
||||||
errorText=''
|
|
||||||
underlineShow={true}
|
|
||||||
value={this.state.signinId}
|
|
||||||
onChange={(e, newValue) => this.setState({ signinId: newValue })}
|
|
||||||
/>
|
|
||||||
<br />
|
|
||||||
<TextField
|
|
||||||
hintText='Password'
|
|
||||||
floatingLabelText='Password'
|
|
||||||
type='password'
|
|
||||||
value={this.state.signinPw}
|
|
||||||
onChange={(e, newValue) => this.setState({ signinPw: newValue })}
|
|
||||||
/>
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<RaisedButton
|
|
||||||
label='Sign In'
|
|
||||||
primary={true}
|
|
||||||
onClick={(e) => this.props.onSignin(this.state.signinId, this.state.signinPw)}
|
|
||||||
/>
|
|
||||||
<RaisedButton
|
|
||||||
label='Sign Up'
|
|
||||||
primary={false}
|
|
||||||
onClick={this.props.onSignup}
|
|
||||||
/>
|
|
||||||
<RaisedButton
|
|
||||||
label='Reset Password'
|
|
||||||
primary={false}
|
|
||||||
onClick={this.props.onResetPassword}
|
|
||||||
/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
} from 'material-ui';
|
} from 'material-ui';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
isSignin?: boolean;
|
||||||
onSignin?: (signinId: string, signinPw: string) => void;
|
onSignin?: (signinId: string, signinPw: string) => void;
|
||||||
onSignup?: () => void;
|
onSignup?: () => void;
|
||||||
onResetPassword?: () => void;
|
onResetPassword?: () => void;
|
||||||
|
@ -48,7 +49,7 @@ export class Signin extends React.Component<Props, State> {
|
||||||
|
|
||||||
public render(): JSX.Element {
|
public render(): JSX.Element {
|
||||||
|
|
||||||
return (
|
return (this.props.isSignin ? <div>Signed</div> :
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
hintText='smith@gmail.com'
|
hintText='smith@gmail.com'
|
|
@ -3,13 +3,15 @@ import {
|
||||||
Signin,
|
Signin,
|
||||||
Props as SigninProps,
|
Props as SigninProps,
|
||||||
State as SigninState,
|
State as SigninState,
|
||||||
} from './components/Signin';
|
} from '../components/Signin';
|
||||||
|
import State from 'member/signin/redux/state';
|
||||||
|
|
||||||
import signinActions from 'member/signin/redux/action';
|
import signinActions from 'member/signin/redux/action';
|
||||||
|
|
||||||
|
|
||||||
export function mapStateToProps(state: any): SigninProps {
|
export function mapStateToProps(state: any): SigninProps {
|
||||||
return {
|
return {
|
||||||
|
isSignin: state.member.signin.isAuthenticated,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user