domain redux push

This commit is contained in:
geek 2017-07-04 16:32:08 +09:00
parent 6c31de500d
commit 27408bb790
16 changed files with 173 additions and 0 deletions

View File

@ -0,0 +1,41 @@
import Action from '@overflow/commons/redux/Action';
import DomainMember from '@overflow/domain/api/model/DomainMember';
import MemberRegistPayload from '../payload/MemberRegistPayload';
// Action Type
export type REQUEST = '@overflow/domain/member_regist/REQUEST';
export type REQUEST_SUCCESS = '@overflow/domain/member_regist/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/domain/member_regist/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/domain/member_regist/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/domain/member_regist/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/domain/member_regist/REQUEST_FAILURE';
// Action Creater
export type request = (domain: DomainMember) => Action<MemberRegistPayload>;
export type requestSuccess = () => Action<void>;
export type requestFailure = (error: Error) => Action;
export const request: request = (domainMember: DomainMember): Action<MemberRegistPayload> => {
return {
type: REQUEST,
payload: {
domainMember: domainMember,
},
};
};
export const requestSuccess: requestSuccess = (): Action<void> => {
return {
type: REQUEST_SUCCESS,
payload: null,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,41 @@
import Action from '@overflow/commons/redux/Action';
import Domain from '@overflow/domain/api/model/Domain';
import RegistPayload from '../payload/RegistPayload';
// Action Type
export type REQUEST = '@overflow/domain/regist/REQUEST';
export type REQUEST_SUCCESS = '@overflow/domain/regist/REQUEST_SUCCESS';
export type REQUEST_FAILURE = '@overflow/domain/regist/REQUEST_FAILURE';
export const REQUEST: REQUEST = '@overflow/domain/regist/REQUEST';
export const REQUEST_SUCCESS: REQUEST_SUCCESS = '@overflow/domain/regist/REQUEST_SUCCESS';
export const REQUEST_FAILURE: REQUEST_FAILURE = '@overflow/domain/regist/REQUEST_FAILURE';
// Action Creater
export type request = (domain: Domain) => Action<RegistPayload>;
export type requestSuccess = () => Action<void>;
export type requestFailure = (error: Error) => Action;
export const request: request = (domain: Domain): Action<RegistPayload> => {
return {
type: REQUEST,
payload: {
domain: domain,
},
};
};
export const requestSuccess: requestSuccess = (): Action<void> => {
return {
type: REQUEST_SUCCESS,
payload: null,
};
};
export const requestFailure: requestFailure = (error: Error): Action => {
return {
type: REQUEST_FAILURE,
error: error,
};
};

View File

@ -0,0 +1,7 @@
import DomainMember from '../../api/model/DomainMember';
interface MemberRegistPayload {
domainMember: DomainMember;
}
export default MemberRegistPayload;

View File

@ -0,0 +1,6 @@
import Domain from '../../api/model/Domain';
interface RegistPayload {
domain: Domain;
}
export default RegistPayload;

View File

@ -0,0 +1,39 @@
import { SagaIterator } from 'redux-saga';
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
import AppContext from '@overflow/commons/context';
import Action from '@overflow/commons/redux/Action';
import DomainMember from '../../api/model/DomainMember';
import DomainMemberService from '../../api/service/DomainMemberService';
import * as MemberRegistActions from '../action/member_regist';
import MemberRegistPayload from '../payload/MemberRegistPayload';
function* regist(action: Action<MemberRegistPayload>): SagaIterator {
try {
const dm = action.payload.domainMember;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
yield call(AppContext.getService<DomainMemberService>().regist, dm);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(MemberRegistActions.requestSuccess());
} catch (e) {
yield put(MemberRegistActions.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchDomainMemberRegist(): SagaIterator {
yield takeLatest(MemberRegistActions.REQUEST, regist);
}

View File

@ -0,0 +1,39 @@
import { SagaIterator } from 'redux-saga';
import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects';
import AppContext from '@overflow/commons/context';
import Action from '@overflow/commons/redux/Action';
import Domain from '../../api/model/Domain';
import DomainService from '../../api/service/DomainService';
import * as RegistActions from '../action/regist';
import RegistPayload from '../payload/RegistPayload';
function* regist(action: Action<RegistPayload>): SagaIterator {
try {
const dm = action.payload.domain;
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: true},
// });
yield call(AppContext.getService<DomainService>().regist, dm);
// if (responseBody.token === undefined) {
// throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE);
// }
yield put(RegistActions.requestSuccess());
} catch (e) {
yield put(RegistActions.requestFailure(e));
} finally {
// yield put({
// type: types.SENDING_REQUEST,
// payload: {sendingRequest: false},
// });
}
}
export function* watchDomainRegist(): SagaIterator {
yield takeLatest(RegistActions.REQUEST, regist);
}