File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 11import { useAuthStore } from '@/domains/shared/store/auth' ;
2- import { useEffect , useState } from 'react' ;
2+ import { useEffect , useState , useRef } from 'react' ;
33import { usePathname , useRouter } from 'next/navigation' ;
44import { getCookie , removeCookie } from '@/domains/shared/auth/utils/cookie' ;
55import { useToast } from '@/shared/hook/useToast' ;
@@ -12,6 +12,7 @@ export const useLoginRedirect = () => {
1212
1313 const [ loading , setLoading ] = useState ( true ) ;
1414 const [ welcomeModalOpen , setWelcomeModalOpen ] = useState ( false ) ;
15+ const hasShownToast = useRef ( false ) ;
1516
1617 useEffect ( ( ) => {
1718 if ( ! user && loading ) {
@@ -39,7 +40,8 @@ export const useLoginRedirect = () => {
3940
4041 if ( pathname . startsWith ( '/login/user/first-user' ) ) {
4142 setWelcomeModalOpen ( true ) ;
42- } else if ( pathname . startsWith ( '/login/user/success' ) ) {
43+ } else if ( pathname . startsWith ( '/login/user/success' ) && ! hasShownToast . current ) {
44+ hasShownToast . current = true ;
4345 toastSuccess ( `${ user . nickname } 님 \n 로그인 성공 🎉` ) ;
4446 router . replace ( preLoginPath ) ;
4547 setTimeout ( ( ) => removeCookie ( 'preLoginPath' ) , 500 ) ;
You can’t perform that action at this time.
0 commit comments