Skip to content

Commit 1325f9d

Browse files
committed
✨ feat:토스트 추가
- 좌석 선택/취소시 토스트 추가 - 좌석 api 실패시 토스트 추가 - 예매내역 삭제,실패시 토스트 추가 Issue Resolved: #
1 parent e9cdeda commit 1325f9d

File tree

8 files changed

+48
-19
lines changed

8 files changed

+48
-19
lines changed

front/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import ToastContainer from '@/components/Toast/ToastContainer.tsx';
55
import AuthProvider from '@/providers/AuthProvider';
66
import QueryProvider from '@/providers/QueryProvider';
77
import router from '@/routes/index';
8+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
89

910
function App() {
1011
return (
1112
<QueryProvider>
1213
<AuthProvider>
1314
<RouterProvider router={router} />
1415
<ToastContainer />
16+
<ReactQueryDevtools />
1517
</AuthProvider>
1618
</QueryProvider>
1719
);

front/src/components/Captcha/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function Captcha({ goNextStep }: CaptchaProps) {
3232
setIsValid(false);
3333
if (InputRef.current) {
3434
const input = InputRef.current! as HTMLInputElement;
35-
input.value = '';
35+
setInputData('');
3636
input.focus();
3737
}
3838
}

front/src/components/Navbar/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { postLogout } from '@/api/user.ts';
77
import { useAuthContext } from '@/hooks/useAuthContext.tsx';
88

99
import ReservationCard from '@/components/Navbar/ReservationCard.tsx';
10+
import { toast } from '@/components/Toast/index.ts';
1011
import Button from '@/components/common/Button';
1112
import Icon from '@/components/common/Icon';
1213
import Popover from '@/components/common/Popover';
@@ -34,6 +35,7 @@ export default function Navbar() {
3435
mutationKey: RESERVATION_DELETE_MUTATION_KEY,
3536
mutationFn: deleteReservation,
3637
onSuccess: () => {
38+
toast.warning('예매내역이 삭제되었습니다.');
3739
return queryClient.refetchQueries({ queryKey: ['reservation'] });
3840
},
3941
});
@@ -83,7 +85,7 @@ export default function Navbar() {
8385
)}>
8486
<h3 className="px-4 text-left text-heading3">예매 현황</h3>
8587
<Separator direction="row" />
86-
<div className="flex max-h-[800px] flex-grow flex-col justify-center gap-6 overflow-y-scroll pr-4">
88+
<div className="flex max-h-[800px] flex-grow flex-col gap-6 overflow-y-scroll pr-4">
8789
{isReservation ? (
8890
reservations.map((reservation) => (
8991
<ReservationCard
@@ -94,7 +96,9 @@ export default function Navbar() {
9496
/>
9597
))
9698
) : (
97-
<div className="w-full text-heading2 text-typo-sub">현재 예매된 내역이 없습니다. </div>
99+
<div className="m-auto w-full text-heading2 text-typo-sub">
100+
현재 예매된 내역이 없습니다.{' '}
101+
</div>
98102
)}
99103
</div>
100104
<Separator direction="row" />

front/src/components/Toast/Toast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function Toast({ type, text, close }: ToastProps) {
5151
}
5252

5353
const toastVariant = cva(
54-
`flex gap-4 px-4 py-3 relative h-fit w-[300px] items-center rounded border whitespace-pre-line`,
54+
`flex gap-4 px-4 py-3 relative h-fit w-[300px] items-center rounded border whitespace-pre-line z-20`,
5555
{
5656
variants: {
5757
type: {

front/src/components/Toast/ToastContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function ToastContainer() {
3636
};
3737
}, []);
3838
return (
39-
<div className="fixed left-8 top-20 flex flex-col gap-5 overflow-visible transition-all">
39+
<div className="fixed left-8 top-20 z-20 flex flex-col gap-5 overflow-visible transition-all">
4040
{toastList.map((toast) => (
4141
<Toast
4242
key={toast.id}

front/src/components/common/Popover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const Content = ({ children }: IContent) => {
115115
{canOpen &&
116116
createPortal(
117117
<div
118-
className="fixed z-[999] cursor-default"
118+
className="fixed z-10 cursor-default"
119119
style={{
120120
top: position.x + position.y + 24,
121121
right: 32,

front/src/pages/ReservationPage/SectionAndSeat.tsx

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { BASE_URL } from '@/api/axios.ts';
44
import { PostSeatData, postSeat } from '@/api/booking.ts';
55
import { postReservation } from '@/api/reservation.ts';
66

7+
import { toast } from '@/components/Toast/index.ts';
78
import Button from '@/components/common/Button.tsx';
89
import Icon from '@/components/common/Icon.tsx';
910
import Separator from '@/components/common/Separator.tsx';
@@ -54,6 +55,7 @@ export default function SectionAndSeat({
5455
(seat) => seat.seatIndex !== seatIndex || seat.sectionIndex !== sectionIndex,
5556
);
5657
setSelectedSeats([...filtered]);
58+
toast.error('좌석 선택/취소에 실패했습니다');
5759
},
5860
throwOnError: false,
5961
});
@@ -241,7 +243,13 @@ const renderSeatMap = (
241243
setSelectedSeats: (seats: SelectedSeat[]) => void,
242244
maxSelectCount: number,
243245
selectedSeats: SelectedSeat[],
244-
pickSeat: (data: PostSeatData) => void,
246+
pickSeat: (
247+
data: PostSeatData,
248+
mutateOption?: {
249+
onSuccess?: () => void;
250+
onError?: () => void;
251+
},
252+
) => void,
245253
eventId: number,
246254
reservingList: PostSeatData[],
247255
) => {
@@ -278,23 +286,37 @@ const renderSeatMap = (
278286
const selectedCount = selectedSeats.length;
279287
if (isMine) {
280288
const filtered = selectedSeats.filter((seat) => seatName !== seat.name);
281-
pickSeat({
282-
sectionIndex: selectedSectionIndex,
283-
seatIndex: index,
284-
expectedStatus: 'deleted',
285-
eventId,
286-
});
289+
pickSeat(
290+
{
291+
sectionIndex: selectedSectionIndex,
292+
seatIndex: index,
293+
expectedStatus: 'deleted',
294+
eventId,
295+
},
296+
{
297+
onSuccess: () => {
298+
toast.warning(`${seatName!} 좌석을 취소했습니다`);
299+
},
300+
},
301+
);
287302
setSelectedSeats(filtered);
288303
return;
289304
}
290305

291306
if (maxSelectCount <= selectedCount) return;
292-
pickSeat({
293-
sectionIndex: selectedSectionIndex,
294-
seatIndex: index,
295-
expectedStatus: 'reserved',
296-
eventId,
297-
});
307+
pickSeat(
308+
{
309+
sectionIndex: selectedSectionIndex,
310+
seatIndex: index,
311+
expectedStatus: 'reserved',
312+
eventId,
313+
},
314+
{
315+
onSuccess: () => {
316+
toast.success(`${seatName!} 좌석 선택에\n성공했습니다`);
317+
},
318+
},
319+
);
298320
setSelectedSeats([
299321
...selectedSeats,
300322
{ seatIndex: index, sectionIndex: selectedSectionIndex, name: seatName! },

front/src/pages/ReservationPage/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function ReservationPage() {
2525
const { data: event } = useSuspenseQuery<EventDetail, CustomError>({
2626
queryKey: [`event`, eventId],
2727
queryFn: getEventDetail(Number(eventId)),
28+
staleTime: Infinity,
2829
});
2930
const { place } = event;
3031
const { data: placeInformation } = useQuery<PlaceInformation, CustomError>({

0 commit comments

Comments
 (0)