diff --git a/src/api/posts.api.js b/src/api/posts.api.js index 68a5a46..6f776b6 100644 --- a/src/api/posts.api.js +++ b/src/api/posts.api.js @@ -10,19 +10,33 @@ export const postApi = { async getPostByID (id) { return (await axios.get(`${path}/${id}`)).data; }, - async createNewPost(title, content) { + async createNewPost(title, content, parent = null) { const location = await locationUtils.getCurrentLocation(); if(location.lon && location.lat) { - await axios.post(`${path}s`, { - "authorID": 1, - "title": title, - "content": content, - "date": Date.now().toString(), - "location": { - "longitude": location.lon, - "latitude": location.lat, - }, - }); + if(parent !== null) { + await axios.post(`${path}s`, { + "authorID": 1, + "title": title, + "content": content, + "date": Date.now().toString(), + "location": { + "longitude": location.lon, + "latitude": location.lat, + }, + "parent": parent + }); + } else { + await axios.post(`${path}s`, { + "authorID": 1, + "title": title, + "content": content, + "date": Date.now().toString(), + "location": { + "longitude": location.lon, + "latitude": location.lat, + } + }); + } } else { console.log("Geolocation is not supported by this browser. Could'nt post without valid location"); } diff --git a/src/components/Post.js b/src/components/PostComment.js similarity index 87% rename from src/components/Post.js rename to src/components/PostComment.js index c4b5f4c..c697e60 100644 --- a/src/components/Post.js +++ b/src/components/PostComment.js @@ -2,13 +2,13 @@ import React from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCaretUp, faCaretDown } from '@fortawesome/free-solid-svg-icons'; -const Post = ({ post, vote }) => { +const PostComment = ({ post, vote, type }) => { return (
{post.content}