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' ;
@@ -7,6 +7,7 @@ import { postLogout } from '@/api/user.ts';
77import { useAuthContext } from '@/hooks/useAuthContext.tsx' ;
88
99import ReservationCard from '@/components/Navbar/ReservationCard.tsx' ;
10+ import { toast } from '@/components/Toast/index.ts' ;
1011import Button from '@/components/common/Button' ;
1112import Icon from '@/components/common/Icon' ;
1213import Popover from '@/components/common/Popover' ;
@@ -22,6 +23,7 @@ const RESERVATION_DELETE_MUTATION_KEY = ['reservation'];
2223
2324export default function Navbar ( ) {
2425 const { isLogin, userId, logout } = useAuthContext ( ) ;
26+ const navigate = useNavigate ( ) ;
2527 const queryClient = useQueryClient ( ) ;
2628 const { data : reservations } = useQuery < Reservation [ ] , CustomError > ( {
2729 queryKey : [ `reservation` ] ,
@@ -34,8 +36,12 @@ export default function Navbar() {
3436 mutationKey : RESERVATION_DELETE_MUTATION_KEY ,
3537 mutationFn : deleteReservation ,
3638 onSuccess : ( ) => {
39+ toast . warning ( '예매내역이 삭제되었습니다.' ) ;
3740 return queryClient . refetchQueries ( { queryKey : [ 'reservation' ] } ) ;
3841 } ,
42+ onError : ( ) => {
43+ toast . error ( '예매내역 삭제에 실패했습니다.\n 잠시 후 다시 시도해주세요' ) ;
44+ } ,
3945 } ) ;
4046
4147 const deletingReservationIdList = useMutationState ( {
@@ -45,16 +51,19 @@ export default function Navbar() {
4551
4652 const { mutate : requestLogout } = useMutation ( {
4753 mutationFn : postLogout ,
48- onError : ( ) => { } ,
4954 onSuccess : ( ) => {
50- if ( logout ) logout ( ) ;
55+ if ( logout ) {
56+ logout ( ) ;
57+ toast . warning ( '로그아웃 되었습니다' ) ;
58+ navigate ( '/' , { replace : true } ) ;
59+ }
5160 } ,
5261 } ) ;
5362
5463 const handleLogOut = ( ) => {
5564 requestLogout ( ) ;
5665 } ;
57- //TODO 예약 내역
66+
5867 const isReservation = reservations && reservations . length > 0 ;
5968 const widthClass = `w-[${ POPOVER_WIDTH } px]` ;
6069 return (
@@ -77,10 +86,13 @@ export default function Navbar() {
7786 < Popover . Overlay >
7887 < Popover . Content >
7988 < div
80- className = { cx ( widthClass , `flex flex-col gap-6 rounded-xl border bg-white p-6 shadow-2xl` ) } >
89+ className = { cx (
90+ widthClass ,
91+ `flex max-h-[80vh] min-h-[300px] flex-col gap-6 rounded-xl border bg-white p-6 shadow-2xl` ,
92+ ) } >
8193 < h3 className = "px-4 text-left text-heading3" > 예매 현황</ h3 >
8294 < Separator direction = "row" />
83- < div className = "flex max-h-[800px] flex-col gap-6 overflow-y-scroll pr-4" >
95+ < div className = "flex max-h-[800px] flex-grow flex- col gap-6 overflow-y-scroll pr-4" >
8496 { isReservation ? (
8597 reservations . map ( ( reservation ) => (
8698 < ReservationCard
@@ -91,7 +103,9 @@ export default function Navbar() {
91103 />
92104 ) )
93105 ) : (
94- < div className = "w-full text-heading2 text-typo-sub" > 현재 예매된 내역이 없습니다. </ div >
106+ < div className = "m-auto w-full text-heading2 text-typo-sub" >
107+ 현재 예매된 내역이 없습니다.{ ' ' }
108+ </ div >
95109 ) }
96110 </ div >
97111 < Separator direction = "row" />
0 commit comments