From 20876da23b6bb0ace2e96a05454aa63eeb475721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Myeongjae=20Kim=20=E1=84=80=E1=85=B5=E1=86=B7=E1=84=86?= =?UTF-8?q?=E1=85=A7=E1=86=BC=E1=84=8C=E1=85=A2?= Date: Sun, 27 Oct 2019 22:38:41 +0900 Subject: [PATCH] [#22] Remove annotations from browser codes --- .babelrc | 16 +------------- package.json | 2 -- pages/_app.tsx | 4 ++-- .../service/CommonErrorServiceImpl.ts | 8 +++---- src/common/inversify.id.ts | 5 ----- .../components/atmos/ImmutableTextField.tsx | 4 ++-- .../components/atmos/LanguageToggleButton.tsx | 4 ++-- .../components/molecules/Confirm.tsx | 4 ++-- .../components/templates/CmsLayout.tsx | 4 ++-- .../container/molecules/SnackbarContainer.tsx | 4 ++-- src/inversifyConfig.ts | 19 ----------------- src/inversifyIds.ts | 9 -------- src/inversifyServices.ts | 21 ------------------- src/mother/inversify.id.ts | 7 ------- .../repository/NoticeRepositoryImpl.ts | 12 +++++------ .../service/NoticeServiceImpl.ts | 8 +++---- src/mother/notice/inversify.id.ts | 6 ------ .../components/organisms/NoticeDetail.tsx | 6 ++---- .../components/organisms/NoticeList.tsx | 4 ++-- .../templates/NoticeForm/NoticeForm.tsx | 4 ++-- .../containers/NoticeDetailContainer.tsx | 4 ++-- .../containers/NoticeFormContainer.tsx | 4 ++-- .../presentation/state-module/detail.ts | 7 +++---- .../notice/presentation/state-module/form.ts | 9 ++++---- .../notice/presentation/state-module/list.ts | 5 ++--- 25 files changed, 45 insertions(+), 135 deletions(-) delete mode 100644 src/common/inversify.id.ts delete mode 100644 src/inversifyConfig.ts delete mode 100644 src/inversifyIds.ts delete mode 100644 src/inversifyServices.ts delete mode 100644 src/mother/inversify.id.ts delete mode 100644 src/mother/notice/inversify.id.ts diff --git a/.babelrc b/.babelrc index c22e2cd..5d4f37a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,19 +1,5 @@ { "presets": [ - "next/babel", - ], - "plugins": [ - [ - "@babel/plugin-proposal-decorators", - { - "legacy": true - } - ], - [ - "@babel/plugin-proposal-class-properties", - { - "loose": true - } - ] + "next/babel" ] } \ No newline at end of file diff --git a/package.json b/package.json index a764687..7a3b383 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,6 @@ "winston": "^3.2.1" }, "devDependencies": { - "@babel/plugin-proposal-class-properties": "^7.5.5", - "@babel/plugin-proposal-decorators": "^7.4.4", "@types/assert-plus": "^1.0.4", "@types/axios": "^0.14.0", "@types/enzyme": "^3.10.3", diff --git a/pages/_app.tsx b/pages/_app.tsx index 432591f..7a43473 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -16,9 +16,9 @@ import NotificationCenterContainer from 'src/common/presentation/container/organ import CmsLayoutContainer from 'src/common/presentation/container/templates/CmsLayoutContainer'; import { setPaths } from 'src/common/presentation/state-module/common'; import { rootReducer, rootSaga, RootState } from 'src/common/presentation/state-module/root'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; -const { appWithTranslation } = inversifyServices.common.i18NService; +const { appWithTranslation } = I18NService; const makeStore = (preloadedState = {} as RootState) => { const bindMiddleware = (middlewares: Middleware[]) => { diff --git a/src/common/infrastructure/service/CommonErrorServiceImpl.ts b/src/common/infrastructure/service/CommonErrorServiceImpl.ts index 8c0e0fb..c777d05 100644 --- a/src/common/infrastructure/service/CommonErrorServiceImpl.ts +++ b/src/common/infrastructure/service/CommonErrorServiceImpl.ts @@ -1,10 +1,10 @@ -import { injectable } from "inversify"; import RepositoryError, { RepositoryErrorData } from "src/common/domain/RepositoryError"; import CommonErrorService from "src/common/service/CommonErrorService"; -@injectable() -export default class CommonErrorServiceImpl implements CommonErrorService { +class CommonErrorServiceImpl implements CommonErrorService { public createRepositoryErrorFrom(e?: RepositoryErrorData): RepositoryError { return RepositoryError.of(e); } -} \ No newline at end of file +} + +export default new CommonErrorServiceImpl(); \ No newline at end of file diff --git a/src/common/inversify.id.ts b/src/common/inversify.id.ts deleted file mode 100644 index 3009fb1..0000000 --- a/src/common/inversify.id.ts +++ /dev/null @@ -1,5 +0,0 @@ -const common = { - CommonErrorService: Symbol.for("@notice/CommonErrorService"), -}; - -export { common }; \ No newline at end of file diff --git a/src/common/presentation/components/atmos/ImmutableTextField.tsx b/src/common/presentation/components/atmos/ImmutableTextField.tsx index b0575e7..73bcc75 100644 --- a/src/common/presentation/components/atmos/ImmutableTextField.tsx +++ b/src/common/presentation/components/atmos/ImmutableTextField.tsx @@ -3,7 +3,7 @@ import { TextFieldProps } from '@material-ui/core/TextField'; import { makeStyles } from '@material-ui/styles'; import clsx from 'clsx' import * as React from 'react'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; const useStyles = makeStyles(createStyles({ root: { @@ -11,7 +11,7 @@ const useStyles = makeStyles(createStyles({ } })); -const { useTranslation } = inversifyServices.common.i18NService; +const { useTranslation } = I18NService; const ImmutableTextField: React.FC = ( props diff --git a/src/common/presentation/components/atmos/LanguageToggleButton.tsx b/src/common/presentation/components/atmos/LanguageToggleButton.tsx index 086a636..33a7864 100644 --- a/src/common/presentation/components/atmos/LanguageToggleButton.tsx +++ b/src/common/presentation/components/atmos/LanguageToggleButton.tsx @@ -1,9 +1,9 @@ import { Button } from '@material-ui/core'; import * as React from 'react'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import Maybe from './Maybe'; -const { i18n } = inversifyServices.common.i18NService; +const { i18n } = I18NService; const toggleLanguage = () => i18n.changeLanguage(i18n.language === 'ko' ? 'en' : 'ko'); const LanguageToggleButton: React.FC = () => diff --git a/src/common/presentation/components/molecules/Confirm.tsx b/src/common/presentation/components/molecules/Confirm.tsx index 05bd581..c01b4d4 100644 --- a/src/common/presentation/components/molecules/Confirm.tsx +++ b/src/common/presentation/components/molecules/Confirm.tsx @@ -4,7 +4,7 @@ import { fade } from '@material-ui/core/styles'; import { createStyles, makeStyles } from '@material-ui/styles'; import clsx from 'clsx'; import * as React from 'react'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import { ConfirmPayload } from '../../state-module/common'; const useStyles = makeStyles((theme: Theme) => createStyles({ @@ -31,7 +31,7 @@ interface Props { closeConfirmDialog(): void } -const { useTranslation } = inversifyServices.common.i18NService; +const { useTranslation } = I18NService; const Confirm: React.FC = ({ isConfirmOpened, confirmData, closeConfirmDialog }) => { const classes = useStyles(); diff --git a/src/common/presentation/components/templates/CmsLayout.tsx b/src/common/presentation/components/templates/CmsLayout.tsx index 0c048ed..63629b4 100644 --- a/src/common/presentation/components/templates/CmsLayout.tsx +++ b/src/common/presentation/components/templates/CmsLayout.tsx @@ -18,7 +18,7 @@ import React, { Fragment } from 'react'; import { WithTranslation } from 'react-i18next'; import { FirstDepthPath } from 'src/common/domain/constants/FIRST_DEPTH_PATHS'; import SIDE_BAR_ITEMS from 'src/common/domain/constants/SIDE_BAR_ITEMS'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import HorizontalMenuBarContainer from '../../container/molecules/HorizontalMenuBarContainer'; import LanguageToggleButton from '../atmos/LanguageToggleButton'; import Link from '../atmos/Link'; @@ -27,7 +27,7 @@ import NotificationCenterButton from '../atmos/NotificationCenterButton'; const drawerWidth = 240; const horizontalMenuBarHeight = 31; /* manually calculate the height of horizonMenuBar */ -const { withTranslation } = inversifyServices.common.i18NService; +const { withTranslation } = I18NService; const useStyles = makeStyles((theme: Theme) => createStyles({ flex: { diff --git a/src/common/presentation/container/molecules/SnackbarContainer.tsx b/src/common/presentation/container/molecules/SnackbarContainer.tsx index 2dfe707..ca36c93 100644 --- a/src/common/presentation/container/molecules/SnackbarContainer.tsx +++ b/src/common/presentation/container/molecules/SnackbarContainer.tsx @@ -5,7 +5,7 @@ import * as React from 'react'; import { WithTranslation } from 'react-i18next'; import { connect } from 'react-redux'; import { bindActionCreators, Dispatch } from 'redux'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import { RootState } from '../../state-module/root'; import * as snackbarModule from '../../state-module/snackbar'; import { Snackbar } from '../../state-module/snackbar'; @@ -15,7 +15,7 @@ interface Props extends WithSnackbarProps, WithTranslation { dispatchers: typeof snackbarModule } -const { withTranslation } = inversifyServices.common.i18NService; +const { withTranslation } = I18NService; class SnackbarContainer extends React.Component { private displayed: string[] = []; diff --git a/src/inversifyConfig.ts b/src/inversifyConfig.ts deleted file mode 100644 index f02473c..0000000 --- a/src/inversifyConfig.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Container } from "inversify"; -import "reflect-metadata"; -import CommonErrorServiceImpl from "src/common/infrastructure/service/CommonErrorServiceImpl"; -import CommonErrorService from "src/common/service/CommonErrorService"; -import { inversifyIds } from 'src/inversifyIds'; -import NoticeRepository from "src/mother/notice/domain/NoticeRepository"; -import NoticeRepositoryImpl from "src/mother/notice/infrastructure/repository/NoticeRepositoryImpl"; -import NoticeServiceImpl from "src/mother/notice/infrastructure/service/NoticeServiceImpl"; -import NoticeService from "src/mother/notice/service/NoticeService"; - -const { mother, common } = inversifyIds; - -const inversifyContainer = new Container(); - -inversifyContainer.bind(mother.notice.NoticeRepository).to(NoticeRepositoryImpl); -inversifyContainer.bind(mother.notice.NoticeService).to(NoticeServiceImpl); -inversifyContainer.bind(common.CommonErrorService).to(CommonErrorServiceImpl); - -export { inversifyContainer }; diff --git a/src/inversifyIds.ts b/src/inversifyIds.ts deleted file mode 100644 index 581d23e..0000000 --- a/src/inversifyIds.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { common } from './common/inversify.id' -import { mother } from './mother/inversify.id' - -const inversifyIds = { - mother, - common -} - -export { inversifyIds } \ No newline at end of file diff --git a/src/inversifyServices.ts b/src/inversifyServices.ts deleted file mode 100644 index eeecb33..0000000 --- a/src/inversifyServices.ts +++ /dev/null @@ -1,21 +0,0 @@ -import Axios from "axios"; -import CommonErrorService from "src/common/service/CommonErrorService"; -import { inversifyContainer } from "src/inversifyConfig"; -import { inversifyIds } from "src/inversifyIds"; -import NoticeService from "src/mother/notice/service/NoticeService"; -import I18NService from "./common/service/I18NService"; - -const inversifyServices = { - common: { - errorService: inversifyContainer.get(inversifyIds.common.CommonErrorService), - i18NService: I18NService, - axios: Axios.create() - }, - mother: { - notice: { - service: inversifyContainer.get(inversifyIds.mother.notice.NoticeService) - } - } -} - -export default inversifyServices \ No newline at end of file diff --git a/src/mother/inversify.id.ts b/src/mother/inversify.id.ts deleted file mode 100644 index 400146f..0000000 --- a/src/mother/inversify.id.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { notice } from "./notice/inversify.id" - -const mother = { - notice -} - -export { mother }; \ No newline at end of file diff --git a/src/mother/notice/infrastructure/repository/NoticeRepositoryImpl.ts b/src/mother/notice/infrastructure/repository/NoticeRepositoryImpl.ts index 08e40e8..cafe2c7 100644 --- a/src/mother/notice/infrastructure/repository/NoticeRepositoryImpl.ts +++ b/src/mother/notice/infrastructure/repository/NoticeRepositoryImpl.ts @@ -1,18 +1,16 @@ import Axios from 'axios'; -import { inject, injectable } from "inversify"; import Id from 'src/common/domain/Id'; import Page from 'src/common/domain/Page'; import PageRequest from 'src/common/domain/PageRequest'; +import CommonErrorServiceImpl from 'src/common/infrastructure/service/CommonErrorServiceImpl'; import CommonErrorService from 'src/common/service/CommonErrorService'; -import { inversifyIds } from "src/inversifyIds" import Notice from '../../domain/Notice'; import NoticeRepository from '../../domain/NoticeRepository' const NOTICE_REPO_URL = `${process.env.REPOSITORY_URL}/notices` -@injectable() -export default class NoticeRepositoryImpl implements NoticeRepository { - @inject(inversifyIds.common.CommonErrorService) private commonErrorService!: CommonErrorService +class NoticeRepositoryImpl implements NoticeRepository { + constructor(private commonErrorService: CommonErrorService) { } public findById = (id: Id): Promise => new Promise((resolve, rejected) => { Axios.get(`${NOTICE_REPO_URL}/${id}`) @@ -55,4 +53,6 @@ export default class NoticeRepositoryImpl implements NoticeRepository { .then(() => resolve()) .catch(e => rejected(this.commonErrorService.createRepositoryErrorFrom(e))); }) -} \ No newline at end of file +} + +export default new NoticeRepositoryImpl(CommonErrorServiceImpl); \ No newline at end of file diff --git a/src/mother/notice/infrastructure/service/NoticeServiceImpl.ts b/src/mother/notice/infrastructure/service/NoticeServiceImpl.ts index 9bb1c37..ad9b7f9 100644 --- a/src/mother/notice/infrastructure/service/NoticeServiceImpl.ts +++ b/src/mother/notice/infrastructure/service/NoticeServiceImpl.ts @@ -1,15 +1,13 @@ -import { decorate, inject, injectable } from "inversify"; import Id from 'src/common/domain/Id'; import Page from "src/common/domain/Page"; import PageRequest from "src/common/domain/PageRequest"; import NoticeRequestDto from "../../api/dto/NoticeRequestDto"; import Notice from "../../domain/Notice"; import NoticeRepository from "../../domain/NoticeRepository"; -import { notice } from "../../inversify.id"; import NoticeService from "../../service/NoticeService"; +import NoticeRepositoryImpl from '../repository/NoticeRepositoryImpl'; -@injectable() -export default class NoticeServiceImpl implements NoticeService { +class NoticeServiceImpl implements NoticeService { constructor(private noticeRepository: NoticeRepository) { } public getNotice = (id: Id): Promise => this.noticeRepository.findById(id) @@ -27,4 +25,4 @@ export default class NoticeServiceImpl implements NoticeService { this.noticeRepository.deleteById(id).then(() => { return }); } -decorate(inject(notice.NoticeRepository) as ParameterDecorator, NoticeServiceImpl, 0); \ No newline at end of file +export default new NoticeServiceImpl(NoticeRepositoryImpl); \ No newline at end of file diff --git a/src/mother/notice/inversify.id.ts b/src/mother/notice/inversify.id.ts deleted file mode 100644 index ba1e781..0000000 --- a/src/mother/notice/inversify.id.ts +++ /dev/null @@ -1,6 +0,0 @@ -const notice = { - NoticeRepository: Symbol.for("@mother/NoticeRepository"), - NoticeService: Symbol.for("@mother/NoticeService"), -}; - -export { notice }; \ No newline at end of file diff --git a/src/mother/notice/presentation/components/organisms/NoticeDetail.tsx b/src/mother/notice/presentation/components/organisms/NoticeDetail.tsx index 22bf8e9..5e4aa2e 100644 --- a/src/mother/notice/presentation/components/organisms/NoticeDetail.tsx +++ b/src/mother/notice/presentation/components/organisms/NoticeDetail.tsx @@ -7,11 +7,10 @@ import ImmutableTextField from 'src/common/presentation/components/atmos/Immutab import MarkdownPreview from 'src/common/presentation/components/atmos/previews/MarkdownPreview'; import ErrorTypography from 'src/common/presentation/components/atmos/typographies/ErrorTypography'; import MySpeedDial, { SpeedDialActionData } from 'src/common/presentation/components/molecules/MySpeedDial'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import Notice from 'src/mother/notice/domain/Notice'; import { createLinkClickHandler } from 'src/util/createLinkClickHandler'; - const useStyles = makeStyles((theme: Theme) => createStyles({ spacing: { height: theme.spacing(1) }, semiTransparent: { @@ -28,7 +27,6 @@ const useStyles = makeStyles((theme: Theme) => createStyles({ } })) - interface Props { notice: Notice pending: boolean @@ -37,7 +35,7 @@ interface Props { deleteNotice(): void } -const { useTranslation } = inversifyServices.common.i18NService; +const { useTranslation } = I18NService; const NoticeDetail: React.FC = ({ notice, pending, rejected, deleteNotice }) => { const classes = useStyles(); diff --git a/src/mother/notice/presentation/components/organisms/NoticeList.tsx b/src/mother/notice/presentation/components/organisms/NoticeList.tsx index 65c7ec4..e0270dd 100644 --- a/src/mother/notice/presentation/components/organisms/NoticeList.tsx +++ b/src/mother/notice/presentation/components/organisms/NoticeList.tsx @@ -5,7 +5,7 @@ import MyTable from "src/common/presentation/components/atmos/MyTable"; import Spacer from 'src/common/presentation/components/atmos/Spacer'; import ErrorTypography from 'src/common/presentation/components/atmos/typographies/ErrorTypography'; import MySpeedDial, { SpeedDialActionData } from 'src/common/presentation/components/molecules/MySpeedDial'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import Notice from 'src/mother/notice/domain/Notice'; import { createLinkClickHandler } from 'src/util/createLinkClickHandler'; @@ -15,7 +15,7 @@ interface Props { rejected: boolean } -const { useTranslation } = inversifyServices.common.i18NService; +const { useTranslation } = I18NService; const onRowClick = (e?: React.MouseEvent, data?: Notice) => { if (!e || !data) { diff --git a/src/mother/notice/presentation/components/templates/NoticeForm/NoticeForm.tsx b/src/mother/notice/presentation/components/templates/NoticeForm/NoticeForm.tsx index 9d4a982..86bbf91 100644 --- a/src/mother/notice/presentation/components/templates/NoticeForm/NoticeForm.tsx +++ b/src/mother/notice/presentation/components/templates/NoticeForm/NoticeForm.tsx @@ -10,7 +10,7 @@ import Spacer from 'src/common/presentation/components/atmos/Spacer'; import ErrorTypography from 'src/common/presentation/components/atmos/typographies/ErrorTypography'; import MySpeedDial, { SpeedDialActionData } from 'src/common/presentation/components/molecules/MySpeedDial'; import MarkdownEditor from 'src/common/presentation/components/organisms/MarkdownEditor'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import NoticeFormDto from 'src/mother/notice/api/dto/NoticeFormDto'; const useStyles = makeStyles((theme: Theme) => createStyles({ @@ -35,7 +35,7 @@ interface Props { rejected: boolean } -const { useTranslation } = inversifyServices.common.i18NService; +const { useTranslation } = I18NService; const NoticeForm: React.FC & Props> = ({ handleSubmit, diff --git a/src/mother/notice/presentation/containers/NoticeDetailContainer.tsx b/src/mother/notice/presentation/containers/NoticeDetailContainer.tsx index a8e9b73..37db254 100644 --- a/src/mother/notice/presentation/containers/NoticeDetailContainer.tsx +++ b/src/mother/notice/presentation/containers/NoticeDetailContainer.tsx @@ -4,7 +4,7 @@ import { bindActionCreators, Dispatch } from 'redux'; import Id from 'src/common/domain/Id'; import * as commonModule from "src/common/presentation/state-module/common" import { RootState } from 'src/common/presentation/state-module/root'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import Notice from '../../domain/Notice'; import NoticeDetail from '../components/organisms/NoticeDetail'; import * as detailModule from "../state-module/detail" @@ -20,7 +20,7 @@ interface Props { commonDispatchers: typeof commonModule } -const { useTranslation } = inversifyServices.common.i18NService; +const { useTranslation } = I18NService; const NoticeDetailContainer: React.FC = ({ id, notice, pending, rejected, dispatchers, commonDispatchers }) => { React.useEffect(() => { diff --git a/src/mother/notice/presentation/containers/NoticeFormContainer.tsx b/src/mother/notice/presentation/containers/NoticeFormContainer.tsx index 440d015..f4ad363 100644 --- a/src/mother/notice/presentation/containers/NoticeFormContainer.tsx +++ b/src/mother/notice/presentation/containers/NoticeFormContainer.tsx @@ -4,7 +4,7 @@ import { bindActionCreators, Dispatch } from 'redux'; import Id from 'src/common/domain/Id'; import * as commonModule from "src/common/presentation/state-module/common" import { RootState } from 'src/common/presentation/state-module/root'; -import inversifyServices from 'src/inversifyServices'; +import I18NService from 'src/common/service/I18NService'; import NoticeFormDto from '../../api/dto/NoticeFormDto'; import NoticeForm from '../components/templates/NoticeForm'; import * as formModule from "../state-module/form"; @@ -21,7 +21,7 @@ interface Props { commonDispatchers: typeof commonModule } -const { useTranslation } = inversifyServices.common.i18NService; +const { useTranslation } = I18NService; const NoticeFormContainer: React.FC = ({ id, isEditing, diff --git a/src/mother/notice/presentation/state-module/detail.ts b/src/mother/notice/presentation/state-module/detail.ts index cc86613..1d4d6f5 100644 --- a/src/mother/notice/presentation/state-module/detail.ts +++ b/src/mother/notice/presentation/state-module/detail.ts @@ -3,10 +3,10 @@ import Router from 'next/router'; import { call, put, takeLatest } from "redux-saga/effects"; import Id from 'src/common/domain/Id'; import { enqueueSnackbar } from 'src/common/presentation/state-module/snackbar'; -import inversifyServices from "src/inversifyServices"; import stringify from 'src/util/stringify'; import { ActionType, createAsyncAction, createReducer, createStandardAction, getType } from "typesafe-actions"; import Notice from "../../domain/Notice"; +import NoticeServiceImpl from '../../infrastructure/service/NoticeServiceImpl'; export const reset = createStandardAction("@noticeDetail/RESET")(); @@ -87,12 +87,11 @@ export function* saga() { yield takeLatest(getType(deleteNotice), sagaDeleteNotice); } -const noticeService = inversifyServices.mother.notice.service function* sagaFetchNotice(action: ActionType): Generator { yield put(fetchNoticeAsync.request()) const { id } = action.payload try { - const notice: Notice = yield call(noticeService.getNotice, id); + const notice: Notice = yield call(NoticeServiceImpl.getNotice, id); yield put(fetchNoticeAsync.success({ notice })); } catch (e) { yield put(fetchNoticeAsync.failure()); @@ -110,7 +109,7 @@ function* sagaDeleteNotice(action: ActionType): Generator { yield put(deleteNoticeAsync.request()) const { id } = action.payload try { - yield call(noticeService.deleteNotice, id); + yield call(NoticeServiceImpl.deleteNotice, id); yield put(deleteNoticeAsync.success()); yield put(enqueueSnackbar({ snackbar: { diff --git a/src/mother/notice/presentation/state-module/form.ts b/src/mother/notice/presentation/state-module/form.ts index 0da7c85..7cda9b2 100644 --- a/src/mother/notice/presentation/state-module/form.ts +++ b/src/mother/notice/presentation/state-module/form.ts @@ -5,12 +5,12 @@ import Router from 'next/router'; import { call, put, takeLatest } from "redux-saga/effects"; import Id from 'src/common/domain/Id'; import { enqueueSnackbar } from 'src/common/presentation/state-module/snackbar'; -import inversifyServices from "src/inversifyServices"; import stringify from 'src/util/stringify'; import { ActionType, createAsyncAction, createReducer, createStandardAction, getType } from "typesafe-actions"; import NoticeFormDto from '../../api/dto/NoticeFormDto'; import NoticeRequestDto from '../../api/dto/NoticeRequestDto'; import Notice from "../../domain/Notice"; +import NoticeServiceImpl from '../../infrastructure/service/NoticeServiceImpl'; export const reset = createStandardAction("@noticeForm/RESET")(); export const setPendingFalse = createStandardAction("@noticeForm/SET_PENDING_FALSE")(); @@ -123,12 +123,11 @@ export function* saga() { yield takeLatest(getType(putNotice), sagaPutNotice); } -const noticeService = inversifyServices.mother.notice.service function* sagaFetchInitialNotice(action: ActionType): Generator { yield put(fetchInitialNoticeAsync.request()) const { id } = action.payload try { - const notice: Notice = yield call(noticeService.getNotice, id); + const notice: Notice = yield call(NoticeServiceImpl.getNotice, id); const initialNoticeFormDto = yield call(NoticeFormDto.of, notice); yield put(fetchInitialNoticeAsync.success({ initialNoticeFormDto })); } catch (e) { @@ -147,7 +146,7 @@ function* sagaPostNotice(action: ActionType): Generator { const { noticeFormDto } = action.payload; try { const noticeRequestDto = NoticeRequestDto.of(noticeFormDto); - const id: Id = yield call(noticeService.postNotice, noticeRequestDto); + const id: Id = yield call(NoticeServiceImpl.postNotice, noticeRequestDto); yield put(postNoticeAsync.success()); yield put(enqueueSnackbar({ @@ -174,7 +173,7 @@ function* sagaPutNotice(action: ActionType): Generator { const { id, noticeFormDto } = action.payload; try { const noticeRequestDto = NoticeRequestDto.of(noticeFormDto); - yield call(noticeService.putNotice, id, noticeRequestDto); + yield call(NoticeServiceImpl.putNotice, id, noticeRequestDto); yield put(postNoticeAsync.success()); yield put(enqueueSnackbar({ diff --git a/src/mother/notice/presentation/state-module/list.ts b/src/mother/notice/presentation/state-module/list.ts index f06697a..91646fe 100644 --- a/src/mother/notice/presentation/state-module/list.ts +++ b/src/mother/notice/presentation/state-module/list.ts @@ -2,10 +2,10 @@ import { produce } from 'immer' import { call, put, takeLatest } from "redux-saga/effects"; import Page from 'src/common/domain/Page'; import { enqueueSnackbar } from 'src/common/presentation/state-module/snackbar'; -import inversifyServices from "src/inversifyServices"; import stringify from 'src/util/stringify'; import { ActionType, createAsyncAction, createReducer, createStandardAction, getType } from "typesafe-actions"; import Notice from "../../domain/Notice"; +import NoticeServiceImpl from '../../infrastructure/service/NoticeServiceImpl'; export const reset = createStandardAction("@noticeList/RESET")(); @@ -58,11 +58,10 @@ export function* saga() { yield takeLatest(getType(fetchNoticePage), sagaFetchNotice); } -const noticeService = inversifyServices.mother.notice.service function* sagaFetchNotice(): Generator { yield put(fetchNoticePageAsync.request()) try { - const page: Page = yield call(noticeService.getNoticePage, { page: 1, size: 1 << 31 - 1 }); + const page: Page = yield call(NoticeServiceImpl.getNoticePage, { page: 1, size: 1 << 31 - 1 }); yield put(fetchNoticePageAsync.success({ page })); } catch (e) { yield put(fetchNoticePageAsync.failure());