diff --git a/components/CommentButton.tsx b/components/CommentButton.tsx index 8780aa4..fa059f0 100644 --- a/components/CommentButton.tsx +++ b/components/CommentButton.tsx @@ -17,7 +17,7 @@ const CommentButton = ({ blog, handleComment }: CommentButtonProps) => { return ( <> -
+
{blogsLength.length > 0 ? blogsLength.length : ""}
diff --git a/components/LikeButton.tsx b/components/LikeButton.tsx index b2ae258..8298257 100644 --- a/components/LikeButton.tsx +++ b/components/LikeButton.tsx @@ -21,6 +21,7 @@ const LikeButton = ({ blog, handleLike }: LikeButtonProps) => { if (!isLiked) { setIsLiked(true); setOptimisticLike(1); + handleLike(blog); } }; @@ -38,13 +39,16 @@ const LikeButton = ({ blog, handleLike }: LikeButtonProps) => { const Icon = isLiked ? AiFillHeart : AiOutlineHeart; return ( -
+
- {blog?.likes.length + optimisticLike} + + {blog?.likes.length + optimisticLike !== 0 ? blog?.likes.length + optimisticLike : null} +
); }; diff --git a/components/PostModal.tsx b/components/PostModal.tsx index d29fb8a..92109cf 100644 --- a/components/PostModal.tsx +++ b/components/PostModal.tsx @@ -1,6 +1,6 @@ "use client"; -import React from "react"; +import React, { useRef } from "react"; import { useState } from "react"; import { useSession } from "next-auth/react"; import { @@ -16,6 +16,8 @@ import { import { CircularProgress } from "@nextui-org/progress"; import toast from "react-hot-toast"; import { PostBlog } from "@/actions/actions"; +import { Smile } from "lucide-react"; +import EmojiPicker from "emoji-picker-react"; const InitialState = { title: "", @@ -32,9 +34,13 @@ interface PostModalProps { } export default function PostModal({ isOpen, onOpenChange, setfunction }: PostModalProps) { + const [isEmojiOpen, setIsEmojiOpen] = useState(false); const [formData, setFormData] = useState(InitialState); const [posting, setPosting] = useState(false); const { data: session } = useSession(); + + const contentRef = useRef(null); + const handleChange = (e: any) => { const { name, value } = e.target; setFormData((prevValue) => ({ ...prevValue, [name]: value })); @@ -55,6 +61,13 @@ export default function PostModal({ isOpen, onOpenChange, setfunction }: PostMod } }; + const handleEmojiClick = (emoji: string) => { + setFormData((prevFormData) => ({ + ...prevFormData, + content: prevFormData.content + emoji, + })); + }; + const resetForm = () => { setFormData(InitialState); }; @@ -75,7 +88,7 @@ export default function PostModal({ isOpen, onOpenChange, setfunction }: PostMod Jot down your thought - +