diff --git a/FrontEnd/src/api/blog.js b/FrontEnd/src/api/blog.js index d5fbbeb..0a02407 100644 --- a/FrontEnd/src/api/blog.js +++ b/FrontEnd/src/api/blog.js @@ -195,4 +195,15 @@ export const getLatestBlogPosts = async () => { console.log(error); return []; } +}; + +// get authors all blogs +export const getAuthorAllBlogs = async (authorId) => { + try { + const response = await axios.get(`/api/blog/author/${authorId}`); + return response.data; + } catch (error) { + console.log(error); + return []; + } }; \ No newline at end of file diff --git a/FrontEnd/src/components/blog/PublicBlogCard.jsx b/FrontEnd/src/components/blog/PublicBlogCard.jsx index d770d51..049f4f6 100644 --- a/FrontEnd/src/components/blog/PublicBlogCard.jsx +++ b/FrontEnd/src/components/blog/PublicBlogCard.jsx @@ -21,20 +21,20 @@ const PublicBlogCrad = ({ handleBookmark, logged, }) => { - // const [isBookmarked, setIsBookmarked] = useState(false); - // const [isLogged, setIsLogged] = useState(false); + const [isBookmarked, setIsBookmarked] = useState(false); + const [isLogged, setIsLogged] = useState(false); - // useEffect(() => { - // if (user && user == bookmarked) { - // setIsBookmarked(true); - // } - // }, [bookmarked, user]); + useEffect(() => { + if (user && user == bookmarked) { + setIsBookmarked(true); + } + }, [bookmarked, user]); - // useEffect(() => { - // if (logged) { - // setIsLogged(true); - // } - // }); + useEffect(() => { + if (logged) { + setIsLogged(true); + } + }); //date formatter function formatDate(dateString) { @@ -59,7 +59,7 @@ const PublicBlogCrad = ({
- {/*
+
{isLogged && ( )}
-
*/} +
diff --git a/FrontEnd/src/pages/blog/MyBlogPosts.jsx b/FrontEnd/src/pages/blog/MyBlogPosts.jsx index 45e6203..d31ea7e 100644 --- a/FrontEnd/src/pages/blog/MyBlogPosts.jsx +++ b/FrontEnd/src/pages/blog/MyBlogPosts.jsx @@ -3,7 +3,7 @@ import React from "react"; import { useParams, Link } from "react-router-dom"; import { useState, useEffect } from "react"; -import { getBlogsByAuthor, deleteBlog } from "../../api/blog"; +import { getAuthorAllBlogs, deleteBlog } from "../../api/blog"; import { BlogContainer, BlogCard } from "../../components"; import { toast } from "react-toastify"; @@ -20,7 +20,7 @@ export default function MyBlogPosts() { useEffect(() => { const fetchBlogsByAuthor = async () => { - const blogs = await getBlogsByAuthor(userID); + const blogs = await getAuthorAllBlogs(userID); setBlogs(blogs); }; fetchBlogsByAuthor(); @@ -29,7 +29,7 @@ export default function MyBlogPosts() { //refresh blog object const refreshFunc = async () => { setLoading(true); - let res = await getBlogsByAuthor(userID); + let res = await getAuthorAllBlogs(userID); setBlogs(res); setLoading(false); };