Skip to content

Commit

Permalink
Merge pull request #150 from Red-Stream-Y3/main
Browse files Browse the repository at this point in the history
pull req to production
  • Loading branch information
JaninduDiz authored May 17, 2023
2 parents 5a9a8c0 + 24f4eba commit 1d591a7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
11 changes: 11 additions & 0 deletions FrontEnd/src/api/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}
};
28 changes: 14 additions & 14 deletions FrontEnd/src/components/blog/PublicBlogCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -59,7 +59,7 @@ const PublicBlogCrad = ({
</div>

<div className="flex justify-end text-white w-full">
{/* <div className="flex items-center mx-2">
<div className="flex items-center mx-2">
<div className="">
{isLogged && (
<button onClick={handleBookmark}>
Expand All @@ -71,7 +71,7 @@ const PublicBlogCrad = ({
</button>
)}
</div>
</div> */}
</div>

<div className="flex items-center mx-2">
<div className="text-xl text-blue-600">
Expand Down
6 changes: 3 additions & 3 deletions FrontEnd/src/pages/blog/MyBlogPosts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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();
Expand All @@ -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);
};
Expand Down

0 comments on commit 1d591a7

Please sign in to comment.