From edb7e689ceaaa695666f3932ef71c83ffab4b047 Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Tue, 20 Feb 2024 12:01:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B3=F0=9F=8D=A8=20=E2=86=9D=20Removing?= =?UTF-8?q?=20most=20mention=20of=20comment=20components=20for=20now=20[?= =?UTF-8?q?=20SGV2-8=20//=20FCDB-6=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Content/ClassificationFeed.tsx | 82 +---------------------- components/Content/DiscussCard.tsx | 44 +----------- 2 files changed, 2 insertions(+), 124 deletions(-) diff --git a/components/Content/ClassificationFeed.tsx b/components/Content/ClassificationFeed.tsx index 2d60098a..c6b75485 100644 --- a/components/Content/ClassificationFeed.tsx +++ b/components/Content/ClassificationFeed.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from "react"; import { useSession, useSupabaseClient, SupabaseClient } from "@supabase/auth-helpers-react"; -import CardForum, { CommentItem, RoverContentCard } from "./DiscussCard"; +import CardForum from "./DiscussCard"; export function ClassificationFeedForIndividualPlanet(planetId, backgroundColorSet) { const supabase: SupabaseClient = useSupabaseClient(); @@ -13,12 +13,6 @@ export function ClassificationFeedForIndividualPlanet(planetId, backgroundColorS useEffect(() => { fetchPosts(); }, []); - - useEffect(() => { - if (planetPosts.length > 0) { - console.log("Comments: ", planetPosts.flatMap((post) => post.comments)); - } - }, []); async function fetchPosts() { try { @@ -73,78 +67,4 @@ export function ClassificationFeedForIndividualPlanet(planetId, backgroundColorS ))} ); -}; - -export function ClassificationFeedForIndividualPlanetDuplicates(planetId) { - const supabase: SupabaseClient = useSupabaseClient(); - const session = useSession(); - - const [posts, setPosts] = useState([]); - // const [profile, setProfile] = useState(null); - const [planetPosts, setPlanetPosts] = useState([]); - - useEffect(() => { - fetchPosts(); - }, []); - - useEffect(() => { - if (planetPosts.length > 0) { - console.log("Comments: ", planetPosts.flatMap((post) => post.comments)); - } - }, []); - - async function fetchPosts() { - try { - const postsResponse = await supabase - .from("posts_duplicates") - .select( - "id, anomaly, content, created_at, planets2, planetsss(id, temperature), profiles(id, avatar_url, full_name, username)" - ) - // .eq('anomaly', planetId) // 'planets2', planetId - .order('created_at', { ascending: false }); - - if (postsResponse.error || !postsResponse.data) { - console.error("Error fetching posts:", postsResponse.error); - return; - } - - const postIds = postsResponse.data.map((post) => post.id); - - const commentsResponse = await supabase - .from("comments") - .select("id, content, created_at, profiles(id, avatar_url, username), post_id") - .in("post_id", postIds) - .order("created_at", { ascending: true }); - - const commentsByPostId = commentsResponse.data.reduce((acc, comment) => { - const postId = comment.post_id; - if (!acc[postId]) { - acc[postId] = []; - } - acc[postId].push(comment); - return acc; - }, {}); - - const postsWithComments = postsResponse.data.map((post) => ({ - ...post, - comments: commentsByPostId[post.id] || [], - })); - - setPosts(postsWithComments); - console.log(posts); - } catch (error) { - console.error("Error fetching posts:", error.message); - } - } - - return ( -
- {posts.map((post) => ( - <> - -

{post.planetId}

- - ))} -
- ); }; \ No newline at end of file diff --git a/components/Content/DiscussCard.tsx b/components/Content/DiscussCard.tsx index 7f7639d4..16ef6ad8 100644 --- a/components/Content/DiscussCard.tsx +++ b/components/Content/DiscussCard.tsx @@ -36,23 +36,6 @@ interface Comment { avatar_url: string; username: string; }; -} - -export const CommentItem: React.FC = ({ id, content, created_at, profiles }) => { - return ( -
-
- - - Test - -
-
{profiles?.username}
-
-
-
{content}
-
- ); }; const CardForum: React.FC = ({ @@ -107,31 +90,6 @@ const CardForum: React.FC = ({ - {/*
- {comments && ( - - )} - - -
- {showComments && comments && comments.length > 0 && ( - -

Comments

- {comments.map((comment) => ( - - ))} -
- )} */}
); @@ -175,7 +133,7 @@ export function RoverContentCard({
- )} {/* Comment/action section */} + )} )