Skip to content

Commit

Permalink
#21 Add comments to post page.
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 27, 2023
1 parent 2737752 commit 83e8183
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/pages/posts/PostPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ import { useParams } from "react-router-dom";
import { axiosReq } from "../../api/axiosDefaults";
import Post from "./Post";

import CommentCreateForm from "../comments/CommentCreateForm";
import { useCurrentUser } from "../../contexts/CurrentUserContext";

function PostPage() {
const { id } = useParams();
const [post, setPost] = useState({ results: [] });

const currentUser = useCurrentUser();
const traveler_image = currentUser?.traveler_image;
const [comments, setComments] = useState({ results: [] });

useEffect(() => {
const handleMount = async () => {
try {
Expand All @@ -32,12 +39,24 @@ function PostPage() {
return (
<Row className="h-100">
<Col className="py-2 p-0 p-lg-2" lg={8}>
<p>Popular profiles for mobile</p>
<p>Popular travelers for mobile</p>
<Post {...post.results[0]} setPosts={setPost} postPage />
<Container className={appStyles.Content}>Comments</Container>
<Container className={appStyles.Content}>
{currentUser ? (
<CommentCreateForm
traveler_id={currentUser.traveler_id}
travelerImage={traveler_image}
post={id}
setPost={setPost}
setComments={setComments}
/>
) : comments.results.length ? (
"Comments"
) : null}
</Container>
</Col>
<Col lg={4} className="d-none d-lg-block p-0 p-lg-2">
Popular profiles for desktop
Popular travelers for desktop
</Col>
</Row>
);
Expand Down

0 comments on commit 83e8183

Please sign in to comment.