From d310b01bf1f20b45b2983db961852552064cab69 Mon Sep 17 00:00:00 2001 From: Gizmotronn Date: Thu, 9 Jan 2025 21:22:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=B8=F0=9F=90=BC=20=E2=86=9D=20[SSP-47]?= =?UTF-8?q?:=20Planet=20Ids=20from=20PH=20classifications=20now=20showing?= =?UTF-8?q?=20in=20P4/AI4M=20projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/tests/page.tsx | 2 + components/Projects/Auto/AI4Mars.tsx | 102 +++++++++++++----- components/Projects/Satellite/PlanetFour.tsx | 68 ++++++------ .../SatellitePhotos/AI4M/AIForMars.tsx | 4 +- .../SatellitePhotos/P4/PlanetFour.tsx | 2 +- components/Structures/Missions/PickPlanet.tsx | 12 +-- 6 files changed, 120 insertions(+), 70 deletions(-) diff --git a/app/tests/page.tsx b/app/tests/page.tsx index 349e79ae..31223450 100644 --- a/app/tests/page.tsx +++ b/app/tests/page.tsx @@ -1,11 +1,13 @@ "use client"; +import PlanetFour from "@/components/Structures/Missions/Astronomers/SatellitePhotos/P4/PlanetFour"; import React, { useState } from "react"; export default function TestPage() { return ( // <> + // {/* */} ); diff --git a/components/Projects/Auto/AI4Mars.tsx b/components/Projects/Auto/AI4Mars.tsx index 74eea291..7a092471 100644 --- a/components/Projects/Auto/AI4Mars.tsx +++ b/components/Projects/Auto/AI4Mars.tsx @@ -6,6 +6,7 @@ import { useActivePlanet } from "@/context/ActivePlanet"; import ClassificationForm from "../(classifications)/PostForm"; import { Anomaly } from "../Zoodex/ClassifyOthersAnimals"; import ImageAnnotator from "../(classifications)/Annotating/Annotator"; +import PreferredTerrestrialClassifications from "@/components/Structures/Missions/PickPlanet"; interface Props { anomalyid: number | bigint; @@ -139,12 +140,18 @@ export function StarterAiForMars({ anomalyid }: Props) { )} - + ); }; -export function AiForMarsProject() { +interface SelectedAnomProps { + anomalyid?: number; +}; + +export function AiForMarsProject({ + anomalyid +}: SelectedAnomProps) { const supabase = useSupabaseClient(); const session = useSession(); const { activePlanet } = useActivePlanet(); @@ -183,33 +190,60 @@ export function AiForMarsProject() { checkTutorialMission(); }, [session, supabase]); + const fetchAnomaly = async () => { + if (!session) { + setLoading(false); + return; + }; + + try { + const { data: anomalyData, error: anomalyError } = await supabase + .from("anomalies") + .select("*") + .eq("anomalySet", "automaton-aiForMars"); + + if (anomalyError) throw anomalyError; + + const randomAnomaly = anomalyData[Math.floor(Math.random() * anomalyData.length)] as Anomaly; + setAnomaly(randomAnomaly); + setImageUrl( + `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/telescope/automaton-aiForMars/${randomAnomaly.id}.jpeg` + ); + } catch (error: any) { + console.error("Error fetching anomaly", error.message); + setAnomaly(null); + } finally { + setLoading(false); + }; + }; + useEffect(() => { - async function fetchAnomaly() { - if (!session) { - setLoading(false); - return; - } + // async function fetchAnomaly() { + // if (!session) { + // setLoading(false); + // return; + // }; - try { - const { data: anomalyData, error: anomalyError } = await supabase - .from("anomalies") - .select("*") - .eq("anomalySet", "automaton-aiForMars"); - - if (anomalyError) throw anomalyError; - - const randomAnomaly = anomalyData[Math.floor(Math.random() * anomalyData.length)] as Anomaly; - setAnomaly(randomAnomaly); - setImageUrl( - `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/telescope/automaton-aiForMars/${randomAnomaly.id}.jpeg` - ); - } catch (error: any) { - console.error("Error fetching anomaly", error.message); - setAnomaly(null); - } finally { - setLoading(false); - } - } + // try { + // const { data: anomalyData, error: anomalyError } = await supabase + // .from("anomalies") + // .select("*") + // .eq("anomalySet", "automaton-aiForMars"); + + // if (anomalyError) throw anomalyError; + + // const randomAnomaly = anomalyData[Math.floor(Math.random() * anomalyData.length)] as Anomaly; + // setAnomaly(randomAnomaly); + // setImageUrl( + // `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/telescope/automaton-aiForMars/${randomAnomaly.id}.jpeg` + // ); + // } catch (error: any) { + // console.error("Error fetching anomaly", error.message); + // setAnomaly(null); + // } finally { + // setLoading(false); + // } + // } fetchAnomaly(); }, [session, supabase]); @@ -254,6 +288,7 @@ export function AiForMarsProject() { /> */} )} +

Selected Anomaly ID: {anomalyid}

{imageUrl && ( ) : (
- +
)} - {anomalyid &&

Selected Anomaly: {anomalyid}

} +

Selected Anomaly ID: {anomalyid}

); }; diff --git a/components/Structures/Missions/Astronomers/SatellitePhotos/AI4M/AIForMars.tsx b/components/Structures/Missions/Astronomers/SatellitePhotos/AI4M/AIForMars.tsx index c9f24049..e9b69ec2 100644 --- a/components/Structures/Missions/Astronomers/SatellitePhotos/AI4M/AIForMars.tsx +++ b/components/Structures/Missions/Astronomers/SatellitePhotos/AI4M/AIForMars.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react"; import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react"; import MissionShell from "../../../BasePlate"; import { CloudCogIcon, FolderCog, PaintBucket, Vote } from "lucide-react"; -import { AiForMarsProject } from "@/components/Projects/Auto/AI4Mars"; +import { AI4MWrapper, AiForMarsProject } from "@/components/Projects/Auto/AI4Mars"; import VoteAI4MClassifications from "./AI4MVote"; interface Mission { @@ -40,7 +40,7 @@ const AI4M = () => { icon: CloudCogIcon, points: 2, completedCount: 0, - internalComponent: () => , + internalComponent: () => , color: "text-blue-500", }, { diff --git a/components/Structures/Missions/Astronomers/SatellitePhotos/P4/PlanetFour.tsx b/components/Structures/Missions/Astronomers/SatellitePhotos/P4/PlanetFour.tsx index cfb7abc5..d137de73 100644 --- a/components/Structures/Missions/Astronomers/SatellitePhotos/P4/PlanetFour.tsx +++ b/components/Structures/Missions/Astronomers/SatellitePhotos/P4/PlanetFour.tsx @@ -19,7 +19,7 @@ interface Mission { interface MissionPoints { [key: number]: number; -}; +}; const PlanetFour = () => { const supabase = useSupabaseClient(); diff --git a/components/Structures/Missions/PickPlanet.tsx b/components/Structures/Missions/PickPlanet.tsx index 25a977f1..62b632e8 100644 --- a/components/Structures/Missions/PickPlanet.tsx +++ b/components/Structures/Missions/PickPlanet.tsx @@ -18,7 +18,7 @@ interface Classification { interface PreferredTerrestrialClassificationsProps { onSelectAnomaly: (anomalyId: number | null) => void; - } + }; export default function PreferredTerrestrialClassifications({ onSelectAnomaly, @@ -46,7 +46,7 @@ interface PreferredTerrestrialClassificationsProps { if (classificationIds.length === 0) { setClassifications([]); return; - } + }; const { data: classificationsData, error: classificationsError } = await supabase .from("classifications") @@ -62,8 +62,8 @@ interface PreferredTerrestrialClassificationsProps { images = classification.media.filter((url: any) => typeof url === "string"); } else if (typeof classification.media === "object" && classification.media.uploadUrl) { images.push(classification.media.uploadUrl); - } - } + }; + }; return { ...classification, images }; }); @@ -72,7 +72,7 @@ interface PreferredTerrestrialClassificationsProps { setError("An unexpected error occurred."); } finally { setLoading(false); - } + }; }; useEffect(() => { @@ -98,7 +98,7 @@ interface PreferredTerrestrialClassificationsProps { votes={0} category="Terrestrial" tags={["Preferred", "Planet"]} - images={classification.images || []} + images={classification.media || []} anomalyId={classification.anomaly?.toString() || "N/A"} classificationType="planet" classificationConfig={classification.classificationConfiguration}