diff --git a/reddit-front/src/components/Comments/Comments.jsx b/reddit-front/src/components/Comments/Comments.jsx index ca280c1..c90b3eb 100644 --- a/reddit-front/src/components/Comments/Comments.jsx +++ b/reddit-front/src/components/Comments/Comments.jsx @@ -7,7 +7,7 @@ import { Button } from '@mui/material'; import avatarImg from '../../assets/Images/avatar_default_5.png'; import CreatePostEditor from '../../pages/CreatePost/CreatePostEditor'; -export default function Comments() { +export default function Comments({ comment }) { const [replyContnet, setReplyContnet] = useState(''); const [countVotes, setCountVotes] = useState(); const [showReply, setShowReply] = useState(false); @@ -62,7 +62,9 @@ export default function Comments() { alt="avatar" /> -

karim

+

+ {comment.user.username} +

- {/* ffffff *fdfdfdfdf* *rerererer* ~fdsfdfdsfdfd~ `fdfdfdfdfdf` > `fdfsdfdfdfd` > dfsdfsdfdsfd - rerere - gfgfgf - oioioi 1. fdsfdfs diff --git a/reddit-front/src/pages/ModToolsPage/ModToolsPage.jsx b/reddit-front/src/pages/ModToolsPage/ModToolsPage.jsx index 5e054ad..1ae5788 100644 --- a/reddit-front/src/pages/ModToolsPage/ModToolsPage.jsx +++ b/reddit-front/src/pages/ModToolsPage/ModToolsPage.jsx @@ -26,7 +26,7 @@ import Banned from '../../components/Banned/Banned'; import Muted from '../../components/Muted/Muted'; import Approved from '../../components/Approved/Approved'; import Moderators from '../../components/Moderators/Moderators'; -// import ModQueue from '../../components/ModQueue/ModQueue'; +import ModQueue from '../../components/ModQueue/ModQueue'; import FetchUserData from '../../utilities/FetchUserData/FetchUserData'; import { getSubreddit } from '../../services/requests/Subreddit'; import Loader from '../../utilities/Loader/Loader'; @@ -64,7 +64,6 @@ function ModToolsPage() { // Mapping for the components const componentsMap = { - muted: muted, banned: banned, moderators: moderators, @@ -270,7 +269,6 @@ function ModToolsPage() { - {/* User Management */} diff --git a/reddit-front/src/pages/PostFullPage/PostCard/PostContent/PostContent.jsx b/reddit-front/src/pages/PostFullPage/PostCard/PostContent/PostContent.jsx index 17645f9..d21db99 100644 --- a/reddit-front/src/pages/PostFullPage/PostCard/PostContent/PostContent.jsx +++ b/reddit-front/src/pages/PostFullPage/PostCard/PostContent/PostContent.jsx @@ -1,3 +1,4 @@ +/* eslint-disable import/named */ /* eslint-disable no-unneeded-ternary */ /* eslint-disable no-nested-ternary */ /* eslint-disable react/jsx-boolean-value */ @@ -23,7 +24,7 @@ import PostInfo from '../PostInfo/PostInfo'; import './PostContent.css'; import { divideBigNumber, getDateDiff } from '../../../../utilities/Helpers'; -import { flagPostAsVisited } from '../../../../services/requests/Post'; +// import { flagPostAsVisited } from '../../../../services/requests/Post'; /** * @typedef PropType @@ -240,7 +241,6 @@ function PostContent({ postId={postData._id} userInfo={postData.user} subredditInfo={postData.subredditInfo} - postedAt={getDateDiff(postData.publishedDate)} approvedBy={postData.approvedBy} approvedAt={postData.approvedAt} diff --git a/reddit-front/src/pages/PostFullPage/PostFullPage.jsx b/reddit-front/src/pages/PostFullPage/PostFullPage.jsx index a82dca5..4fcf1d8 100644 --- a/reddit-front/src/pages/PostFullPage/PostFullPage.jsx +++ b/reddit-front/src/pages/PostFullPage/PostFullPage.jsx @@ -1,3 +1,8 @@ +/* eslint-disable indent */ +/* eslint-disable react/jsx-indent */ +/* eslint-disable operator-linebreak */ +/* eslint-disable no-underscore-dangle */ +/* eslint-disable no-multiple-empty-lines */ /* eslint-disable no-nested-ternary */ /* eslint-disable no-unused-vars */ /* eslint-disable react/jsx-boolean-value */ @@ -5,8 +10,7 @@ import { useState, useEffect } from 'react'; import { useParams } from 'react-router-dom'; -import { ThemeProvider, Box } from '@mui/material'; - +import { ThemeProvider, Box, Button } from '@mui/material'; import BackToTop from '../../components/BackToTop/BackToTop'; import AppBar from '../../components/Layout/AppBar/AppBar'; @@ -19,6 +23,7 @@ import { subredditTheme } from '../Subreddit/Subreddit.Style'; +import CreatePostEditor from '../CreatePost/CreatePostEditor'; import { SideBarContainer, SideBarContent @@ -29,7 +34,7 @@ import { getPost } from '../../services/requests/Post'; import { getSubreddit } from '../../services/requests/Subreddit'; import Loader from '../../utilities/Loader/Loader'; import Comments from '../../components/Comments/Comments'; - +import { postComment, getComments } from '../../services/requests/comments'; /** * This Component for the Community Cards. @@ -45,10 +50,29 @@ function PostFullPage() { const [loadingSubreddit, setLoadingSubreddit] = useState(true); const [goToErrorPage, setGoToErrorPage] = useState(false); - const [commentContnet, setCommentContnet] = useState(''); - const handleReply = () => {}; + const [comments, setComments] = useState([]); + const handleComment = () => { + postComment({ + parentId: postData._id, + subredditId: subredditData._id, + postId: postData._id, + text: commentContnet + }); + }; + useEffect(() => { + const fetchGetComments = async () => { + const results = await getComments({ id: postData._id }); + setComments(results); + }; + fetchGetComments(); + }, []); + console.log('comments'); + console.log(comments); + console.log('finish'); const handleCloseReply = () => {}; + console.log(postData); + console.log(subredditData); const color = '#ccc'; let subredditId = 1; // for testing only @@ -78,6 +102,15 @@ function PostFullPage() { fetchSubredditInfo(); }, []); + const commentsShow = + comments.length > 0 + ? comments.map((comment) => ( +
+ +
+ )) + : ''; + return ( {!goToErrorPage ? ( @@ -124,29 +157,21 @@ function PostFullPage() { postContent={commentContnet} />
-
- -
-
- -
-
- -
+ {commentsShow} diff --git a/reddit-front/src/services/requests/comments.js b/reddit-front/src/services/requests/comments.js index 641b37c..a2c29ce 100644 --- a/reddit-front/src/services/requests/comments.js +++ b/reddit-front/src/services/requests/comments.js @@ -11,7 +11,7 @@ export const getComments = async (object) => { console.log(object); try { console.log('first'); - const response = await api.get(`/api/comment/${id}`, { + const response = await api.get(`/api/thing/${id}/with-children`, { headers: { Authorization: token } }); console.log('last');