diff --git a/src/actions/index.js b/src/actions/index.js index f0fa858..af17cf4 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -66,7 +66,7 @@ export const newBlogPost = (payload) => async (dispatch) => { }; export const newComment = (payload, parent_id) => async (dispatch) => { - const response = await sudoscientist.post('/blog/comments' + parent_id, payload) + const response = await sudoscientist.post('/blog/comments/' + parent_id, payload) if (response.status === 201) { window.location.reload() } diff --git a/src/components/Comments.js b/src/components/Comments.js index 8410f6a..362f232 100644 --- a/src/components/Comments.js +++ b/src/components/Comments.js @@ -1,7 +1,6 @@ import React from 'react'; import ReactMde from "react-mde"; import ReactMarkdown from 'react-markdown'; -import { useSelector } from "react-redux"; import { connect } from 'react-redux'; import 'github-markdown-css' import "react-mde/lib/styles/css/react-mde-all.css" @@ -10,12 +9,11 @@ import { newComment } from '../actions'; const Comment = (props) => { const [content, setContent] = React.useState(""); const [selectedTab, setSelectedTab] = React.useState("write"); - const username = useSelector(state => state.auth.username); const submitComment = () => { const payload = { content: content } - props.newComment(username, payload) + props.newComment(payload, props.post.currentId) } return (
@@ -32,12 +30,16 @@ const Comment = (props) => { Promise.resolve()} />
+
+ +
) } const mapStateToProps = (state) => { return { - user: state.auth + post: state.posts, + user: state.auth, }; } diff --git a/src/components/Post.js b/src/components/Post.js index 42c8f54..1221596 100644 --- a/src/components/Post.js +++ b/src/components/Post.js @@ -5,7 +5,6 @@ import { connect } from 'react-redux'; import { fetchPost,newComment } from '../actions'; import { Link } from 'react-router-dom'; import Comment from './Comments'; -import { useSelector } from "react-redux"; class Post extends React.Component { constructor (props) { @@ -13,8 +12,8 @@ class Post extends React.Component { this.state = { isLoading: true } - console.log(props) } + componentDidMount() { const { slug } = this.props.match.params this.props.fetchPost(slug)