From f17b253ac6e1f6eb75828166f13d88eb5ccbc443 Mon Sep 17 00:00:00 2001 From: Pete Gerlach Date: Tue, 11 Jun 2024 15:26:49 +0200 Subject: [PATCH] restructured code --- src/api/posts.api.js | 2 +- src/components/Post.js | 9 ++++++--- src/components/PostList.js | 5 ++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/api/posts.api.js b/src/api/posts.api.js index f1f4399..68a5a46 100644 --- a/src/api/posts.api.js +++ b/src/api/posts.api.js @@ -11,7 +11,7 @@ export const postApi = { return (await axios.get(`${path}/${id}`)).data; }, async createNewPost(title, content) { - const location = locationUtils.getCurrentLocation(); + const location = await locationUtils.getCurrentLocation(); if(location.lon && location.lat) { await axios.post(`${path}s`, { "authorID": 1, diff --git a/src/components/Post.js b/src/components/Post.js index 70fd3f9..c4b5f4c 100644 --- a/src/components/Post.js +++ b/src/components/Post.js @@ -2,7 +2,7 @@ import React from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCaretUp, faCaretDown } from '@fortawesome/free-solid-svg-icons'; -const Post = ({ post, upvotePost, downvotePost }) => { +const Post = ({ post, vote }) => { return (
@@ -16,12 +16,15 @@ const Post = ({ post, upvotePost, downvotePost }) => {
{post.reactions.positive - post.reactions.negative} -
diff --git a/src/components/PostList.js b/src/components/PostList.js index d92ae25..5d0d690 100644 --- a/src/components/PostList.js +++ b/src/components/PostList.js @@ -1,15 +1,14 @@ import React from 'react'; import Post from './Post'; -const PostList = ({ posts, upvotePost, downvotePost, onPostClick }) => { +const PostList = ({ posts, vote, onPostClick }) => { return (
{posts.map(post => (
onPostClick(post)}>
))}