diff --git a/src/ts/@overflow/domain/redux/action/member_regist.ts b/src/ts/@overflow/domain/redux/action/member_regist.ts new file mode 100644 index 0000000..2fb6a9f --- /dev/null +++ b/src/ts/@overflow/domain/redux/action/member_regist.ts @@ -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; +export type requestSuccess = () => Action; +export type requestFailure = (error: Error) => Action; + +export const request: request = (domainMember: DomainMember): Action => { + return { + type: REQUEST, + payload: { + domainMember: domainMember, + }, + }; +}; + +export const requestSuccess: requestSuccess = (): Action => { + return { + type: REQUEST_SUCCESS, + payload: null, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/domain/redux/action/regist.ts b/src/ts/@overflow/domain/redux/action/regist.ts new file mode 100644 index 0000000..980613f --- /dev/null +++ b/src/ts/@overflow/domain/redux/action/regist.ts @@ -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; +export type requestSuccess = () => Action; +export type requestFailure = (error: Error) => Action; + +export const request: request = (domain: Domain): Action => { + return { + type: REQUEST, + payload: { + domain: domain, + }, + }; +}; + +export const requestSuccess: requestSuccess = (): Action => { + return { + type: REQUEST_SUCCESS, + payload: null, + }; +}; + +export const requestFailure: requestFailure = (error: Error): Action => { + return { + type: REQUEST_FAILURE, + error: error, + }; +}; diff --git a/src/ts/@overflow/domain/redux/payload/MemberRegistPayload.ts b/src/ts/@overflow/domain/redux/payload/MemberRegistPayload.ts new file mode 100644 index 0000000..f5f79f9 --- /dev/null +++ b/src/ts/@overflow/domain/redux/payload/MemberRegistPayload.ts @@ -0,0 +1,7 @@ +import DomainMember from '../../api/model/DomainMember'; + +interface MemberRegistPayload { + domainMember: DomainMember; +} + +export default MemberRegistPayload; diff --git a/src/ts/@overflow/domain/redux/payload/RegistPayload.ts b/src/ts/@overflow/domain/redux/payload/RegistPayload.ts new file mode 100644 index 0000000..613c6da --- /dev/null +++ b/src/ts/@overflow/domain/redux/payload/RegistPayload.ts @@ -0,0 +1,6 @@ +import Domain from '../../api/model/Domain'; +interface RegistPayload { + domain: Domain; +} + +export default RegistPayload; diff --git a/src/ts/@overflow/domain/redux/reducer/domain_member_regist.ts b/src/ts/@overflow/domain/redux/reducer/domain_member_regist.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/domain/redux/reducer/domain_regist.ts b/src/ts/@overflow/domain/redux/reducer/domain_regist.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/domain/redux/action/domain_member_regist.ts b/src/ts/@overflow/domain/redux/reducer/member_regist.ts similarity index 100% rename from src/ts/@overflow/domain/redux/action/domain_member_regist.ts rename to src/ts/@overflow/domain/redux/reducer/member_regist.ts diff --git a/src/ts/@overflow/domain/redux/action/domain_regist.ts b/src/ts/@overflow/domain/redux/reducer/regist.ts similarity index 100% rename from src/ts/@overflow/domain/redux/action/domain_regist.ts rename to src/ts/@overflow/domain/redux/reducer/regist.ts diff --git a/src/ts/@overflow/domain/redux/saga/domain_member_regist.ts b/src/ts/@overflow/domain/redux/saga/domain_member_regist.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/domain/redux/saga/domain_regist.ts b/src/ts/@overflow/domain/redux/saga/domain_regist.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/domain/redux/saga/member_regist.ts b/src/ts/@overflow/domain/redux/saga/member_regist.ts new file mode 100644 index 0000000..493d6c7 --- /dev/null +++ b/src/ts/@overflow/domain/redux/saga/member_regist.ts @@ -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): SagaIterator { + try { + const dm = action.payload.domainMember; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + yield call(AppContext.getService().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); +} diff --git a/src/ts/@overflow/domain/redux/saga/regist.ts b/src/ts/@overflow/domain/redux/saga/regist.ts new file mode 100644 index 0000000..6916d4d --- /dev/null +++ b/src/ts/@overflow/domain/redux/saga/regist.ts @@ -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): SagaIterator { + try { + const dm = action.payload.domain; + // yield put({ + // type: types.SENDING_REQUEST, + // payload: {sendingRequest: true}, + // }); + + yield call(AppContext.getService().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); +} diff --git a/src/ts/@overflow/domain/redux/state/domain_member_regist.ts b/src/ts/@overflow/domain/redux/state/domain_member_regist.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/domain/redux/state/domain_regist.ts b/src/ts/@overflow/domain/redux/state/domain_regist.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/ts/@overflow/domain/redux/payload/DomainMemberRegistPayload.ts b/src/ts/@overflow/domain/redux/state/member_regist.ts similarity index 100% rename from src/ts/@overflow/domain/redux/payload/DomainMemberRegistPayload.ts rename to src/ts/@overflow/domain/redux/state/member_regist.ts diff --git a/src/ts/@overflow/domain/redux/payload/DomainRegistPayload.ts b/src/ts/@overflow/domain/redux/state/regist.ts similarity index 100% rename from src/ts/@overflow/domain/redux/payload/DomainRegistPayload.ts rename to src/ts/@overflow/domain/redux/state/regist.ts