Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions client/src/pages/BookingConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
};
Expand Down Expand Up @@ -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);
}
};
Expand Down
14 changes: 7 additions & 7 deletions client/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand All @@ -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();
}, []);
Expand All @@ -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;
Expand Down