Skip to content

Commit

Permalink
# 15 Add basic post
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 24, 2023
1 parent a63533a commit 121f82e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/pages/posts/PostPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,33 @@ import Container from "react-bootstrap/Container";
import appStyles from "../../App.module.css";
import { useParams } from "react-router-dom";
import { axiosReq } from "../../api/axiosDefaults";
import Post from "./Post";

function PostPage() {
const { id } = useParams();
const [post, setPost] = useState({ results: [] });
useEffect(() => {
const handleMount = async () => {
try {
const [{ data: post }] = await Promise.all([
axiosReq.get(`/posts/${id}`),
]);
setPost({ results: [post] });
console.log(post);
} catch (err) {
console.log(err);
}
};
handleMount();
}, [id]);
const { id } = useParams();
const [post, setPost] = useState({ results: [] });

useEffect(() => {
const handleMount = async () => {
try {
const [{ data: post }] = await Promise.all([
axiosReq.get(`/posts/${id}`),
]);
setPost({ results: [post] });
console.log(post);
} catch (err) {
console.log(err);
}
};

handleMount();
}, [id]);

return (
<Row className="h-100">
<Col className="py-2 p-0 p-lg-2" lg={8}>
<p>Popular profiles for mobile</p>
<p>Post component</p>
<Post {...post.results[0]} setPosts={setPost} postPage />
<Container className={appStyles.Content}>Comments</Container>
</Col>
<Col lg={4} className="d-none d-lg-block p-0 p-lg-2">
Expand Down
24 changes: 24 additions & 0 deletions src/styles/Post.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.Post {
background-color: #ffffff;
border: 1px solid #dadadf;
border-radius: 2px;
margin-bottom: 16px;
text-align: center;
}

.Post figure,
h5 {
margin: 0 0;
}

.Heart {
color: #f85032;
}

.Heart:hover {
color: #2142b2;
}

.HeartOutline:hover {
color: #f85032;
}

0 comments on commit 121f82e

Please sign in to comment.