diff --git a/README.md b/README.md index 95cf8201..331bba71 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Style Share is a collaborative platform designed to streamline the process of cr 2. Run the following commands in the backend folder ```sh - npm install + npm install npm run build npm run dev ``` diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5c73538f..cccfab1a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -14,10 +14,20 @@ import AuthenticatedRoute from "./components/AuthenticatedRoute"; import Profile from "./pages/Profile"; import React from "react"; import Loader from "./components/Loader"; +import BookmarkList from './components/BookmarkList'; // import axios from "axios"; // axios.defaults.baseURL = "http://localhost:3001/"; function App() { + const [bookmarks, setBookmarks] = useState([]); + + const handleBookmark = (item: string) => { + setBookmarks((prevBookmarks) => + prevBookmarks.includes(item) + ? prevBookmarks.filter((bookmark) => bookmark !== item) + : [...prevBookmarks, item] + ); + }; return ( diff --git a/frontend/src/components/BookmarkButton.tsx b/frontend/src/components/BookmarkButton.tsx new file mode 100644 index 00000000..d8fd3c4b --- /dev/null +++ b/frontend/src/components/BookmarkButton.tsx @@ -0,0 +1,17 @@ +import React, { useState } from 'react'; + +interface BookmarkButtonProps { + item: string; + onBookmark: (item: string) => void; + isBookmarked: boolean; +} + +const BookmarkButton: React.FC = ({ item, onBookmark, isBookmarked }) => { + return ( + + ); +}; + +export default BookmarkButton; diff --git a/frontend/src/components/BookmarkList.tsx b/frontend/src/components/BookmarkList.tsx new file mode 100644 index 00000000..8033c9ab --- /dev/null +++ b/frontend/src/components/BookmarkList.tsx @@ -0,0 +1,23 @@ +import React from 'react'; + +interface BookmarkListProps { + bookmarks: string[]; + onRemove: (item: string) => void; +} + +const BookmarkList: React.FC = ({ bookmarks, onRemove }) => { + return ( +
+

Bookmarked Items

+
    + {bookmarks.map((bookmark, index) => ( +
  • + {bookmark} +
  • + ))} +
+
+ ); +}; + +export default BookmarkList; diff --git a/frontend/src/pages/Posts.tsx b/frontend/src/pages/Posts.tsx index 71441bbe..c5886101 100644 --- a/frontend/src/pages/Posts.tsx +++ b/frontend/src/pages/Posts.tsx @@ -3,8 +3,15 @@ import axios from 'axios'; import { IPost } from '../types'; import Loader from '../components/Loader'; import PostCard from '../components/PostCard'; +import BookmarkButton from '../components/BookmarkButton'; +import React from 'react'; -const Posts = () => { +interface PostsProps { + onBookmark: (item: string) => void; + bookmarks: string[]; +} + +const Posts: React.FC = ({ onBookmark, bookmarks }) => { const [posts, setPosts] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); @@ -68,7 +75,7 @@ const Posts = () => { ); if (loading) { - return ; + return ; } if (error) { @@ -129,7 +136,13 @@ const Posts = () => {
{filteredPosts.map((post) => ( - + + + ))}