From 1c7f08520aa78855e15ca2903c8012f7f3f3f3fb Mon Sep 17 00:00:00 2001 From: prosperceed Date: Thu, 27 Aug 2026 20:18:34 +0000 Subject: [PATCH] fix: distinguish filtered workspace empty state --- frontend/app/workspaces/page.tsx | 181 ++++++++++++++++++++++++++++--- 1 file changed, 167 insertions(+), 14 deletions(-) diff --git a/frontend/app/workspaces/page.tsx b/frontend/app/workspaces/page.tsx index 60fa40a..96cb969 100644 --- a/frontend/app/workspaces/page.tsx +++ b/frontend/app/workspaces/page.tsx @@ -5,37 +5,48 @@ import DashboardLayout from "@/components/dashboard/DashboardLayout"; import { useGetWorkspaces } from "@/lib/react-query/hooks/workspaces/useGetWorkspaces"; import { WorkspaceType } from "@/lib/types/workspace"; import WorkspaceCard from "@/components/workspaces/WorkspaceCard"; +<<<<<<< HEAD import { Search, SlidersHorizontal, Building2, X, } from "lucide-react"; +======= +import { Search, SlidersHorizontal, Building2 } from "lucide-react"; +>>>>>>> f26430a (fix: distinguish filtered workspace empty state) const WORKSPACE_TYPES: { label: string; value: WorkspaceType | "" }[] = [ - { label: "All Types", value: "" }, - { label: "Coworking", value: "COWORKING" }, - { label: "Private Office", value: "PRIVATE_OFFICE" }, - { label: "Meeting Room", value: "MEETING_ROOM" }, - { label: "Hot Desk", value: "HOT_DESK" }, - { label: "Dedicated Desk", value: "DEDICATED_DESK" }, + { label: "All Types", value: "" }, + { label: "Coworking", value: "COWORKING" }, + { label: "Private Office", value: "PRIVATE_OFFICE" }, + { label: "Meeting Room", value: "MEETING_ROOM" }, + { label: "Hot Desk", value: "HOT_DESK" }, + { label: "Dedicated Desk", value: "DEDICATED_DESK" }, ]; export default function WorkspacesPage() { +<<<<<<< HEAD const [search, setSearch] = useState(""); const [type, setType] = useState""); const [page, setPage] = useState(1); +======= + const [search, setSearch] = useState(""); + const [type, setType] = useState(""); + const [page, setPage] = useState(1); +>>>>>>> f26430a (fix: distinguish filtered workspace empty state) - const { data, isLoading, isError } = useGetWorkspaces({ - search: search || undefined, - type: type || undefined, - page, - limit: 9, - }); + const { data, isLoading, isError } = useGetWorkspaces({ + search: search || undefined, + type: type || undefined, + page, + limit: 9, + }); - const workspaces = data?.data ?? []; - const meta = data?.meta; + const workspaces = data?.data ?? []; + const meta = data?.meta; +<<<<<<< HEAD const hasActiveFilters = search !== "" || type !== ""; const handleClearFilters = () => { @@ -151,4 +162,146 @@ export default function WorkspacesPage() { )} ); +======= + const hasActiveFilters = search.trim() !== "" || type !== ""; + + const clearFilters = () => { + setSearch(""); + setType(""); + setPage(1); + }; + + return ( + + {/* Header */} +
+

Workspaces

+

+ Browse and book available workspaces. +

+
+ + {/* Filters */} +
+
+ + { + setSearch(e.target.value); + setPage(1); + }} + className="w-full pl-9 pr-4 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-200" + /> +
+ +
+ + +
+
+ + {/* Content */} + {isLoading ? ( +
+ {[1, 2, 3, 4, 5, 6].map((i) => ( +
+ ))} +
+ ) : isError ? ( +
+ +

Failed to load workspaces

+

Please try again later.

+
+ ) : workspaces.length === 0 && hasActiveFilters ? ( +
+ + +

+ No workspaces match your current filters +

+ +

+ Try changing your search or workspace type. +

+ + +
+ ) : workspaces.length === 0 ? ( +
+ + +

No workspaces available

+ +

+ There are currently no workspaces available to browse. +

+
+ ) : ( + <> +
+ {workspaces.map((ws) => ( + + ))} +
+ + {/* Pagination */} + {meta && meta.totalPages > 1 && ( +
+

+ Showing {(page - 1) * 9 + 1}–{Math.min(page * 9, meta.total)} of{" "} + {meta.total} +

+ +
+ + + +
+
+ )} + + )} + + ); +>>>>>>> f26430a (fix: distinguish filtered workspace empty state) }