From 32842613bc70659e0fc2ccccecb82d479a65b1fc Mon Sep 17 00:00:00 2001 From: suhwa Date: Mon, 6 Feb 2023 16:03:43 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8,=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85,=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=9E=AC=EC=84=A4=EC=A0=95=20=EC=84=B1=EA=B3=B5=20?= =?UTF-8?q?=EC=8B=9C=20home=EC=9C=BC=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Auth/LoginForm/FormAndButton.tsx | 7 ++++++- src/components/Auth/ResetPassword/ResetPasswordForm.tsx | 7 +++++-- src/components/Auth/SignUpForm/EmailConfirmForm.tsx | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/Auth/LoginForm/FormAndButton.tsx b/src/components/Auth/LoginForm/FormAndButton.tsx index 6cd225ba..bf2d5eae 100644 --- a/src/components/Auth/LoginForm/FormAndButton.tsx +++ b/src/components/Auth/LoginForm/FormAndButton.tsx @@ -5,6 +5,7 @@ import { useAppDispatch, useAppSelector } from "app/store/Hooks"; import { signIn } from "app/store/ducks/auth/authThunk"; import useInput from "hooks/useInput"; import Loading from "components/Common/Loading"; +import { useHistory } from "react-router-dom"; const placeholder = { username: "사용자 이름", @@ -12,6 +13,8 @@ const placeholder = { }; export default function LoginFormAndButton() { + const history = useHistory(); + const [usernameInputProps, usernameIsValid, usernameIsFocus] = useInput( "", undefined, @@ -36,7 +39,9 @@ export default function LoginFormAndButton() { }), ); }; - requestSignIn(); + requestSignIn().then(() => { + history.push("/"); + }); }; return ( diff --git a/src/components/Auth/ResetPassword/ResetPasswordForm.tsx b/src/components/Auth/ResetPassword/ResetPasswordForm.tsx index 83ac270c..a745ee17 100644 --- a/src/components/Auth/ResetPassword/ResetPasswordForm.tsx +++ b/src/components/Auth/ResetPassword/ResetPasswordForm.tsx @@ -1,4 +1,4 @@ -import { useLocation } from "react-router-dom"; +import { useHistory, useLocation } from "react-router-dom"; import queryString from "query-string"; import HeaderBeforeLogin from "./HeaderBeforeLogin"; import ContentBox from "components/Common/ContentBox"; @@ -72,6 +72,7 @@ const Container = styled.section` `; export default function ResetPasswordForm() { + const history = useHistory(); const { search } = useLocation(); const { username, code } = queryString.parse( search, @@ -105,7 +106,9 @@ export default function ResetPasswordForm() { username, newPassword: newPasswordInputProps.value, }), - ); + ).then(() => { + history.push("/"); + }); }; return ( diff --git a/src/components/Auth/SignUpForm/EmailConfirmForm.tsx b/src/components/Auth/SignUpForm/EmailConfirmForm.tsx index fe75eb35..7c0d8040 100644 --- a/src/components/Auth/SignUpForm/EmailConfirmForm.tsx +++ b/src/components/Auth/SignUpForm/EmailConfirmForm.tsx @@ -11,6 +11,7 @@ import { authAction } from "app/store/ducks/auth/authSlice"; import { signIn } from "app/store/ducks/auth/authThunk"; import { useState } from "react"; import Loading from "components/Common/Loading"; +import { useHistory } from "react-router-dom"; const Container = styled.div` .form-description { @@ -71,6 +72,7 @@ const messageImage: CommonType.ImageProps = { }; export default function EmailConfirmForm() { + const history = useHistory(); const userInput = useAppSelector((state) => state.auth.signUpUserData); const dispatch = useAppDispatch(); const [errorMessage, setErrorMessage] = useState(""); @@ -129,7 +131,9 @@ export default function EmailConfirmForm() { username: userInput.username, password: userInput.password, }), - ); + ).then(() => { + history.push("/"); + }); } else if (status === 200 && !data) { setErrorMessage(message); // 인증코드가 다를 경우, 200번대가 아니라 400번대가 더 적합할 거 같음(사용자 입력에러니까)