diff --git a/frontend/src/pages/HostListings.jsx b/frontend/src/pages/HostListings.jsx index 06bd1eb..a25bb26 100644 --- a/frontend/src/pages/HostListings.jsx +++ b/frontend/src/pages/HostListings.jsx @@ -16,6 +16,19 @@ const HostListings = () => { const [imgErrors, setImgErrors] = useState({}); // Track loading state for image const [isLoading, setIsLoading] = useState(true); + // Modal state +const [isModalOpen, setIsModalOpen] = useState(false); +const [selectedListingId, setSelectedListingId] = useState(null); + +const handleConfirmDelete = () => { + if (selectedListingId) { + deleteListing(selectedListingId); + setIsModalOpen(false); + setSelectedListingId(null); + } +}; + + // Handle image load errors const handleImageError = (listingId) => { @@ -379,19 +392,55 @@ const HostListings = () => { // Loading state while fetching listings if (loading) { - return ( -
-
- - Loading your listings... + return ( +
+
+ + {/* all your listings code here */} + +
+ + {/* 👇 PASTE MODAL HERE 👇 */} + + {isModalOpen && ( +
+
+

+ Confirm Delete +

+

+ Are you sure you want to delete this listing? +

+ +
+ + + +
- ); + )} + +
+); + } return (
+ + {/* Page header with title and Add new listing button */}

@@ -611,11 +660,15 @@ const HostListings = () => { {/* Delete listing button */} + onClick={() => { + setSelectedListingId(listing.id); + setIsModalOpen(true); + }} + className="inline-flex items-center px-3 py-1.5 border border-neutral-300 text-sm font-medium rounded-md text-red-700 bg-white hover:bg-red-50 hover:border-red-300" +> + Delete + +