Upload 5.12
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
import { useState } from "react";
|
||||
import blogService from "../services/blogs";
|
||||
import Togglable from "./Togglable";
|
||||
import { useState } from 'react'
|
||||
import blogService from '../services/blogs'
|
||||
import Togglable from './Togglable'
|
||||
|
||||
const Blog = ({ blog, setNotification, removeBlog }) => {
|
||||
const blogStyle = {
|
||||
paddingTop: 10,
|
||||
paddingLeft: 2,
|
||||
border: "solid",
|
||||
border: 'solid',
|
||||
borderWidth: 1,
|
||||
marginBottom: 5,
|
||||
};
|
||||
}
|
||||
|
||||
const [likes, setLikes] = useState(blog.likes);
|
||||
const [likes, setLikes] = useState(blog.likes)
|
||||
|
||||
const handleLike = (blog) => {
|
||||
blog.likes = blog.likes + 1;
|
||||
blog.likes = blog.likes + 1
|
||||
blogService
|
||||
.update(blog.id, blog)
|
||||
.then((returnedBlog) => {
|
||||
setLikes(returnedBlog.likes);
|
||||
setNotification(`You liked ${blog.title}`, "success");
|
||||
setLikes(returnedBlog.likes)
|
||||
setNotification(`You liked ${blog.title}`, 'success')
|
||||
})
|
||||
.catch((error) => {
|
||||
setNotification(`Like failed. Error: ${error}`, "error");
|
||||
});
|
||||
};
|
||||
setNotification(`Like failed. Error: ${error}`, 'error')
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={blogStyle}>
|
||||
@@ -43,7 +43,7 @@ const Blog = ({ blog, setNotification, removeBlog }) => {
|
||||
</Togglable>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default Blog;
|
||||
export default Blog
|
||||
|
||||
Reference in New Issue
Block a user