Skip to content
Snippets Groups Projects
Commit c77727eb authored by Tonge, Marcus A (UG - Comp Sci & Elec Eng)'s avatar Tonge, Marcus A (UG - Comp Sci & Elec Eng)
Browse files

Delete button for bookings page

parent ca4f783d
No related branches found
No related tags found
Loading
...@@ -61,6 +61,24 @@ const BookingsPage = () => { ...@@ -61,6 +61,24 @@ const BookingsPage = () => {
setIsOpen(true); setIsOpen(true);
}; };
const handleDeleteBooking = async (selectedBooking) => {
try {
const response = await fetch(`${bookingServiceBaseUrl}/bookings/delete/${selectedBooking.id}`, {
method: "DELETE",
headers: {
Authorization: `Bearer ${localStorage.getItem("token")}`,
},
});
if (response.ok) {
setBookings(bookings.filter((booking) => booking.id !== selectedBooking.id));
} else {
setError("Booking extension failed");
}
} catch (error) {
setError(error.message);
}
};
const handleSubmitExtend = async () => { const handleSubmitExtend = async () => {
setIsOpen(false); setIsOpen(false);
setExtendTime(null); setExtendTime(null);
...@@ -119,9 +137,15 @@ const BookingsPage = () => { ...@@ -119,9 +137,15 @@ const BookingsPage = () => {
<Text> <Text>
<strong>Expiry Time:</strong> {booking.endTime} <strong>Expiry Time:</strong> {booking.endTime}
</Text> </Text>
<Stack>
<Button mt={4} onClick={() => handleExtendBooking(booking)}> <Button mt={4} onClick={() => handleExtendBooking(booking)}>
Extend booking Extend booking
</Button> </Button>
<Button color={"white"} backgroundColor={"red.500"} mt={4} onClick={() => handleDeleteBooking(booking)}>
Delete booking
</Button>
</Stack>
</Box> </Box>
))} ))}
</Stack> </Stack>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment