Skip to content

Commit

Permalink
#17 Add handle Delete
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 27, 2023
1 parent 3c330bc commit 35c5829
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pages/posts/Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ const Post = (props) => {
history.push(`/posts/${id}/edit`);
};

const handleDelete = async () => {
try {
await axiosRes.delete(`/posts/${id}/`);
history.goBack();
} catch (err) {
console.log(err);
}
};

const handleLike = async () => {
try {
const { data } = await axiosReq.post("/likes/", { post: id });
Expand Down Expand Up @@ -82,7 +91,12 @@ const Post = (props) => {
</Link>
<div className="d-flex align-items-center">
<span>{updated_at}</span>
{is_owner && postPage && <MoreDropdown handleEdit={handleEdit} />}
{is_owner && postPage && (
<MoreDropdown
handleEdit={handleEdit}
handleDelete={handleDelete}
/>
)}
</div>
</Media>
</Card.Body>
Expand Down

0 comments on commit 35c5829

Please sign in to comment.