Skip to content

Commit

Permalink
fixed the fucking loop
Browse files Browse the repository at this point in the history
  • Loading branch information
lGnyte committed May 28, 2024
1 parent 5fa2643 commit d0b6938
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/components/BrowseAccommodations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export default function BrowseAccommodations(props: {posts: any[]}) {
}))
}, [debouncedQuery, props.posts])

useEffect(() => {
console.log("Filtered posts", filteredPosts)
}, [filteredPosts]);

return (
<div className="mb-10">
<label className="text-lg mr-2" htmlFor="search">Browse by location or name:</label>
Expand Down
11 changes: 6 additions & 5 deletions src/components/PostsFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ import { BsCashCoin } from "react-icons/bs";

export default function PostsFeed(props: {usertype?: string, setFeedPosts?: React.Dispatch<SetStateAction<any[]>>}) {
const [posts, setPosts] = useState([] as DocumentData[]);
const { usertype, setFeedPosts } = props

useEffect(() => {
(async () => {
const querySnapshot = await getDocs(collection(db, 'accommodations'));
const postsData = querySnapshot.docs.map(doc => ({...doc.data(), id: doc.id}));
setPosts(postsData);
if(props.setFeedPosts) {
props.setFeedPosts(postsData)
if(setFeedPosts) {
setFeedPosts(postsData)
}
})();
}, [props]);
}, [setFeedPosts]);

return (
<section className="grid grid-cols-3 gap-4">
Expand All @@ -40,9 +41,9 @@ export default function PostsFeed(props: {usertype?: string, setFeedPosts?: Reac
}
</div>
<p className="text-sm mb-4"><BsCashCoin className="inline-block" /> <strong>{post.price} RON</strong> per room</p>
{props.usertype === "guest" ?
{usertype === "guest" ?
<Link href={`display_accommodation/${post.id}`} className="bg-gray-800 hover:bg-gray-500 rounded-md duration-200 px-4 py-2 text-white font-semibold mt-2">View Experience</Link>
: props.usertype !== "host" &&
: usertype !== "host" &&
<button disabled className="px-2 py-1 bg-gray-300 cursor-not-allowed rounded-md">Sign In to view</button>
}
</div>
Expand Down

0 comments on commit d0b6938

Please sign in to comment.