diff --git a/client/src/pages/BookingConfirmation.tsx b/client/src/pages/BookingConfirmation.tsx index 47c9f8c..4cebe49 100644 --- a/client/src/pages/BookingConfirmation.tsx +++ b/client/src/pages/BookingConfirmation.tsx @@ -12,6 +12,7 @@ import BookingSummary from "../components/booking/BookingSummary.tsx"; import BookingForm from "../components/booking/BookingForm.tsx"; import api from "../lib/api.ts"; + export default function BookingConfirmation() { const { slug } = useParams<{ slug: string }>(); const [searchParams] = useSearchParams(); @@ -52,10 +53,11 @@ export default function BookingConfirmation() { setLoading(true); const res = await api.get(`/restaurant/${slug}`); setRestaurant(res.data.restaurant); - } catch (error) { - toast.error(error?.response?.data?.message || error?.message); - navigate("/"); - }finally{ + } catch (error: any) { + toast.error(error?.response?.data?.message || error?.message || "Something went wrong"); +} + + finally{ setLoading(false); } }; @@ -90,9 +92,11 @@ export default function BookingConfirmation() { }); setConfirmedBooking(res.data); toast.success("Reservation confirmed!"); - } catch (error: any) { - toast.error(error?.response?.data?.message || error?.message); - } finally { + } + catch (error: any) { + toast.error(error?.response?.data?.message || error?.message || "Something went wrong"); +} + finally { setConfirming(false); } }; diff --git a/client/src/pages/Dashboard.tsx b/client/src/pages/Dashboard.tsx index a5daf7a..4f47777 100644 --- a/client/src/pages/Dashboard.tsx +++ b/client/src/pages/Dashboard.tsx @@ -26,8 +26,8 @@ export default function Dashboard() { setBookings(res.data.bookings); } catch (error: any) { - toast.error(error?.response?.data?.message || error?.message); - } finally { + toast.error(error?.response?.data?.message || error?.message || "Something went wrong"); +} finally { setLoadingBookings(false); } }; @@ -45,8 +45,8 @@ export default function Dashboard() { setRecommendations(res.data.restaurants); } catch (error: any) { - toast.error(error?.response?.data?.message || error?.message); - } + toast.error(error?.response?.data?.message || error?.message || "Something went wrong"); +} }; fetchRecommendations(); }, []); @@ -61,9 +61,9 @@ export default function Dashboard() { // Update local state setBookings((prev) => prev.map((b) => (b._id === bookingId ? { ...b, status: "cancelled" } : b))) toast.success("Reservation cancelled successfully."); - } catch (error: any) { - toast.error(error?.response?.data?.message || error?.message); - } + }catch (error: any) { + toast.error(error?.response?.data?.message || error?.message || "Something went wrong"); +} }; if (!user) return null;