Skip to content

Commit edb7e68

Browse files
committed
🐳🍨 ↝ Removing most mention of comment components for now [ SGV2-8 // FCDB-6 ]
1 parent d606fc5 commit edb7e68

File tree

2 files changed

+2
-124
lines changed

2 files changed

+2
-124
lines changed
+1-81
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from "react";
22
import { useSession, useSupabaseClient, SupabaseClient } from "@supabase/auth-helpers-react";
3-
import CardForum, { CommentItem, RoverContentCard } from "./DiscussCard";
3+
import CardForum from "./DiscussCard";
44

55
export function ClassificationFeedForIndividualPlanet(planetId, backgroundColorSet) {
66
const supabase: SupabaseClient = useSupabaseClient();
@@ -13,12 +13,6 @@ export function ClassificationFeedForIndividualPlanet(planetId, backgroundColorS
1313
useEffect(() => {
1414
fetchPosts();
1515
}, []);
16-
17-
useEffect(() => {
18-
if (planetPosts.length > 0) {
19-
console.log("Comments: ", planetPosts.flatMap((post) => post.comments));
20-
}
21-
}, []);
2216

2317
async function fetchPosts() {
2418
try {
@@ -73,78 +67,4 @@ export function ClassificationFeedForIndividualPlanet(planetId, backgroundColorS
7367
))}
7468
</div>
7569
);
76-
};
77-
78-
export function ClassificationFeedForIndividualPlanetDuplicates(planetId) {
79-
const supabase: SupabaseClient = useSupabaseClient();
80-
const session = useSession();
81-
82-
const [posts, setPosts] = useState([]);
83-
// const [profile, setProfile] = useState(null);
84-
const [planetPosts, setPlanetPosts] = useState([]);
85-
86-
useEffect(() => {
87-
fetchPosts();
88-
}, []);
89-
90-
useEffect(() => {
91-
if (planetPosts.length > 0) {
92-
console.log("Comments: ", planetPosts.flatMap((post) => post.comments));
93-
}
94-
}, []);
95-
96-
async function fetchPosts() {
97-
try {
98-
const postsResponse = await supabase
99-
.from("posts_duplicates")
100-
.select(
101-
"id, anomaly, content, created_at, planets2, planetsss(id, temperature), profiles(id, avatar_url, full_name, username)"
102-
)
103-
// .eq('anomaly', planetId) // 'planets2', planetId
104-
.order('created_at', { ascending: false });
105-
106-
if (postsResponse.error || !postsResponse.data) {
107-
console.error("Error fetching posts:", postsResponse.error);
108-
return;
109-
}
110-
111-
const postIds = postsResponse.data.map((post) => post.id);
112-
113-
const commentsResponse = await supabase
114-
.from("comments")
115-
.select("id, content, created_at, profiles(id, avatar_url, username), post_id")
116-
.in("post_id", postIds)
117-
.order("created_at", { ascending: true });
118-
119-
const commentsByPostId = commentsResponse.data.reduce((acc, comment) => {
120-
const postId = comment.post_id;
121-
if (!acc[postId]) {
122-
acc[postId] = [];
123-
}
124-
acc[postId].push(comment);
125-
return acc;
126-
}, {});
127-
128-
const postsWithComments = postsResponse.data.map((post) => ({
129-
...post,
130-
comments: commentsByPostId[post.id] || [],
131-
}));
132-
133-
setPosts(postsWithComments);
134-
console.log(posts);
135-
} catch (error) {
136-
console.error("Error fetching posts:", error.message);
137-
}
138-
}
139-
140-
return (
141-
<div className="flex flex-col items-center gap-4 py-2" style={{ maxWidth: '100%', margin: 'auto' }}>
142-
{posts.map((post) => (
143-
<>
144-
<CardForum key={post.id} {...post} />
145-
<p>{post.planetId}</p>
146-
</>
147-
))}
148-
</div>
149-
);
15070
};

components/Content/DiscussCard.tsx

+1-43
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,6 @@ interface Comment {
3636
avatar_url: string;
3737
username: string;
3838
};
39-
}
40-
41-
export const CommentItem: React.FC<Comment> = ({ id, content, created_at, profiles }) => {
42-
return (
43-
<div className="ml-2 my-3">
44-
<div className="flex items-center mb-2">
45-
<Avatar className="rounded-full">
46-
<AvatarImage src={"https://qwbufbmxkjfaikoloudl.supabase.co/storage/v1/object/public/avatars/" + profiles?.avatar_url ?? ""} />
47-
<AvatarFallback>Test</AvatarFallback>
48-
</Avatar>
49-
<div className="flex flex-wrap items-center ml-2">
50-
<div className="font-bold">{profiles?.username}</div>
51-
</div>
52-
</div>
53-
<div className="my-3 text-sm">{content}</div>
54-
</div>
55-
);
5639
};
5740

5841
const CardForum: React.FC<TProps> = ({
@@ -107,31 +90,6 @@ const CardForum: React.FC<TProps> = ({
10790
</CardContent>
10891
<CardFooter className="p-0 flex-col items-start pb-2">
10992
<Separator className="mb-2" />
110-
{/* <div className="space-x-2 px-4 py-2">
111-
{comments && (
112-
<Button onClick={toggleComments} variant="outline" size="default" className="space-x-2">
113-
<MessagesSquare className="w-5 aspect-square" />
114-
</Button>
115-
)}
116-
<Button variant="outline" size="icon">
117-
<Share2 className="w-5 aspect-square" />
118-
</Button>
119-
<Button
120-
onClick={toggleComments}
121-
variant="destructive"
122-
size="icon"
123-
>
124-
<Megaphone className="w-5 aspect-square" />
125-
</Button>
126-
</div>
127-
{showComments && comments && comments.length > 0 && (
128-
<CardContent className="p-4 pt-2">
129-
<h3 className="text-lg font-semibold mb-2">Comments</h3>
130-
{comments.map((comment) => (
131-
<CommentItem key={comment.id} {...comment} />
132-
))}
133-
</CardContent>
134-
)} */}
13593
</CardFooter>
13694
</>
13795
);
@@ -175,7 +133,7 @@ export function RoverContentCard({
175133
<div className="mb-4">
176134
<div key={media}><img src={media} className="w-full h-48 object-cover rounded-md" /></div>
177135
</div>
178-
)} {/* Comment/action section */}
136+
)}
179137
</div>
180138
</div>
181139
)

0 commit comments

Comments
 (0)