diff --git a/.DS_Store b/.DS_Store index 9cfc02de..3b497b8c 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/components/Authentication/LoginModal.tsx b/components/Authentication/LoginModal.tsx index b1622c35..a67978f8 100644 --- a/components/Authentication/LoginModal.tsx +++ b/components/Authentication/LoginModal.tsx @@ -1,7 +1,7 @@ import { ReactNode, useEffect } from 'react'; // import { useHistory } from 'react-router-dom'; import Link from 'next/link'; -import Layout from '../../components/Section/Layout'; +import Layout from '../_Core/Section/Layout'; import { Auth, ThemeSupa } from '@supabase/auth-ui-react'; import { useSession, useSupabaseClient } from '@supabase/auth-helpers-react'; import { useRouter } from 'next/router'; diff --git a/components/Content/Archive/ArchivedInventory.tsx b/components/Content/Archive/ArchivedInventory.tsx index 23f94563..4dc64b8b 100644 --- a/components/Content/Archive/ArchivedInventory.tsx +++ b/components/Content/Archive/ArchivedInventory.tsx @@ -1,9 +1,9 @@ import React from "react"; import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; -import Layout from "../../Section/Layout"; +import Layout from "../../_Core/Section/Layout"; import OwnedPlanetsList from "./UserOwnedPlanets"; // Potentially this should be in a lists component dir import OwnedItemsList from "../Inventory/UserOwnedItems"; -import MySpaceships from "../Inventory/Vehicles/MySpaceships"; +import MySpaceships from "../../Gameplay/Vehicles/MySpaceships"; export default function V1Inventory() { // Inventory items for v1 of public schema, see notes below const supabase = useSupabaseClient(); diff --git a/components/Content/ClassificationFeed.tsx b/components/Content/ClassificationFeed.tsx deleted file mode 100644 index 8765a9a9..00000000 --- a/components/Content/ClassificationFeed.tsx +++ /dev/null @@ -1,323 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { useSession, useSupabaseClient, SupabaseClient } from "@supabase/auth-helpers-react"; -import CardForum, { CommentItem, RoverContentCard } from "./DiscussCard"; - -export default function ClassificationFeed({ custommaxWidth = '85%' }) { - const supabase = useSupabaseClient(); - const [posts, setPosts] = useState([]); - - useEffect(() => { - fetchPosts(); - }, []); - - async function fetchPosts() { - try { - const postsResponse = await supabase - .from("basePlanets") - .select( - "id, content, created_at, planets2, planetsss(id, temperature), profiles(id, avatar_url, full_name, username)" - ) - .order('created_at', { ascending: false }); - - const roverImagePostsResponse = await supabase - .from("contentROVERIMAGES") - .select("id, content, created_at") - .order('created_at', { ascending: false }); - - const combinedPosts = [...postsResponse.data, ...roverImagePostsResponse.data]; - - const sortedPosts = combinedPosts.sort((a, b) => - new Date(b.created_at).getTime() - new Date(a.created_at).getTime() - ); - - setPosts(sortedPosts); - } catch (error) { - console.error("Error fetching posts:", error.message); - } - } - - return ( - - ); -} - -export function FactionFeed({ custommaxWidth = '85%', factionId }) { - 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() { - const postsResponse = await supabase - .from("posts_duplicates") - .select( - "id, content, created_at, planets2, faction, planetsss(id, temperature), profiles(id, avatar_url, full_name, username)" - ) - .eq('faction', factionId) - .order('created_at', { ascending: false }); - - 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") // Add the closing parenthesis for profiles select - .in("post_id", postIds) - .order("created_at", { ascending: true }); - - const commentsByPostId: { [postId: number]: Comment[] } = commentsResponse.data.reduce((acc, comment) => { - const postId = comment.post_id; - if (!acc[postId]) { - acc[postId] = []; - } - acc[postId].push(comment); - return acc; - }, {}); - - // const postsWithComments: Post[] = postsResponse.data.map((post) => ({ - const postsWithComments = postsResponse.data.map((post) => ({ - ...post, - comments: commentsByPostId[post.id] || [], - })); - - setPosts(postsWithComments); - } - - return ( - - ); -}; - -export function MultiClassificationFeed({ custommaxWidth = '85%' }) { - const supabase: SupabaseClient = useSupabaseClient(); - const session = useSession(); - - const [posts, setPosts] = useState([]); - const [planetPosts, setPlanetPosts] = useState([]); - - useEffect(() => { - fetchPosts(); - }, []); - - useEffect(() => { - if (planetPosts.length > 0) { - console.log("Comments: ", planetPosts.flatMap((post) => post.comments)); - } - }, []); - - async function fetchPosts() { - const postsResponse = await supabase - .from("posts_duplicates") - .select( - "id, content, created_at, planets2, planetsss(id, temperature), profiles(id, avatar_url, full_name, username)" - ) - .order('created_at', { ascending: false }); - - const roverImagePostsResponse = await supabase - .from("contentROVERIMAGES") - .select("id, content, created_at") - .order('created_at', { ascending: false }); - - const combinedPosts = [...postsResponse.data, ...roverImagePostsResponse.data]; - - const sortedPosts = combinedPosts.sort((a: { created_at: string }, b: { created_at: string }) => - new Date(b.created_at).getTime() - new Date(a.created_at).getTime() - ); - - setPosts(sortedPosts); - } - - return ( - - ); -} - -export function ClassificationFeedForIndividualPlanet(planetId, backgroundColorSet) { - 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("classifications") - // .select("id, content, created_at, author, anomaly, basePlanets, profiles(id, avatar_url, full_name, username)") - .select("id, created_at, content, anomaly, media, profiles(id, avatar_url, full_name, username)") - .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 - .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/Classify/AnomalyPostFormCard.tsx b/components/Content/Classify/AnomalyPostFormCard.tsx index f4f40c7b..f76eab6c 100644 --- a/components/Content/Classify/AnomalyPostFormCard.tsx +++ b/components/Content/Classify/AnomalyPostFormCard.tsx @@ -114,82 +114,5 @@ export default function PostFormCardAnomalyTag({ onPost, planetId }) { - ) -} - -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 - - supabase - .from("posts_duplicates") - .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 ( - <> -
- {/*
- -
*/} -