From e252d85738beba85e8c407b3b3547f04912e3a3c Mon Sep 17 00:00:00 2001
From: rktguswjd <010_cm@naver.com>
Date: Sat, 26 Jun 2021 18:07:38 +0900
Subject: [PATCH 1/5] =?UTF-8?q?[feat]=20nicknameSuccess=20hook=20=EC=B6=94?=
=?UTF-8?q?=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/hooks/useUser.js | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/hooks/useUser.js b/src/hooks/useUser.js
index 262a1883..8c53ca1f 100644
--- a/src/hooks/useUser.js
+++ b/src/hooks/useUser.js
@@ -27,6 +27,7 @@ const useUser = () => {
isStop,
tabTestsLoading,
profileUrl,
+ nickname,
} = useSelector((state) => state.user);
const { data, status } = useSelector((state) => state.user.user);
const logInLoading = useMemo(
@@ -38,6 +39,11 @@ const useUser = () => {
[data, status]
); // 로그인 상태
+ const nicknameSuccess = useMemo(
+ () => [SUCCESS].includes(nickname.status),
+ [nickname.status]
+ );
+
const dispatch = useDispatch();
const checkLogIn = () => dispatch(checkLogInAction());
@@ -84,6 +90,7 @@ const useUser = () => {
putNickname,
uploadImg,
profileUrl,
+ nicknameSuccess,
};
};
From f7eb0fdd253a2892cdd18a99a8123b514013f71f Mon Sep 17 00:00:00 2001
From: rktguswjd <010_cm@naver.com>
Date: Sat, 26 Jun 2021 18:08:26 +0900
Subject: [PATCH 2/5] =?UTF-8?q?[feat]=20nickname=EA=B4=80=EB=A0=A8=20state?=
=?UTF-8?q?=20reducerUtils=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
---
src/redux/reducer/userReducer.js | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/redux/reducer/userReducer.js b/src/redux/reducer/userReducer.js
index 77f3f0f6..99b16767 100644
--- a/src/redux/reducer/userReducer.js
+++ b/src/redux/reducer/userReducer.js
@@ -29,8 +29,7 @@ const initialState = {
profileError: false,
// 닉네임 변경
- nicknameLoading: false,
- nicknameError: false,
+ nickname: reducerUtils.init(),
};
const user = createSlice({
@@ -149,7 +148,6 @@ const user = createSlice({
state.uploadLoading = true;
},
uploadProfileSuccess: (state, { payload: { url } }) => {
- console.log(url);
state.uploadLoading = false;
state.profileUrl = url;
},
@@ -172,14 +170,13 @@ const user = createSlice({
// 닉네임 변경
updateNickname: (state) => {
- state.nicknameLoading = true;
+ state.nickname = reducerUtils.loading();
},
updateNicknameSuccess: (state) => {
- state.nicknameLoading = false;
+ state.nickname = reducerUtils.success();
},
updateNicknameError: (state) => {
- state.nicknameLoading = false;
- state.nicknameError = true;
+ state.nickname = reducerUtils.error();
},
},
From a95ffd6e5d2b0b94778316d5f7fb382f3569146c Mon Sep 17 00:00:00 2001
From: rktguswjd <010_cm@naver.com>
Date: Sat, 26 Jun 2021 18:09:43 +0900
Subject: [PATCH 3/5] =?UTF-8?q?[feat]=20updateNicknameSaga=20success?=
=?UTF-8?q?=ED=9B=84=20userInfo=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/redux/saga/userSaga.js | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/redux/saga/userSaga.js b/src/redux/saga/userSaga.js
index 835a576f..fe2a4046 100644
--- a/src/redux/saga/userSaga.js
+++ b/src/redux/saga/userSaga.js
@@ -74,10 +74,21 @@ const updateProfileSaga = createPromiseSaga(
UserAPI.updateProfile
);
-const updateNicknameSaga = createPromiseSaga(
- updateNickname.type,
- UserAPI.updateNickname
-);
+function* updateNicknameSaga(action) {
+ const { status } = yield call(UserAPI.updateNickname, action.payload);
+ const { success, error } = createActionString(action.type);
+
+ if (status === SUCCESS) {
+ yield put({
+ type: success,
+ });
+ yield put({
+ type: getUserInfo.type,
+ });
+ } else {
+ yield put({ type: error });
+ }
+}
const uploadProfileSaga = createPromiseSaga(
uploadProfile.type,
From 9df5ae7a9ffae8109ea8690bda1d1e425cb87d4b Mon Sep 17 00:00:00 2001
From: rktguswjd <010_cm@naver.com>
Date: Sat, 26 Jun 2021 18:11:35 +0900
Subject: [PATCH 4/5] =?UTF-8?q?[fix]=20nickname=20=EB=AC=B4=ED=95=9C=20?=
=?UTF-8?q?=EC=9E=85=EB=A0=A5=20=EC=88=98=EC=A0=95,=20nickname=20=EB=B3=80?=
=?UTF-8?q?=EA=B2=BD=20=ED=9B=84=20userInfo=20=EC=97=85=EB=8D=B0=EC=9D=B4?=
=?UTF-8?q?=ED=8A=B8,=20profile=20=EB=B3=80=EA=B2=BD=20=ED=9B=84=20?=
=?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=B6=9C=EB=A0=A5=20=EC=88=98?=
=?UTF-8?q?=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/view/mypage/AccountManage.jsx | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/src/view/mypage/AccountManage.jsx b/src/view/mypage/AccountManage.jsx
index bda30aee..1a165ab8 100644
--- a/src/view/mypage/AccountManage.jsx
+++ b/src/view/mypage/AccountManage.jsx
@@ -10,6 +10,7 @@ import AutosizeInput from "react-input-autosize";
import Error from "../Error";
import BottomBtn, { PageContainer } from "../../components/frame/BottomBtn";
import ManageList from "../../components/MyPage/ManageList";
+import { StyledSpinner } from "../../components/common/Loading";
const { deepGray } = theme.colors;
const { lg } = theme.fontSizes;
@@ -25,6 +26,7 @@ const AccountManage = () => {
putNickname,
uploadImg,
logOut,
+ nicknameSuccess,
} = useUser();
const fileInput = useRef();
@@ -39,6 +41,10 @@ const AccountManage = () => {
profileUrl && putProfile({ profileUrl: profileUrl });
}, [profileUrl]);
+ useEffect(() => {
+ if (nicknameSuccess) setInputValue("");
+ }, [nicknameSuccess, setInputValue]);
+
const onChange = useCallback(
(e) => {
setInputValue(e.target.value);
@@ -52,7 +58,7 @@ const AccountManage = () => {
if (!inputValue || data.nickname === inputValue) return;
putNickname({ nickname: inputValue });
},
- [inputValue]
+ [inputValue, putNickname]
);
const onKeyPress = (event) => {
@@ -82,7 +88,7 @@ const AccountManage = () => {
}
);
};
-
+ console.log(nicknameSuccess);
if (!loggedIn) return ;
return logInLoading ? (
@@ -91,7 +97,7 @@ const AccountManage = () => {
- {data.profileImg ? (
+ {profileUrl == null && data.profileImg ? (
{