fix: update EdgeProvider routing logic to handle session state more effectively

This commit is contained in:
yoosangwook 2025-06-11 10:12:46 +09:00
parent 10787e7e60
commit ada3057d36

View File

@ -36,12 +36,12 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
*
*
*/
const handlePageEvent = (path: string) => {
tracking({
url: path,
data: '',
})
}
// const handlePageEvent = (path: string) => {
// tracking({
// url: path,
// data: '',
// })
// }
/**
* alert - window.alert
@ -69,17 +69,6 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
}
useEffect(() => {
if (pathname === '/login') {
if (session?.isLoggedIn) {
router.push('/')
}
}
if (pathname === '/') {
if (!session?.isLoggedIn) {
router.push('/login')
}
}
//alert 함수 변경해서 바인딩
window.alert = function (msg, alertBtn = () => setAlert(false)) {
alertFunc(msg, alertBtn)
@ -94,6 +83,13 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
alertFunc2(msg, alertBtn2Yes || (() => {}), alertBtn2No || (() => {}))
return false
}
if (sessionData === '') {
router.push('/login')
} else {
if (pathname === '/login') {
router.push('/')
}
}
// 서버 세션이 있으면 zuatand 세션 데이터 갱신
if (sessionData && sessionData !== '') {
setSession({