diff --git a/components/Content/ClassificationFeed.tsx b/components/Content/ClassificationFeed.tsx
index 7e4e918f..c38a9e20 100644
--- a/components/Content/ClassificationFeed.tsx
+++ b/components/Content/ClassificationFeed.tsx
@@ -80,6 +80,78 @@ export function ClassificationFeedForIndividualPlanet(planetId) {
}
}, []);
+ async function fetchPosts() {
+ try {
+ const postsResponse = await supabase
+ .from("classifications")
+ .select("*")
+ .eq('anomaly', planetId.planetId.id)
+ .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}
+ >
+ ))}
+
+ );
+};
+
+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
diff --git a/components/Content/Classify/AnomalyPostFormCard.tsx b/components/Content/Classify/AnomalyPostFormCard.tsx
index bf4fa1d6..3882bd33 100644
--- a/components/Content/Classify/AnomalyPostFormCard.tsx
+++ b/components/Content/Classify/AnomalyPostFormCard.tsx
@@ -19,6 +19,83 @@ export default function PostFormCardAnomalyTag({ onPost, planetId }) {
// Check if user has items to make post -> not required functionality yet
+ // Create the publication
+ async function createPost() {
+ // Will add an identifier to determine the number of posts mentioning the planet, as that will affect the classification rating
+
+ supabase
+ .from("classifications")
+ .insert({
+ author: profile,
+ content,
+ // media: uploads
+ // planets2: planetId,
+ anomaly: planetId, // Set this to multiple anomaly types/foreign key options
+ }).then(response => {
+ if (!response.error) {
+ alert(`Post ${content} created`);
+ setContent('');
+ // setUploads([]);
+ if ( onPost ) {
+ onPost();
+ }
+ }
+ });
+
+ // .then (update user experience/currency)
+ }
+
+ /* Get user avatar & other data
+ useEffect(() => {
+ supabase
+ .from('profiles')
+ .select(`avatatar_url`)
+ .eq("id", profile)
+ .then((result) => {
+ setAvatarUrl(result?.data[0]?.avatatar_url);
+ });
+ }, [session]); */
+
+ // Function to add media to the publication
+
+ // Frontend output
+ return (
+ <>
+
+ {/*
+
+
*/}
+
+ >
+ )
+}
+
+export function PostFormCardAnomalyTagOldSchema({ onPost, planetId }) {
+ const supabase = useSupabaseClient();
+ const session = useSession();
+
+ const [content, setContent] = useState('');
+ const profile = session?.user?.id;
+ const [avatar_url, setAvatarUrl] = useState(null);
+ /* const [uploads, setUploads] = useState([]);
+ const [isUploading, setIsUploading] = useState(false);
+ const [userExperience, setUserExperience] = useState();
+ const [hasRequiredItem, setHasRequiredItem] = useState(false); */
+
+ const router = useRouter();
+ const anomalytId = router.query.id;
+
+ // Check if user has items to make post -> not required functionality yet
+
// Create the publication
async function createPost() {
// Will add an identifier to determine the number of posts mentioning the planet, as that will affect the classification rating
diff --git a/pages/planets/[id].tsx b/pages/planets/[id].tsx
index ddd27399..dcde7966 100644
--- a/pages/planets/[id].tsx
+++ b/pages/planets/[id].tsx
@@ -54,7 +54,7 @@ export default function PlanetIdPage () {
-
+
);
@@ -71,7 +71,7 @@ export default function PlanetIdPage () {
-
+
);