domain redux push
This commit is contained in:
parent
6c31de500d
commit
27408bb790
41
src/ts/@overflow/domain/redux/action/member_regist.ts
Normal file
41
src/ts/@overflow/domain/redux/action/member_regist.ts
Normal 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,
|
||||||
|
};
|
||||||
|
};
|
41
src/ts/@overflow/domain/redux/action/regist.ts
Normal file
41
src/ts/@overflow/domain/redux/action/regist.ts
Normal 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,
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,7 @@
|
||||||
|
import DomainMember from '../../api/model/DomainMember';
|
||||||
|
|
||||||
|
interface MemberRegistPayload {
|
||||||
|
domainMember: DomainMember;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MemberRegistPayload;
|
6
src/ts/@overflow/domain/redux/payload/RegistPayload.ts
Normal file
6
src/ts/@overflow/domain/redux/payload/RegistPayload.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import Domain from '../../api/model/Domain';
|
||||||
|
interface RegistPayload {
|
||||||
|
domain: Domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RegistPayload;
|
39
src/ts/@overflow/domain/redux/saga/member_regist.ts
Normal file
39
src/ts/@overflow/domain/redux/saga/member_regist.ts
Normal 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);
|
||||||
|
}
|
39
src/ts/@overflow/domain/redux/saga/regist.ts
Normal file
39
src/ts/@overflow/domain/redux/saga/regist.ts
Normal 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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user