diff --git a/client/src/api/commments.api.js b/client/src/api/commments.api.js new file mode 100644 index 0000000..1c2276f --- /dev/null +++ b/client/src/api/commments.api.js @@ -0,0 +1,25 @@ +import axiosInstance from "./axiosInstance" + +export const getAllComments = async (reviewId) => { + const res = await axiosInstance.get(`/${reviewId}/comments`); + return res.data; +}; + +export const postComment = async (reviewId, comment) => { + const res = axiosInstance.post(`/${reviewId}/comments`, { + comment: comment + }); + return res; +}; + +export const updateComment = async (reviewId, commentId, updatedComment) => { + const res = axiosInstance.patch(`/${reviewId}/comments/${commentId}`, { + comment: updatedComment + }); + return res; +}; + +export const deleteComment = async (reviewId, commentId) => { + const res = axiosInstance.delete(`/${reviewId}/comments/${commentId}`); + return res; +}; \ No newline at end of file diff --git a/client/src/api/userFollows.api.js b/client/src/api/userFollows.api.js new file mode 100644 index 0000000..a5881f2 --- /dev/null +++ b/client/src/api/userFollows.api.js @@ -0,0 +1,6 @@ +import axiosInstance from "./axiosInstance"; + +export const followUser = async (followingId) => { + const res = await axiosInstance.post('/me/follow', { followingId }); + return res; +} \ No newline at end of file diff --git a/client/src/components/Tabs.jsx b/client/src/components/Tabs.jsx index 69fc474..cd916fb 100644 --- a/client/src/components/Tabs.jsx +++ b/client/src/components/Tabs.jsx @@ -3,11 +3,10 @@ import { motion, AnimatePresence } from "framer-motion"; import ReviewCard from "./ui/ReviewCard"; import defaultPfp from "../assets/default-pfp.jpg"; import { getMyReviews, getUserReviews } from "../api/reviews.api"; -import MovieCard from "./ui/MovieCard"; import HistoryTab from "./HistoryTab"; import Loader from "./ui/Loader"; -export default function Tabs({ profileData, isMyProfile }) { +export default function Tabs({ profileData, isMyProfile, onReplyClick }) { const [activeTab, setActiveTab] = useState("reviews"); const [tabContent, setTabContent] = useState(null); const [loading, setLoading] = useState(false); @@ -111,6 +110,7 @@ export default function Tabs({ profileData, isMyProfile }) { reviewText={r?.review} reviewLikes={r?.likedBy} rating={r?.rating} + onReplyClick={() => onReplyClick(r)} /> )) ) : ( diff --git a/client/src/components/ui/ReviewCard.jsx b/client/src/components/ui/ReviewCard.jsx index fd1056b..081de85 100644 --- a/client/src/components/ui/ReviewCard.jsx +++ b/client/src/components/ui/ReviewCard.jsx @@ -1,5 +1,4 @@ import { useState } from "react"; -import axios from "axios"; import useUserStore from "../../store/userStore"; import { toggleLikeReview } from "../../api/reviews.api"; @@ -19,6 +18,7 @@ export default function ReviewCard({ releaseYear, imdbRating, genres, + onReplyClick }) { const [isLiked, setIsLiked] = useState( Array.isArray(reviewLikes) @@ -179,7 +179,9 @@ export default function ReviewCard({ {formattedLikes} - + !following ? ( + + ) : ( + + ) ) : ( )} - {/* DROPDOWN CONTAINER */} + {/* Dropdown */}
- +
+ {/* Comments Modal */} + +
+ +
+

+ Discussion +

+

+ Responses +

+
+ +
+ {comments?.length > 0 ? ( + comments.map((c) => ( +
+ +
+
+
+

{profileData?.user.firstName} {profileData?.user.lastName}

+ {new Date(c.createdAt).toLocaleString()} + + {isMyProfile && +
+ + + +
+ + +
+
+
+ } +
+

{c.comment}

+
+
+ + +
+
+
+ )) + ) : ( +
+

No thoughts shared yet. Be the first to break the silence.

+
+ )} +
+ +
+
+ +