From e96020915743c240f027829ae96fe1137b30a488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kimjh=28=EA=B9=80=EC=9E=A5=ED=98=84=29?= Date: Wed, 19 Oct 2022 14:13:32 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=20reducer=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/mypage/AccountMypageContainer.js | 12 +++++----- .../account/login/actions/authAction.ts | 2 +- src/modules/account/login/models/authModel.ts | 6 +++-- .../account/login/reducers/authReducer.ts | 22 ++++++++++--------- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/containers/account/mypage/AccountMypageContainer.js b/src/containers/account/mypage/AccountMypageContainer.js index 712a13cc..630573aa 100644 --- a/src/containers/account/mypage/AccountMypageContainer.js +++ b/src/containers/account/mypage/AccountMypageContainer.js @@ -43,12 +43,14 @@ import { ConfirmModal } from '../../../components/modal/ConfirmModal'; // ** Function to toggle tabs const AccountMypageContainer = () => { - const [activeTab, setActiveTab] = useState('1'), - store = useSelector(state => state.users), - dispatch = useDispatch(), - { id } = useParams(); + const [activeTab, setActiveTab] = useState('1'); + const dispatch = useDispatch(); + // { id } = useParams(); - const toggle = tab => setActiveTab(tab); + const toggle = tab => { + console.log(tab); + return setActiveTab(tab); + }; const [formModal, setFormModal] = useState(false); const { userPage } = useSelector(state => state.UserPageState); const { user } = useSelector(state => state.authState); diff --git a/src/modules/account/login/actions/authAction.ts b/src/modules/account/login/actions/authAction.ts index 1804c84d..ff99f633 100644 --- a/src/modules/account/login/actions/authAction.ts +++ b/src/modules/account/login/actions/authAction.ts @@ -97,7 +97,7 @@ export const pwCheckAction = createAsyncAction( USERS_PWCheck_REQUEST, USERS_PWCheck_SUCCESS, USERS_PWCheck_FAILURE -)(); +)(); const actions = { login, diff --git a/src/modules/account/login/models/authModel.ts b/src/modules/account/login/models/authModel.ts index 5f354c14..66dcd014 100644 --- a/src/modules/account/login/models/authModel.ts +++ b/src/modules/account/login/models/authModel.ts @@ -60,7 +60,8 @@ export interface UserData { } export interface UserPageState { - userPage: UserPageData | undefined; + userPage?: UserPageData | undefined; + result: boolean | undefined; } export interface UserPageData { memberName: string; @@ -97,5 +98,6 @@ export const initResponseUserPwPageData = { }; export const initResponseUserPageData = { - userPage: undefined + userPage: undefined, + result: undefined }; diff --git a/src/modules/account/login/reducers/authReducer.ts b/src/modules/account/login/reducers/authReducer.ts index 4f368a37..d47fdcb8 100644 --- a/src/modules/account/login/reducers/authReducer.ts +++ b/src/modules/account/login/reducers/authReducer.ts @@ -96,21 +96,23 @@ export const authReducer = createReducer(initialState) draft.isLogin = false; draft.user = undefined; }) + ); + +export const mypageReducer = createReducer( + initResponseUserPageData +) + .handleAction(userPageAction.success, (state, action) => + produce(state, draft => { + const data: UserPageData = action.payload; + draft.userPage = data; + }) ) .handleAction(pwCheckAction.success, (state, action) => produce(state, draft => { - const data: UserPwCheck = action.payload; - draft.UserPwCheck = data; + const data = action.payload; + draft.result = data; }) ); -export const mypageReducer = createReducer( - initResponseUserPageData -).handleAction(userPageAction.success, (state, action) => - produce(state, draft => { - const data: UserPageData = action.payload; - draft.userPage = data; - }) -); export const userPwReducer = createReducer( initResponseUserPwPageData ).handleAction(pwUpdateAction.success, (state, action) =>