diff --git a/src/components/BrowseAccommodations.tsx b/src/components/BrowseAccommodations.tsx index c9b38a8..40dcd9f 100644 --- a/src/components/BrowseAccommodations.tsx +++ b/src/components/BrowseAccommodations.tsx @@ -1,19 +1,24 @@ +import { useRouter } from "next/navigation"; import { useEffect, useState } from "react" +import { SlLocationPin } from "react-icons/sl"; import { useDebounce } from "use-debounce" export default function BrowseAccommodations(props: {posts: any[]}) { const [searchQuery, setSearchQuery]= useState("") const [debouncedQuery] = useDebounce(searchQuery, 500); const [filteredPosts, setFilteredPosts] = useState([] as any[]); + const router = useRouter(); const handleChange = (e: any) => setSearchQuery(e.target.value.toLowerCase()) - + const handleResultClick = (postId:string) => { + router.push(`/display_accommodation/${postId}`); + } useEffect(() => { - // console.log(debouncedQuery) setFilteredPosts(props.posts.filter((post) => { - return post.location.toLowerCase().includes(searchQuery) + return post.location.toLowerCase().includes(searchQuery) || + post.title.toLowerCase().includes(searchQuery) })) }, [debouncedQuery]) @@ -23,8 +28,19 @@ export default function BrowseAccommodations(props: {posts: any[]}) { return (