refactor: Move login redirection logic into useEffect for improved session handling and code clarity

This commit is contained in:
yoosangwook 2025-05-22 09:49:46 +09:00
parent c4ed298db5
commit ea7180b527

View File

@ -29,12 +29,6 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
const { setAlertMsg, setAlertBtn, setAlert, setAlert2, setAlert2BtnYes, setAlert2BtnNo } = usePopupController()
const { session, setSession } = useSessionStore()
if (pathname === '/login') {
if (session?.isLoggedIn) {
router.push('/')
}
}
/**
*
*
@ -72,6 +66,11 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
}
useEffect(() => {
if (pathname === '/login') {
if (session?.isLoggedIn) {
router.push('/')
}
}
//alert 함수 변경해서 바인딩
window.alert = function (msg, alertBtn = () => setAlert(false)) {
alertFunc(msg, alertBtn)