diff --git a/frontend/src/components/PostCard.tsx b/frontend/src/components/PostCard.tsx
index 2d83025..7aae143 100644
--- a/frontend/src/components/PostCard.tsx
+++ b/frontend/src/components/PostCard.tsx
@@ -9,7 +9,7 @@ import toast from "react-hot-toast";
import { Link } from "react-router-dom";
import { FaEdit } from "react-icons/fa";
import bgHero from "../assets/bgHero.png";
-import { MdFavorite,MdFavoriteBorder } from "react-icons/md";
+import { MdFavorite, MdFavoriteBorder } from "react-icons/md";
type Props = {
post: IPost;
@@ -184,74 +184,77 @@ const PostCard = ({ post, onDelete, currentUser }: Props) => {
};
return (
-
-
-
{post.title}
- {isFavorite ? (
-
- ) : (
-
- )}
-
-
- {post.description.length > 100
- ? `${post.description.slice(0, 100)}...`
- : post.description}
-
- By :
-
-
- {' '} @{post.author.username}{' '}
-
-
-
-
-
- {post.tags.map((tag, index) => (
-
- {tag}
-
- ))}
-
-
-
- {currentUser && currentUser.id === post.author.id && (
-
-
);
diff --git a/frontend/src/pages/EditPost.tsx b/frontend/src/pages/EditPost.tsx
index e6f0af9..f0efb0b 100644
--- a/frontend/src/pages/EditPost.tsx
+++ b/frontend/src/pages/EditPost.tsx
@@ -42,7 +42,7 @@ const EditPost = () => {
const handleAddTag = () => {
if (tagInput.length > 0 && !post.tags.includes(tagInput)) {
- setPost({ ...post, tags: [...post.tags, tagInput] });
+ setPost({ ...post, tags: [...post.tags, tagInput.toLowerCase()] });
setTagInput("");
}
};
diff --git a/frontend/src/pages/NewPost.tsx b/frontend/src/pages/NewPost.tsx
index 7ae333d..d0530d9 100644
--- a/frontend/src/pages/NewPost.tsx
+++ b/frontend/src/pages/NewPost.tsx
@@ -33,7 +33,7 @@ const NewPost = () => {
const handleAddTag = () => {
if (tagInput.length > 0 && !tags.includes(tagInput)) {
- setTags([...tags, tagInput]);
+ setTags([...tags, tagInput.toLowerCase()]);
setTagInput("");
}
};
diff --git a/frontend/src/pages/Posts.tsx b/frontend/src/pages/Posts.tsx
index d55de4a..82977d4 100644
--- a/frontend/src/pages/Posts.tsx
+++ b/frontend/src/pages/Posts.tsx
@@ -23,7 +23,7 @@ const Posts = () => {
removeTag: deleteTag,
searchQuery,
setSearchQuery,
- fetchPosts,
+ fetchPosts,
} = usePosts({
initialPage: 1,
pageSize: 12,
@@ -33,9 +33,12 @@ const Posts = () => {
const [tagInput, setTagInput] = useState("");
const [filterTags, setFilterTags] = useState
([]);
const filterRef = useRef(null);
-
const filteredPosts = posts;
-
+ const allTags = filteredPosts.map(post => post.tags).flat();
+ const uniqueTags = [...new Set(allTags)];
+ const tagsToDisplay = uniqueTags.slice(0, 3);
+ var placeholderTags = tagsToDisplay.length > 0 ? tagsToDisplay.join(", ") : "";
+ placeholderTags = placeholderTags + (uniqueTags.length > 3 ? " ..." : "");
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (filterRef.current && !filterRef.current.contains(event.target as Node)) {
@@ -44,7 +47,7 @@ const Posts = () => {
};
document.title = "Style Share | Our Posts 📃";
-
+
document.addEventListener("mousedown", handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
@@ -93,8 +96,8 @@ const Posts = () => {
return (
{
backgroundPosition: "center",
}}
>
-
Posts
+
Posts
{
value={tagInput}
onChange={(e) => setTagInput(e.target.value)}
onKeyDown={handleKeyDown}
- placeholder="Add tag"
+ placeholder={`Add tag${placeholderTags ? ` like ${placeholderTags}` : ""}`}
className="p-2 w-full rounded bg-gray-700 text-white focus:outline-none focus:ring-2 focus:ring-gray-500"
/>
@@ -180,56 +183,55 @@ const Posts = () => {
{filteredPosts.length === 0 ? (
- No Posts
+ No Posts
) : (
-
- {filteredPosts.map((post) => (
-
- ))}
+
+
+ {filteredPosts.map((post) => (
+
+ ))}
+
+
+
+ Previous
+
+ {Array.from({ length: totalPages }, (_, i) => (
+ handlePageClick(i + 1)}
+ className={`text-white px-4 py-2 rounded ${page === i + 1
+ ? "bg-blue-500 text-white"
+ : "bg-blue-600 hover:bg-blue-700"
+ }`}
+ >
+ {i + 1}
+
+ ))}
+
+ Next
+
+
)}
-
-
- Previous
-
- {Array.from({ length: totalPages }, (_, i) => (
- handlePageClick(i + 1)}
- className={`text-white px-4 py-2 rounded ${
- page === i + 1
- ? "bg-blue-500 text-white"
- : "bg-blue-600 hover:bg-blue-700"
- }`}
- >
- {i + 1}
-
- ))}
-
- Next
-
-
);