File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
front/src/components/Navbar Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1- import { Link } from 'react-router-dom' ;
1+ import { Link , useNavigate } from 'react-router-dom' ;
22
33import { CustomError } from '@/api/axios.ts' ;
44import { deleteReservation , getReservation } from '@/api/reservation.ts' ;
@@ -23,6 +23,7 @@ const RESERVATION_DELETE_MUTATION_KEY = ['reservation'];
2323
2424export default function Navbar ( ) {
2525 const { isLogin, userId, logout } = useAuthContext ( ) ;
26+ const navigate = useNavigate ( ) ;
2627 const queryClient = useQueryClient ( ) ;
2728 const { data : reservations } = useQuery < Reservation [ ] , CustomError > ( {
2829 queryKey : [ `reservation` ] ,
@@ -51,8 +52,11 @@ export default function Navbar() {
5152 const { mutate : requestLogout } = useMutation ( {
5253 mutationFn : postLogout ,
5354 onSuccess : ( ) => {
54- if ( logout ) logout ( ) ;
55- toast . warning ( '로그아웃 되었습니다' ) ;
55+ if ( logout ) {
56+ logout ( ) ;
57+ toast . warning ( '로그아웃 되었습니다' ) ;
58+ navigate ( '/' , { replace : true } ) ;
59+ }
5660 } ,
5761 } ) ;
5862
You can’t perform that action at this time.
0 commit comments