diff --git a/frontend/src/components/EmptyState.jsx b/frontend/src/components/EmptyState.jsx new file mode 100644 index 0000000..4e64748 --- /dev/null +++ b/frontend/src/components/EmptyState.jsx @@ -0,0 +1,16 @@ +import React from "react"; + +const EmptyState = ({ title, description }) => { + return ( +
+

+ {title} +

+

+ {description} +

+
+ ); +}; + +export default EmptyState; diff --git a/frontend/src/components/Loading.jsx b/frontend/src/components/Loading.jsx new file mode 100644 index 0000000..754f10f --- /dev/null +++ b/frontend/src/components/Loading.jsx @@ -0,0 +1,12 @@ +import React from "react"; + +const Loading = ({ message = "Loading..." }) => { + return ( +
+
+

{message}

+
+ ); +}; + +export default Loading; diff --git a/frontend/src/pages/HostListings.jsx b/frontend/src/pages/HostListings.jsx index 06bd1eb..c406902 100644 --- a/frontend/src/pages/HostListings.jsx +++ b/frontend/src/pages/HostListings.jsx @@ -1,5 +1,8 @@ import React, { useState, useEffect } from "react"; import { Link } from "react-router-dom"; +import Loading from "../components/Loading"; +import EmptyState from "../components/EmptyState"; + // Fallback image in case property image fails to load const FALLBACK_IMAGE_URL = @@ -16,6 +19,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) => { @@ -378,20 +394,56 @@ const HostListings = () => { }; // Loading state while fetching listings - if (loading) { - return ( -
-
- - Loading your listings... + if (loading) { + 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 +663,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 + +

@@ -659,60 +715,22 @@ const HostListings = () => { )) ) : ( // Empty state when no listings match the current filter -
- - - - {/* Empty state title */} -

- No listings found -

- {/* Empty state description */} -

- {activeTab === "all" - ? "Get started by creating a new listing" - : `You don't have any ${activeTab} listings`} -

- {/* Call-to-action button to add a new listing */} -
- - - - - Add new listing - -
+ + )} + +
- )} +
-
- - ); -}; + ); + }; + } export default HostListings;