diff --git a/README.md b/README.md index f4d602c..9a8f825 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ Code House comes up with a whole bunch of amazing features to provide you the be - 📬 **Newsletter** (once a week) - 💻 **Fully Responsive** - 🔤 **Reply to a comment** +- 📩 **Create Collections with Bookmarks** +- 📱 **Drag and Drop to arrange collections** Code House is the next revolutionary app to hunt the best cheat sheets for all types ✨️ @@ -148,6 +150,7 @@ After your PR got merged, you'll be automatically appared on [contributors page] - [Material UI](http://material-ui.com/): for components - [Animate.css](https://animate.style/): for smooth Animations - [AOS](https://michalsnik.github.io/aos/): for scroll animations +- [React Beautiful DND](https://react-beautiful-dnd.netlify.app/): For Drag and Drop support on Collections Page - [Vercel](http://vercel.com/): for hosting ## 🌈 What's next @@ -161,7 +164,6 @@ Here are some idea that is coming really soon 👀 - Markdown support for feature requests - Twitter and Facebook Auth, **In Progress ⏳️** - Perform Operations with API -- Create Collection when bookmarking cheatsheets - Featuring Cheatsheets on day basis - Generate Cover Image for missing ones - Settings page diff --git a/components/core/InfoBar.js b/components/core/InfoBar.js index e15d34f..2e49423 100644 --- a/components/core/InfoBar.js +++ b/components/core/InfoBar.js @@ -46,22 +46,31 @@ const InfoBar = ({ const [text, setText] = useState(""); // destructuring currentPost[0] - const { id, cheatsheet_name, website_url, upvotes, comments } = + let { id, cheatsheet_name, website_url, upvotes, comments } = currentPost.length > 0 && currentPost[0]; // fetching bookmarked cheatsheets and check if already bookmarked or not const fetchBookmarkedCheatsheets = () => { - if (bookmarks.some((cheatsheet) => cheatsheet.id === id)) { - setIsBookMarked(true); - } else { - setIsBookMarked(false); + let bookmarked = false; + for(let bookmark of bookmarks) { + if(bookmark.id === id){ + bookmarked = true; + } } + setIsBookMarked(bookmarked); }; // use effect to handle it useEffect(() => { - fetchBookmarkedCheatsheets(); - }, [bookmarks]); + if(currentPost.length > 0) { + id = currentPost[0].id; + cheatsheet_name = currentPost[0].cheatsheet_name; + website_url = currentPost[0].website_url; + upvotes = currentPost[0].upvotes; + comments = currentPost[0].comments; + } + return fetchBookmarkedCheatsheets(); + }, [bookmarks, currentPost]); useEffect(() => { // normal state @@ -251,8 +260,6 @@ const InfoBar = ({ } }; - console.log(comments); - return (