refactor: Move login redirection logic into useEffect for improved session handling and code clarity
This commit is contained in:
parent
c4ed298db5
commit
ea7180b527
@ -29,12 +29,6 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
|
|||||||
const { setAlertMsg, setAlertBtn, setAlert, setAlert2, setAlert2BtnYes, setAlert2BtnNo } = usePopupController()
|
const { setAlertMsg, setAlertBtn, setAlert, setAlert2, setAlert2BtnYes, setAlert2BtnNo } = usePopupController()
|
||||||
const { session, setSession } = useSessionStore()
|
const { session, setSession } = useSessionStore()
|
||||||
|
|
||||||
if (pathname === '/login') {
|
|
||||||
if (session?.isLoggedIn) {
|
|
||||||
router.push('/')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 사용자 이벤트 트래킹 처리
|
* 사용자 이벤트 트래킹 처리
|
||||||
*
|
*
|
||||||
@ -72,6 +66,11 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (pathname === '/login') {
|
||||||
|
if (session?.isLoggedIn) {
|
||||||
|
router.push('/')
|
||||||
|
}
|
||||||
|
}
|
||||||
//alert 함수 변경해서 바인딩
|
//alert 함수 변경해서 바인딩
|
||||||
window.alert = function (msg, alertBtn = () => setAlert(false)) {
|
window.alert = function (msg, alertBtn = () => setAlert(false)) {
|
||||||
alertFunc(msg, alertBtn)
|
alertFunc(msg, alertBtn)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user