Skip to content

Commit 9f330e4

Browse files
committed
fix: 로그인 라우트에서 이미 로그인 된 유저 노티가 한번 더 문제 수정
1 parent c8c4f91 commit 9f330e4

File tree

1 file changed

+11
-1
lines changed
  • apps/pyconkr-admin/src/components/pages/account

1 file changed

+11
-1
lines changed

apps/pyconkr-admin/src/components/pages/account/sign_in.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ import { useNavigate } from "react-router-dom";
66

77
import { addErrorSnackbar, addSnackbar } from "../../../utils/snackbar";
88

9+
type PageStateType = {
10+
userJustSignedIn: boolean;
11+
};
12+
913
export const SignInPage: React.FC = () => {
1014
const navigate = useNavigate();
1115
const formRef = React.useRef<HTMLFormElement>(null);
16+
const [pageState, setPageState] = React.useState<PageStateType>({ userJustSignedIn: false });
17+
const setUserJustSignedIn = () => setPageState((ps) => ({ ...ps, userJustSignedIn: true }));
18+
1219
const backendAdminAPIClient = Common.Hooks.BackendAdminAPI.useBackendAdminClient();
1320
const signInMutation = Common.Hooks.BackendAdminAPI.useSignInMutation(backendAdminAPIClient);
1421

@@ -22,6 +29,7 @@ export const SignInPage: React.FC = () => {
2229
}>({ form: formRef.current });
2330
signInMutation.mutate(formData, {
2431
onSuccess: (data) => {
32+
setUserJustSignedIn();
2533
addSnackbar(`안녕하세요, ${data.username}님!`, "success");
2634
navigate("/");
2735
},
@@ -31,13 +39,15 @@ export const SignInPage: React.FC = () => {
3139

3240
React.useEffect(() => {
3341
(async () => {
42+
if (pageState.userJustSignedIn) return;
43+
3444
const userInfo = await Common.BackendAdminAPIs.me(backendAdminAPIClient)();
3545
if (userInfo) {
3646
addSnackbar(`이미 ${userInfo.username}님으로 로그인되어 있습니다!`, "success");
3747
navigate("/");
3848
}
3949
})();
40-
}, [backendAdminAPIClient, navigate]);
50+
}, [backendAdminAPIClient, navigate, pageState.userJustSignedIn]);
4151

4252
return (
4353
<Stack sx={{ width: "100%", height: "100%", flexGrow: 1 }}>

0 commit comments

Comments
 (0)