From 592f189f3ac1efc08f105f96bb3780550419bf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?junh=5Feee=28=EC=9D=B4=EC=A4=80=ED=9D=AC=29?= Date: Tue, 30 Jan 2024 19:17:56 +0900 Subject: [PATCH] =?UTF-8?q?[Redux]=20/account/register=20=EB=AF=B8?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EA=B2=BD=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/find/AccountFindPassword.js | 4 +- .../account/find/AccountFindUserId.js | 4 +- .../account/register/AccountRegisterForm.js | 8 ++-- .../account/register/AccountRegisterTerm.js | 2 +- src/components/laanc/list/LaancDetail.js | 2 +- src/components/laanc/step/LaancStep2.js | 2 +- .../account/mypage/AccountMypageContainer.js | 6 +-- .../actions/{accountAction.ts => index.ts} | 19 ++-------- .../register/apis/{accountApi.ts => index.ts} | 37 +++---------------- src/modules/account/register/index.ts | 9 +++-- .../models/{accountModel.ts => index.ts} | 10 +---- .../reducers/{accountReducer.ts => index.ts} | 18 +-------- .../sagas/{accountSaga.ts => index.ts} | 22 ++++------- 13 files changed, 40 insertions(+), 103 deletions(-) rename src/modules/account/register/actions/{accountAction.ts => index.ts} (67%) rename src/modules/account/register/apis/{accountApi.ts => index.ts} (52%) rename src/modules/account/register/models/{accountModel.ts => index.ts} (78%) rename src/modules/account/register/reducers/{accountReducer.ts => index.ts} (58%) rename src/modules/account/register/sagas/{accountSaga.ts => index.ts} (72%) diff --git a/src/components/account/find/AccountFindPassword.js b/src/components/account/find/AccountFindPassword.js index 7bfc317c..7cf7f431 100644 --- a/src/components/account/find/AccountFindPassword.js +++ b/src/components/account/find/AccountFindPassword.js @@ -16,7 +16,7 @@ import { } from '../../ui/index'; import { User, Lock } from 'react-feather'; import '../../../assets/css/custom.css'; -import { accountApi } from '../../../modules/account/register/apis/accountApi'; +import { accountAPI } from '../../../modules/account/register'; import { findAPI, updatePwAction } from '../../../modules/account/find'; export const AccountFindPassword = props => { @@ -203,7 +203,7 @@ export const AccountFindPassword = props => { return; } - const res = await accountApi.crtfyhpConfirm(inputHpno, inputCrtfy); + const res = await accountAPI.crtfyhpConfirm(inputHpno, inputCrtfy); if (!res.data.result) { setModal({ isOpen: true, diff --git a/src/components/account/find/AccountFindUserId.js b/src/components/account/find/AccountFindUserId.js index 5d84c1fb..81629834 100644 --- a/src/components/account/find/AccountFindUserId.js +++ b/src/components/account/find/AccountFindUserId.js @@ -17,7 +17,7 @@ import { import { User } from 'react-feather'; import '../../../assets/css/custom.css'; -import { accountApi } from '../../../modules/account/register/apis/accountApi'; +import { accountAPI } from '../../../modules/account/register'; import { findAPI, findUserIdAction } from '../../../modules/account/find'; export const AccountFindUserId = props => { @@ -208,7 +208,7 @@ export const AccountFindUserId = props => { return; } - const res = await accountApi.crtfyhpConfirm(inputHpno, inputCrtfy); + const res = await accountAPI.crtfyhpConfirm(inputHpno, inputCrtfy); if (!res.data.result) { setModal({ isOpen: true, diff --git a/src/components/account/register/AccountRegisterForm.js b/src/components/account/register/AccountRegisterForm.js index 70b26735..c32e6514 100644 --- a/src/components/account/register/AccountRegisterForm.js +++ b/src/components/account/register/AccountRegisterForm.js @@ -19,7 +19,7 @@ import { FormFeedback } from '../../ui/index'; import { useDispatch, useSelector } from 'react-redux'; -import { accountApi } from '../../../modules/account/register/apis/accountApi'; +import { accountAPI } from '../../../modules/account/register'; export const AccountRegisterForm = ({ stepper, @@ -110,7 +110,7 @@ export const AccountRegisterForm = ({ return; } - const res = await accountApi.crtfyhp(vData.hpno); + const res = await accountAPI.crtfyhp(vData.hpno); if (!res.data.result) { if (res.data.code === -1) { @@ -237,7 +237,7 @@ export const AccountRegisterForm = ({ // dispatch( // Actions.register.request({ data: data, agreeTerms: agreeTerms }) // ); - const res = await accountApi.register({ + const res = await accountAPI.register({ data: data, agreeTerms: agreeTerms }); @@ -286,7 +286,7 @@ export const AccountRegisterForm = ({ return false; } - const res = await accountApi.crtfyhpConfirm(vData.hpno, vData.crtfyNo); + const res = await accountAPI.crtfyhpConfirm(vData.hpno, vData.crtfyNo); if (!res.data.result) { setModal({ diff --git a/src/components/account/register/AccountRegisterTerm.js b/src/components/account/register/AccountRegisterTerm.js index 093e1588..f2399297 100644 --- a/src/components/account/register/AccountRegisterTerm.js +++ b/src/components/account/register/AccountRegisterTerm.js @@ -11,7 +11,7 @@ import { ModalFooter } from '../../ui/index'; import { useDispatch, useSelector } from 'react-redux'; -import * as Actions from '../../../modules/account/register/actions/accountAction'; +import * as Actions from '../../../modules/account/register'; export const AccountRegisterTerm = ({ stepper, type, movePage }) => { // 약관 목록 diff --git a/src/components/laanc/list/LaancDetail.js b/src/components/laanc/list/LaancDetail.js index ed8a5b66..05293730 100644 --- a/src/components/laanc/list/LaancDetail.js +++ b/src/components/laanc/list/LaancDetail.js @@ -12,7 +12,7 @@ import { Input } from '../../ui/index'; import FlightArea from '../map/FlightArea'; -import * as TermsActions from '../../../modules/account/register/actions/accountAction'; +import * as TermsActions from '../../../modules/account/register'; export default function LaancDetail({ data, handlerLaancClose }) { const dispatch = useDispatch(); diff --git a/src/components/laanc/step/LaancStep2.js b/src/components/laanc/step/LaancStep2.js index a8025680..342a9366 100644 --- a/src/components/laanc/step/LaancStep2.js +++ b/src/components/laanc/step/LaancStep2.js @@ -17,7 +17,7 @@ import { CustomInput } from '../../ui/index'; import * as LaancAction from '../../../modules/laanc/actions/laancActions'; -import * as TermsActions from '../../../modules/account/register/actions/accountAction'; +import * as TermsActions from '../../../modules/account/register'; const FlightArea = lazy(() => import('../map/FlightArea')); diff --git a/src/containers/account/mypage/AccountMypageContainer.js b/src/containers/account/mypage/AccountMypageContainer.js index e226117d..732deb89 100644 --- a/src/containers/account/mypage/AccountMypageContainer.js +++ b/src/containers/account/mypage/AccountMypageContainer.js @@ -15,7 +15,7 @@ import { ModalBody, ModalFooter } from 'reactstrap'; -import { accountApi } from '../../../modules/account/register/apis/accountApi'; +import { accountAPI } from '../../../modules/account/register'; import AccountMypagePwForm from '../../../components/account/mypage/AccountMypagePwForm'; import AccountMypageForm from '../../../components/account/mypage/AccountMypageForm'; import { @@ -157,7 +157,7 @@ const AccountMypageContainer = () => { return; } - const res = await accountApi.crtfyhp(inputHpno); + const res = await accountAPI.crtfyhp(inputHpno); if (!res.data.result) { if (res.data.code === -1) { @@ -233,7 +233,7 @@ const AccountMypageContainer = () => { return false; } - const res = await accountApi.crtfyhpConfirm(inputHpno, inputCrtfy); + const res = await accountAPI.crtfyhpConfirm(inputHpno, inputCrtfy); if (!res.data.result) { setModal({ diff --git a/src/modules/account/register/actions/accountAction.ts b/src/modules/account/register/actions/index.ts similarity index 67% rename from src/modules/account/register/actions/accountAction.ts rename to src/modules/account/register/actions/index.ts index c039846c..b450c822 100644 --- a/src/modules/account/register/actions/accountAction.ts +++ b/src/modules/account/register/actions/index.ts @@ -1,32 +1,21 @@ import { AxiosError } from 'axios'; import { createAsyncAction, ActionType, createAction } from 'typesafe-actions'; import { DefaultSeachModel } from '../../../models/ComnModel'; -import { - AccountData, - AccountTermsData, - AccountState, - AccountFormData, - AgreeTermsData -} from '../models/accountModel'; +import { AccountTermsData, AccountFormData, AgreeTermsData } from '../models'; +// 회원가입 const REGISTER_REQUEST = 'account/register/REGISTER_REQUEST'; const REGISTER_SUCCESS = 'account/register/REGISTER_SUCCESS'; const REGISTER_FAILURE = 'account/register/REGISTER_FAILURE'; +// 약관 체크 목록 const TERMS_DISPATCH = 'account/terms/TERMS_DISPATCH'; +// 약관 리스트 const TERMS_REQUEST = 'account/terms/TERMS_REQUEST'; const TERMS_SUCCESS = 'account/terms/TERMS_SUCCESS'; const TERMS_FAILURE = 'account/terms/TERMS_FAILURE'; -// const CRTFYHP_REQUEST = 'account/crtfyhp/CRTFYHP_REQUEST'; -// const CRTFYHP_SUCCESS = 'account/crtfyhp/CRTFYHP_SUCCESS'; -// const CRTFYHP_FAILURE = 'account/crtfyhp/CRTFYHP_FAILURE'; - -// const CRTFYHP_CONFIRM_REQUEST = 'account/crtfyhp/CRTFYHP_REQUEST'; -// const CRTFYHP_CONFIRM_SUCCESS = 'account/crtfyhp/CRTFYHP_REQUEST'; -// const CRTFYHP_CONFIRM_FAILURE = 'account/crtfyhp/CRTFYHP_REQUEST'; - export const register = createAsyncAction( REGISTER_REQUEST, REGISTER_SUCCESS, diff --git a/src/modules/account/register/apis/accountApi.ts b/src/modules/account/register/apis/index.ts similarity index 52% rename from src/modules/account/register/apis/accountApi.ts rename to src/modules/account/register/apis/index.ts index 74059521..c52c0bed 100644 --- a/src/modules/account/register/apis/accountApi.ts +++ b/src/modules/account/register/apis/index.ts @@ -1,12 +1,12 @@ import axios from '../../../utils/customAxiosUtil'; import qs from 'qs'; -import { AccountFormData, AccountState } from '../models/accountModel'; +import { AccountFormData } from '../models'; import { DefaultSeachModel } from '../../../models/ComnModel'; import { ACCOUNT } from '../../../../configs/constants'; -// import { ReponseControlGpHistory } from '../models/controlGpModel'; -export const accountApi = { +export const accountAPI = { + // 회원가입 register: async (data: AccountFormData) => { const param = { ...data.data, @@ -16,7 +16,7 @@ export const accountApi = { const res = await axios.post('api/acnt/cstmr/register', param); return res; }, - + // 약관 목록 temrsList: async (param: DefaultSeachModel) => { const queryString = qs.stringify(param, { addQueryPrefix: true, @@ -24,39 +24,14 @@ export const accountApi = { }); return await axios.get(`api/acnt/terms/list` + queryString); }, + // 인증번호 발송 crtfyhp: async (hpno: string) => { return await axios.get(`api/acnt/crtfyhp/register/send?hpno=${hpno}`); - ``; }, + // 인증번호 확인 crtfyhpConfirm: async (hpno: string, crtfyNo: string) => { return await axios.get( `api/acnt/crtfyhp/register/confirm?hpno=${hpno}&crtfyNo=${crtfyNo}` ); } - - // list: async (data: string) => { - // const queryString = qs.stringify(data, { - // addQueryPrefix: true, - // arrayFormat: 'repeat' - // }); - - // return await axios.get(`/api/anls/hstry/list` + queryString); - // }, - // detail: async (id: string) => { - // return await axios.get(`/api/anls/hstry/detail/${id}`); - // }, - - // log: async (id: string) => { - // return await axios.get(`/api/anls/hstry/log/${id}`); - // } - // getHistory: async (id: string) => { - // if (!id) { - - // return null; - // } - // const { data }: ReponseControlGpHistory = await axios.get( - // `api/ctr/cntrl/history/${id}` - // ); - // return data; - // } }; diff --git a/src/modules/account/register/index.ts b/src/modules/account/register/index.ts index a75b1cad..1405c5a7 100644 --- a/src/modules/account/register/index.ts +++ b/src/modules/account/register/index.ts @@ -1,4 +1,5 @@ -export * from './actions/accountAction'; -export * from './models/accountModel'; -export * from './reducers/accountReducer'; -export * from './sagas/accountSaga'; +export * from './actions'; +export * from './apis'; +export * from './models'; +export * from './reducers'; +export * from './sagas'; diff --git a/src/modules/account/register/models/accountModel.ts b/src/modules/account/register/models/index.ts similarity index 78% rename from src/modules/account/register/models/accountModel.ts rename to src/modules/account/register/models/index.ts index 600be9a8..b30b8e85 100644 --- a/src/modules/account/register/models/accountModel.ts +++ b/src/modules/account/register/models/index.ts @@ -1,11 +1,3 @@ -// export interface AccountListState { -// data: AnalysisHistoryData[] | undefined; -// detail: AnalysisHistoryData | undefined; -// log: AnalysisHistoryLogData[] | undefined; -// count: number | 0; -// params: string; -// } - export interface AccountState { data: AccountData | undefined; agreeTerms: AgreeTermsData[] | undefined; @@ -54,7 +46,7 @@ export interface AccountTermsData { simpleCn: string; } -export const initResponseAccountData = { +export const initResponseAccountData: AccountState = { data: undefined, agreeTerms: undefined, termsList: undefined, diff --git a/src/modules/account/register/reducers/accountReducer.ts b/src/modules/account/register/reducers/index.ts similarity index 58% rename from src/modules/account/register/reducers/accountReducer.ts rename to src/modules/account/register/reducers/index.ts index 49bf3d47..018fb848 100644 --- a/src/modules/account/register/reducers/accountReducer.ts +++ b/src/modules/account/register/reducers/index.ts @@ -1,36 +1,22 @@ import { createReducer } from 'typesafe-actions'; import produce from 'immer'; -import * as Actions from '../actions/accountAction'; -import { - initResponseAccountData, - AccountData, - AccountState -} from '../models/accountModel'; +import * as Actions from '../actions'; +import { initResponseAccountData, AccountState } from '../models'; export const accountReducer = createReducer< AccountState, Actions.AccountAction >(initResponseAccountData) - // .handleAction(Actions.register.success, (state, action) => - // produce(state, draft => { - // const res = action.payload; - - // }) - // ) - .handleAction(Actions.agreeTerms, (state, action) => produce(state, draft => { const res = action.payload; draft.agreeTerms = res; - // draft.terms = res; }) ) .handleAction(Actions.termsList.success, (state, action) => produce(state, draft => { const res = action.payload; draft.termsList = res; - - // draft.terms = res; }) ); diff --git a/src/modules/account/register/sagas/accountSaga.ts b/src/modules/account/register/sagas/index.ts similarity index 72% rename from src/modules/account/register/sagas/accountSaga.ts rename to src/modules/account/register/sagas/index.ts index 28cd6d09..f0cb11f1 100644 --- a/src/modules/account/register/sagas/accountSaga.ts +++ b/src/modules/account/register/sagas/index.ts @@ -1,21 +1,15 @@ -import { - call, - put, - select, - takeEvery, - takeLatest -} from '@redux-saga/core/effects'; +import { call, put, takeEvery } from '@redux-saga/core/effects'; import { ActionType } from 'typesafe-actions'; -import * as Actions from '../actions/accountAction'; -import * as Apis from '../apis/accountApi'; -import * as Models from '../models/accountModel'; +import * as Actions from '../actions'; +import * as Apis from '../apis'; +import * as Models from '../models'; function* register(action: ActionType) { try { const { data, agreeTerms } = action.payload; - const res = yield call(Apis.accountApi.register, { data, agreeTerms }); + const res = yield call(Apis.accountAPI.register, { data, agreeTerms }); const resData = res.data; @@ -24,7 +18,7 @@ function* register(action: ActionType) { } else { yield put(Actions.register.failure(resData)); } - } catch (error) { + } catch (error: any) { yield put(Actions.register.failure(error)); // yield put(Actions.createNoticeAction.failure(error)); } @@ -34,7 +28,7 @@ function* temrsList(action: ActionType) { try { const { langDivCd, siteCd, termsCtgryCd } = action.payload; - const res = yield call(Apis.accountApi.temrsList, { + const res = yield call(Apis.accountAPI.temrsList, { langDivCd, siteCd, termsCtgryCd @@ -43,7 +37,7 @@ function* temrsList(action: ActionType) { const resData: Models.AccountTermsData[] = res.data; yield put(Actions.termsList.success(resData)); - } catch (error) { + } catch (error: any) { yield put(Actions.termsList.failure(error)); // yield put(Actions.createNoticeAction.failure(error)); }