From f36bb5efa67a731a5d1d67954f67d06b0846917b 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 16:25:49 +0900 Subject: [PATCH] =?UTF-8?q?[Redux]=20/account/find=20=EB=AF=B8=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F?= =?UTF-8?q?=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 | 3 +- .../account/find/AccountFindUserId.js | 3 +- .../find/actions/{findAction.ts => index.ts} | 19 ++++--- src/modules/account/find/apis/findApi.ts | 21 ------- src/modules/account/find/apis/index.ts | 31 +++++++++++ src/modules/account/find/index.ts | 8 +-- src/modules/account/find/models/findModel.ts | 19 ------- .../account/find/reducers/findReducer.ts | 55 ------------------- src/modules/account/find/reducers/index.ts | 55 +++++++++++++++++++ .../find/sagas/{findSaga.ts => index.ts} | 37 ++++++------- src/modules/basis/dron/index.ts | 1 + src/modules/basis/group/index.ts | 1 + 12 files changed, 123 insertions(+), 130 deletions(-) rename src/modules/account/find/actions/{findAction.ts => index.ts} (68%) delete mode 100644 src/modules/account/find/apis/findApi.ts create mode 100644 src/modules/account/find/apis/index.ts delete mode 100644 src/modules/account/find/models/findModel.ts delete mode 100644 src/modules/account/find/reducers/findReducer.ts create mode 100644 src/modules/account/find/reducers/index.ts rename src/modules/account/find/sagas/{findSaga.ts => index.ts} (72%) diff --git a/src/components/account/find/AccountFindPassword.js b/src/components/account/find/AccountFindPassword.js index d236f4b1..1a991325 100644 --- a/src/components/account/find/AccountFindPassword.js +++ b/src/components/account/find/AccountFindPassword.js @@ -16,9 +16,8 @@ import { } from 'reactstrap'; import { User, Lock } from 'react-feather'; import '../../../assets/css/custom.css'; -import { findAPI } from '../../../modules/account/find/apis/findApi'; import { accountApi } from '../../../modules/account/register/apis/accountApi'; -import { updatePwAction } from '../../../modules/account/find/actions/findAction'; +import { findAPI, updatePwAction } from '../../../modules/account/find'; export const AccountFindPassword = props => { const dispatch = useDispatch(); diff --git a/src/components/account/find/AccountFindUserId.js b/src/components/account/find/AccountFindUserId.js index 2ed14772..31085016 100644 --- a/src/components/account/find/AccountFindUserId.js +++ b/src/components/account/find/AccountFindUserId.js @@ -17,9 +17,8 @@ import { import { User } from 'react-feather'; import '../../../assets/css/custom.css'; -import { findUserIdAction } from '../../../modules/account/find/actions/findAction'; import { accountApi } from '../../../modules/account/register/apis/accountApi'; -import { findAPI } from '../../../modules/account/find/apis/findApi'; +import { findAPI, findUserIdAction } from '../../../modules/account/find'; export const AccountFindUserId = props => { const dispatch = useDispatch(); diff --git a/src/modules/account/find/actions/findAction.ts b/src/modules/account/find/actions/index.ts similarity index 68% rename from src/modules/account/find/actions/findAction.ts rename to src/modules/account/find/actions/index.ts index 230cf8ba..f0377c49 100644 --- a/src/modules/account/find/actions/findAction.ts +++ b/src/modules/account/find/actions/index.ts @@ -1,46 +1,49 @@ import { AxiosError } from 'axios'; -import { string } from 'prop-types'; import { ActionType, createAsyncAction } from 'typesafe-actions'; +// 아이디 찾기 인증번호 발송 const SEND_FORID_REQUEST = 'find/SEND_FORID_REQUEST'; const SEND_FORID_SUCCESS = 'find/SEND_FORID_SUCCESS'; const SEND_FORID_FAILURE = 'find/SEND_FORID_FAILURE'; +// 아이디 찾기 const FIND_USERID_REQUEST = 'find/FIND_USERID_REQUEST'; const FIND_USERID_SUCCESS = 'find/FIND_USERID_SUCCESS'; const FIND_USERID_FAILURE = 'find/FIND_USERID_FAILURE'; +// 비밀번호 찾기 인증번호 발송 const SEND_FORPW_REQUEST = 'find/SEND_FORPW_REQUEST'; const SEND_FORPW_SUCCESS = 'find/SEND_FORPW_SUCCESS'; const SEND_FORPW_FAILURE = 'find/SEND_FORPW_FAILURE'; -const UPDATE_USERPW_REQUEST = 'find/UPDATE_USERPW_REQUEST' -const UPDATE_USERPW_SUCCESS = 'find/UPDATE_USERPW_SUCCESS' -const UPDATE_USERPW_FAILURE = 'find/UPDATE_USERPW_FAILURE' +// 비밀번호 변경 +const UPDATE_USERPW_REQUEST = 'find/UPDATE_USERPW_REQUEST'; +const UPDATE_USERPW_SUCCESS = 'find/UPDATE_USERPW_SUCCESS'; +const UPDATE_USERPW_FAILURE = 'find/UPDATE_USERPW_FAILURE'; export const sendForIdAction = createAsyncAction( SEND_FORID_REQUEST, SEND_FORID_SUCCESS, SEND_FORID_FAILURE -)<{memberName: string, hpno: string}, string, AxiosError>(); +)<{ memberName: string; hpno: string }, string, AxiosError>(); export const findUserIdAction = createAsyncAction( FIND_USERID_REQUEST, FIND_USERID_SUCCESS, FIND_USERID_FAILURE -)<{memberName: string, hpno: string}, string, AxiosError>(); +)<{ memberName: string; hpno: string }, string, AxiosError>(); export const sendForPwAction = createAsyncAction( SEND_FORPW_REQUEST, SEND_FORPW_SUCCESS, SEND_FORPW_FAILURE -)<{userId: string, hpno: string}, string, AxiosError>(); +)<{ userId: string; hpno: string }, string, AxiosError>(); export const updatePwAction = createAsyncAction( UPDATE_USERPW_REQUEST, UPDATE_USERPW_SUCCESS, UPDATE_USERPW_FAILURE -)<{userId: string, hpno: string, newPw: string}, string, AxiosError>(); +)<{ userId: string; hpno: string; newPw: string }, string, AxiosError>(); const actions = { sendForIdAction, diff --git a/src/modules/account/find/apis/findApi.ts b/src/modules/account/find/apis/findApi.ts deleted file mode 100644 index bf765121..00000000 --- a/src/modules/account/find/apis/findApi.ts +++ /dev/null @@ -1,21 +0,0 @@ -import axios from '../../../utils/customAxiosUtil'; - -import qs from 'qs'; - -export const findAPI = { - sendForId: async(param) => { - return await axios.get(`api/acnt/crtfyhp/find/sendForId?memberName=${param.memberName}&hpno=${param.hpno}`); - }, - - getUserId: async(param) => { - return await axios.get(`api/acnt/crtfyhp/find/findUserId?memberName=${param.memberName}&hpno=${param.hpno}`); - }, - - sendForPw: async(param) => { - return await axios.get(`api/acnt/crtfyhp/find/sendForPw?userId=${param.userId}&hpno=${param.hpno}`); - }, - - updatePw: async(param) => { - return await axios.get(`api/acnt/crtfyhp/find/updatePw?userId=${param.userId}&hpno=${param.hpno}&newPw=${param.newPw}`); - } -} \ No newline at end of file diff --git a/src/modules/account/find/apis/index.ts b/src/modules/account/find/apis/index.ts new file mode 100644 index 00000000..7d4c9983 --- /dev/null +++ b/src/modules/account/find/apis/index.ts @@ -0,0 +1,31 @@ +import axios from '../../../utils/customAxiosUtil'; + +export const findAPI = { + // 아이디 찾기 인증번호 발송 + sendForId: async param => { + return await axios.get( + `api/acnt/crtfyhp/find/sendForId?memberName=${param.memberName}&hpno=${param.hpno}` + ); + }, + + // 아이디 찾기 + getUserId: async param => { + return await axios.get( + `api/acnt/crtfyhp/find/findUserId?memberName=${param.memberName}&hpno=${param.hpno}` + ); + }, + + // 비밀번호 찾기 인증번호 발송 + sendForPw: async param => { + return await axios.get( + `api/acnt/crtfyhp/find/sendForPw?userId=${param.userId}&hpno=${param.hpno}` + ); + }, + + // 비밀번호 변경 + updatePw: async param => { + return await axios.get( + `api/acnt/crtfyhp/find/updatePw?userId=${param.userId}&hpno=${param.hpno}&newPw=${param.newPw}` + ); + } +}; diff --git a/src/modules/account/find/index.ts b/src/modules/account/find/index.ts index 4bd4ad00..4a5ed5b2 100644 --- a/src/modules/account/find/index.ts +++ b/src/modules/account/find/index.ts @@ -1,4 +1,4 @@ -export * from './actions/findAction'; -export * from './models/findModel'; -export * from './reducers/findReducer'; -export * from './sagas/findSaga'; +export * from './actions'; +export * from './apis'; +export * from './reducers'; +export * from './sagas'; diff --git a/src/modules/account/find/models/findModel.ts b/src/modules/account/find/models/findModel.ts deleted file mode 100644 index 2086628a..00000000 --- a/src/modules/account/find/models/findModel.ts +++ /dev/null @@ -1,19 +0,0 @@ -export interface AccountFindState { - accountFind: AccountFindData | undefined; -} -export interface AccountFindData { - cstmrSno: number; - userId: string; - memberName: string; - hpno: string; - cntfyhpNo: string; - crtfyhpYn: string; -} - -export interface IsCntfyhpSend { - -} - -export const initResponseFindData = { - accountFind: undefined -} diff --git a/src/modules/account/find/reducers/findReducer.ts b/src/modules/account/find/reducers/findReducer.ts deleted file mode 100644 index 37c17b83..00000000 --- a/src/modules/account/find/reducers/findReducer.ts +++ /dev/null @@ -1,55 +0,0 @@ -// base -import produce from 'immer'; - -import { createReducer } from 'typesafe-actions'; - -// action -import { - FindAction, - findUserIdAction, - sendForIdAction, - sendForPwAction, - updatePwAction -} from '../actions/findAction'; - -// -export interface findState { - idResult: string | undefined; - userId: string | undefined; - pwResult: string | undefined; - udResult: string | undefined; -} -const initFindState : findState = { - idResult: undefined, - userId: undefined, - pwResult: undefined, - udResult: undefined -} - -export const findAccountReducer = createReducer( - initFindState -).handleAction(sendForIdAction.success, (state, action) => - produce(state, draft => { - const data = action.payload; - - draft.idResult = data; - }) -).handleAction(findUserIdAction.success, (state, action) => - produce(state, draft => { - const data = action.payload; - - draft.userId = data; - }) -).handleAction(sendForPwAction.success, (state, action) => - produce(state, draft => { - const data = action.payload; - - draft.pwResult = data; - }) -).handleAction(updatePwAction.success, (state, action) => - produce(state, draft => { - const data = action.payload; - - draft.udResult = data; - }) -) \ No newline at end of file diff --git a/src/modules/account/find/reducers/index.ts b/src/modules/account/find/reducers/index.ts new file mode 100644 index 00000000..0a85fb5d --- /dev/null +++ b/src/modules/account/find/reducers/index.ts @@ -0,0 +1,55 @@ +// base +import produce from 'immer'; + +import { createReducer } from 'typesafe-actions'; + +// action +import { + FindAction, + findUserIdAction, + sendForIdAction, + sendForPwAction, + updatePwAction +} from '../actions'; + +// +export interface findState { + idResult: string | undefined; + userId: string | undefined; + pwResult: string | undefined; + udResult: string | undefined; +} +const initFindState: findState = { + idResult: undefined, + userId: undefined, + pwResult: undefined, + udResult: undefined +}; + +export const findAccountReducer = createReducer( + initFindState +) + .handleAction(sendForIdAction.success, (state, action) => + produce(state, draft => { + const data = action.payload; + draft.idResult = data; + }) + ) + .handleAction(findUserIdAction.success, (state, action) => + produce(state, draft => { + const data = action.payload; + draft.userId = data; + }) + ) + .handleAction(sendForPwAction.success, (state, action) => + produce(state, draft => { + const data = action.payload; + draft.pwResult = data; + }) + ) + .handleAction(updatePwAction.success, (state, action) => + produce(state, draft => { + const data = action.payload; + draft.udResult = data; + }) + ); diff --git a/src/modules/account/find/sagas/findSaga.ts b/src/modules/account/find/sagas/index.ts similarity index 72% rename from src/modules/account/find/sagas/findSaga.ts rename to src/modules/account/find/sagas/index.ts index 23535ed8..e9b7c991 100644 --- a/src/modules/account/find/sagas/findSaga.ts +++ b/src/modules/account/find/sagas/index.ts @@ -2,19 +2,18 @@ import { call, put, takeEvery } from 'redux-saga/effects'; // packages import { ActionType } from 'typesafe-actions'; // modules -import * as Actions from '../actions/findAction'; -import { findAPI } from '../apis/findApi'; - +import * as Actions from '../actions'; +import { findAPI } from '../apis'; function* sendForIdSaga( action: ActionType ) { - try{ - const {memberName, hpno} = action.payload; - + try { + const { memberName, hpno } = action.payload; + const res = yield call(findAPI.sendForId, { memberName, hpno }); yield put(Actions.sendForIdAction.success(res)); - } catch (error) { + } catch (error: any) { yield put(Actions.sendForIdAction.failure(error)); } } @@ -22,12 +21,12 @@ function* sendForIdSaga( function* findUserIdSaga( action: ActionType ) { - try{ - const {memberName, hpno} = action.payload; + try { + const { memberName, hpno } = action.payload; const res = yield call(findAPI.getUserId, { memberName, hpno }); yield put(Actions.findUserIdAction.success(res)); - } catch (error) { + } catch (error: any) { yield put(Actions.findUserIdAction.failure(error)); } } @@ -35,12 +34,12 @@ function* findUserIdSaga( function* sendForPwSaga( action: ActionType ) { - try{ - const {userId, hpno} = action.payload; + try { + const { userId, hpno } = action.payload; - const res = yield call(findAPI.sendForPw, {userId, hpno}); + const res = yield call(findAPI.sendForPw, { userId, hpno }); yield put(Actions.sendForPwAction.success(res)); - } catch (error) { + } catch (error: any) { yield put(Actions.sendForPwAction.failure(error)); } } @@ -48,12 +47,12 @@ function* sendForPwSaga( function* updatePwSaga( action: ActionType ) { - try{ - const {userId, hpno, newPw} = action.payload; + try { + const { userId, hpno, newPw } = action.payload; - const res = yield call(findAPI.updatePw, {userId, hpno, newPw}); + const res = yield call(findAPI.updatePw, { userId, hpno, newPw }); yield put(Actions.updatePwAction.success(res)); - } catch (error) { + } catch (error: any) { yield put(Actions.updatePwAction.failure(error)); } } @@ -63,4 +62,4 @@ export function* findSaga() { yield takeEvery(Actions.findUserIdAction.request, findUserIdSaga); yield takeEvery(Actions.sendForPwAction.request, sendForPwSaga); yield takeEvery(Actions.updatePwAction.request, updatePwSaga); -} \ No newline at end of file +} diff --git a/src/modules/basis/dron/index.ts b/src/modules/basis/dron/index.ts index 2ac0c247..1405c5a7 100644 --- a/src/modules/basis/dron/index.ts +++ b/src/modules/basis/dron/index.ts @@ -1,4 +1,5 @@ export * from './actions'; +export * from './apis'; export * from './models'; export * from './reducers'; export * from './sagas'; diff --git a/src/modules/basis/group/index.ts b/src/modules/basis/group/index.ts index 2ac0c247..1405c5a7 100644 --- a/src/modules/basis/group/index.ts +++ b/src/modules/basis/group/index.ts @@ -1,4 +1,5 @@ export * from './actions'; +export * from './apis'; export * from './models'; export * from './reducers'; export * from './sagas';