Skip to content

Commit

Permalink
#16 Send to edit page when clicking icon
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 27, 2023
1 parent 385a47e commit 3c330bc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/pages/posts/Post.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useEffect} from "react";
import React, { useEffect } from "react";
import { useCurrentUser } from "../../contexts/CurrentUserContext";

import styles from "../../styles/Post.module.css";
Expand All @@ -11,6 +11,7 @@ import OverlayTrigger from "react-bootstrap/OverlayTrigger";
import Tooltip from "react-bootstrap/Tooltip";
import { axiosReq, axiosRes } from "../../api/axiosDefaults";
import { MoreDropdown } from "../../components/MoreDropdown";
import { useHistory } from "react-router-dom/cjs/react-router-dom.min";

const Post = (props) => {
const {
Expand All @@ -29,10 +30,15 @@ const Post = (props) => {
setPosts,
} = props;

console.log(likes_count)
console.log(likes_count);

const currentUser = useCurrentUser();
const is_owner = currentUser?.username === owner;
const history = useHistory();

const handleEdit = () => {
history.push(`/posts/${id}/edit`);
};

const handleLike = async () => {
try {
Expand Down Expand Up @@ -76,7 +82,7 @@ const Post = (props) => {
</Link>
<div className="d-flex align-items-center">
<span>{updated_at}</span>
{is_owner && postPage && <MoreDropdown />}
{is_owner && postPage && <MoreDropdown handleEdit={handleEdit} />}
</div>
</Media>
</Card.Body>
Expand Down

0 comments on commit 3c330bc

Please sign in to comment.