,
- },
- {
- id: 200000015,
- name: "Research Disk Detector project",
- description: "Use your telescope to research the Disk Detector project, where you'll be able to discover early solar systems",
- icon: Shapes,
- color: 'text-purple-300',
- requiredItem: 3103,
- },
-];
-
-const biologistMissions: Mission[] = [
- {
- id: [3000004 | 3000004],
- name: "Classify some animals using your Biodome",
- description: "Click on the 'Biodome' structure to make some classifications",
- icon: TreeDeciduous,
- color: 'text-green-300',
- requiredItem: 3104,
- },
- {
- id: 10001,
- name: "View your discoveries",
- description: "Vote on discoveries made by other players to help classify & audit them",
- icon: LightbulbIcon,
- color: 'text-yellow-300',
- modalContent:
,
- },
-];
-
-const communityExpeditions: Mission[] = [
- {
- id: 3500011,
- name: "Travel to Mars",
- description: "Join the community expedition to Mars, where you'll be able to use your scientific tooling & understanding to build mining settlements & infrastructure",
- icon: Pickaxe,
- color: 'text-red-300',
- modalContent:
,
- },
- {
- id: 3500012,
- name: "Mine some resources",
- description: "Use the rovers you've travelled with to mine some anomalies you and the community have found on Mars. This will allow you to produce some materials & more structures for community use",
- icon: DiamondPercent,
- color: 'text-cyan-300',
- modalContent:
- },
- {
- id: 3500013,
- name: "Return to Earth",
- description: "Complete your mission on Mars and return to Earth to continue your research and exploration with the new resources you've obtained from Mars with the rest of the community",
- icon: Rocket,
- color: 'text-green-300',
- modalContent:
- },
-];
-
-const meteorologyMissions: Mission[] = [
- {
- id: [3000010 | 20000007],
- name: "Study some weather events using your atmospheric probe",
- description: "Click on your Weather Balloon to make some classifications",
- icon: CloudHail,
- color: 'text-blue-300',
- requiredItem: 3105,
- },
- {
- id: 10001,
- name: "View your discoveries",
- description: "Vote on discoveries made by other players to help classify & audit them",
- icon: LightbulbIcon,
- color: 'text-yellow-300',
- modalContent:
,
- },
-];
-
-const globalMissions: Mission[] = [
- {
- id: 3000001,
- name: "Discover a new planet",
- description: "Create and use a telescope to discover a new planet using the Planet Hunters module",
- icon: Telescope,
- color: 'text-purple-300',
- },
- {
- id: 1,
- name: "Continue researching & investigating",
- description: "Keep researching new projects and building new structures, and wait for new missions and expeditions to be added",
- icon: LightbulbIcon,
- color: 'text-yellow-300',
- },
- // {
- // id: 2,
- // name: "Vote & advise other's discoveries",
- // description: "Click on the 'Discoveries' button to view and comment on other player\'s discoveries to determine their accuracy and attributes",
- // icon: LucideTestTubeDiagonal,
- // color: 'text-blue-300',
- // tableEntry: 'comments',
- // tableColumn: 'author',
- // },
- {
- id: 3,
- name: "Add your own data for review",
- description: "Click on the plus icon in the toolbar to add your own files that might be able to be part of a project, adding your own content and creations to our network",
- icon: CameraIcon,
- color: 'text-green-300',
- tableEntry: 'uploads',
- tableColumn: 'author',
- modalContent:
,
- },
- {
- id: 4,
- name: "Vote on planet candidate classifications",
- description: "Other users, or maybe you, have discovered some potential planet candidates. Go to your Telescope structure, click 'View all discoveries', and vote to select which classifications are valid, which in turn will allow anomalies to be added to the ecosystem",
- icon: PersonStandingIcon,
- color: 'text-red-300',
- tableEntry: 'votes',
- tableColumn: 'user_id',
- voteOn: 'planet',
- modalContent:
,
- },
-];
-
-const StructureMissionGuide = () => {
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const { activePlanet } = useActivePlanet();
-
- const [completedMissions, setCompletedMissions] = useState
([]);
- const [loading, setLoading] = useState(true);
- const [currentCategory, setCurrentCategory] = useState(0);
- const [ownedItems, setOwnedItems] = useState([]);
- const [scrollableMissions, setScrollableMissions] = useState([]);
-
- const [hideCompleted, setHideCompleted] = useState(false);
- const [isExpanded, setIsExpanded] = useState(false);
- const toggleHideCompleted = () => {
- setHideCompleted((prev) => !prev);
- };
- const toggleHeight = () => {
- setIsExpanded((prev) => !prev);
- };
-
- const categories = [
- { missions: astronomyMissions, name: 'Astronomer' },
- { missions: biologistMissions, name: 'Biologist' },
- { missions: meteorologyMissions, name: 'Meteorologist' },
- // {
- // missions: communityExpeditions,
- // name: "Community Expeditions",
- // },
- ];
-
- const [selectedMission, setSelectedMission] = useState(null);
-
- const handleMissionClick = (mission: Mission) => {
- setSelectedMission(mission);
- };
-
- const closeModal = () => {
- setSelectedMission(null);
- };
-
- useEffect(() => {
- async function fetchInventoryAndCompletedMissions() {
- if (!session?.user?.id || !activePlanet?.id) return;
-
- try {
- const { data: inventoryData } = await supabase
- .from('inventory')
- .select('item')
- .eq('owner', session.user.id)
- .eq('anomaly', activePlanet.id)
- .in('item', [3103, 3104, 3105]);
-
- const ownedItems = inventoryData ? inventoryData.map((inv: { item: number }) => inv.item) : [];
- setOwnedItems(ownedItems);
-
- const { data: missionData } = await supabase
- .from('missions')
- .select('mission')
- .eq('user', session.user.id);
-
- const completedMissionIds = missionData ? missionData.map((mission: { mission: number }) => mission.mission) : [];
-
- const voteOnMissions = await Promise.all(globalMissions.map(async (mission) => {
- if (mission.voteOn) {
- const { data: specificVotes } = await supabase
- .from('votes')
- .select('*')
- .eq("user_id", session.user.id)
- .eq("classificationtype", mission.voteOn);
-
- if (specificVotes && specificVotes.length > 0) {
-
- if (Array.isArray(mission.id)) {
- completedMissionIds.push(mission.id[0]);
- } else {
- completedMissionIds.push(mission.id);
- }
- }
- }
- }));
-
- const additionalChecks = await Promise.all(globalMissions.map(async (mission) => {
- if (mission.tableEntry && mission.tableColumn) {
- const { data: tableData } = await supabase
- .from(mission.tableEntry)
- .select('*')
- .eq(mission.tableColumn, session.user.id);
-
- if (tableData && tableData.length > 0) {
- if (Array.isArray(mission.id)) {
- completedMissionIds.push(mission.id[0]); // Pushing the first element if mission id is an array
- } else {
- completedMissionIds.push(mission.id);
- }
- }
- }
- }));
-
- setCompletedMissions(completedMissionIds);
- setLoading(false);
- } catch (error) {
- console.error("Error fetching inventory or missions:", error);
- setLoading(false);
- }
- }
-
- fetchInventoryAndCompletedMissions();
- }, [session, activePlanet, supabase]);
-
- const [modalMissionContent, setModalMissionContent] = useState(null);
- const [isModalOpen, setIsModalOpen] = useState(false);
-
- useEffect(() => {
- const currentMissions = categories[currentCategory].missions;
-
- // Filter global missions based on ownership of required items
- const filteredGlobalMissions = globalMissions.filter((mission) => {
- if (mission.requiredItem && !ownedItems.includes(mission.requiredItem)) {
- return false;
- }
- return true;
- });
-
- // Determine missions to display based on the selected category
- const missionsToDisplay = currentCategory === 3
- ? [...currentMissions]
- : [
- ...currentMissions,
- ...filteredGlobalMissions,
- // ...communityExpeditions,
- ];
-
- // Ensure missions are unique by ID
- const uniqueMissions = [
- ...new Map(missionsToDisplay.map((mission) => [Array.isArray(mission.id) ? mission.id[0] : mission.id, mission])).values(),
- ];
-
- // Apply completed missions filter
- const filteredMissions = hideCompleted
- ? uniqueMissions.filter((mission) => {
- const missionId = Array.isArray(mission.id) ? mission.id[0] : mission.id;
- return !completedMissions.includes(missionId);
- })
- : uniqueMissions;
-
- setScrollableMissions(filteredMissions);
- }, [currentCategory, ownedItems, hideCompleted]);
-
- const nextCategory = () => {
- setCurrentCategory((prev) => (prev + 1) % categories.length);
- };
-
- const previousCategory = () => {
- setCurrentCategory((prev) => (prev - 1 + categories.length) % categories.length);
- };
-
- const renderMission = (mission: Mission) => {
- const missionId = Array.isArray(mission.id) ? mission.id[0] : mission.id;
- const isCompleted = completedMissions.includes(missionId);
-
- const handleMissionClick = () => {
- setModalMissionContent(mission.modalContent);
- setIsModalOpen(true);
- };
-
- return (
-
-
-
-
-
- {mission.name}
-
-
- {mission.description}
-
- {mission.modalContent && (
-
Action
- )}
-
-
-
- );
- };
-
- return (
-
-
-
-
-
-
-
-
-
- {hideCompleted ? "Show Completed" : "Hide Completed"}
-
-
{categories[currentCategory].name}
-
- {isExpanded ? "Shrink" : "Expand"}
-
-
-
-
-
-
-
-
- {loading ? (
-
Loading...
- ) : (
- scrollableMissions.map(renderMission)
- )}
-
-
-
-
-
setIsModalOpen(false)}
- content={modalMissionContent}
- />
-
- );
-};
-
-export default StructureMissionGuide;
-
-export const StructureMissionGuideMobile = () => {
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const { activePlanet } = useActivePlanet();
-
- const [completedMissions, setCompletedMissions] = useState([]);
- const [loading, setLoading] = useState(true);
- const [currentCategory, setCurrentCategory] = useState(0);
- const [minimized, setMinimized] = useState(false);
- const [ownedItems, setOwnedItems] = useState([]);
- const [scrollableMissions, setScrollableMissions] = useState([]);
- const [showWelcome, setShowWelcome] = useState(false);
- const [showPopup, setShowPopup] = useState(false);
- const [showModal, setShowModal] = useState(false); // State to manage modal visibility
-
- const categories = [
- { missions: astronomyMissions, name: 'Astronomer' },
- { missions: biologistMissions, name: 'Biologist' },
- { missions: meteorologyMissions, name: 'Meteorologist' },
- // {
- // missions: communityExpeditions,
- // name: "Community Expeditions",
- // },
- ];
-
- useEffect(() => {
- async function fetchInventoryAndCompletedMissions() {
- if (!session?.user?.id || !activePlanet?.id) return;
-
- try {
- const { data: inventoryData, error: inventoryError } = await supabase
- .from('inventory')
- .select('item')
- .eq('owner', session.user.id)
- .eq('anomaly', activePlanet.id)
- .in('item', [3103, 3104, 3105]);
-
- if (inventoryError) throw inventoryError;
-
- const ownedItems = inventoryData.map((inv: { item: number }) => inv.item);
- setOwnedItems(ownedItems);
-
- const { data: missionData, error: missionError } = await supabase
- .from('missions')
- .select('mission')
- .eq('user', session.user.id);
-
- if (missionError) throw missionError;
-
- const completedMissionIds = missionData.map((mission: { mission: number }) => mission.mission);
- setCompletedMissions(completedMissionIds);
-
- if (ownedItems.includes(3103)) {
- setCurrentCategory(0); // Astronomy
- } else if (ownedItems.includes(3104)) {
- setCurrentCategory(1); // Biology
- } else if (ownedItems.includes(3105)) {
- setCurrentCategory(2); // Meteorology
- } else {
- setCurrentCategory(Math.floor(Math.random() * categories.length));
- }
-
- setShowWelcome(completedMissionIds.length === 0);
-
- } catch (error) {
- console.error("Error fetching inventory or missions:", error);
- }
-
- setLoading(false);
- }
-
- fetchInventoryAndCompletedMissions();
- }, [session, activePlanet, supabase]);
-
- useEffect(() => {
- const missionsToDisplay = [
- ...categories[currentCategory].missions, // Category missions
- ...globalMissions, // Global missions
- ];
- setScrollableMissions(missionsToDisplay);
- }, [currentCategory]);
-
- const userHasRequiredItem = (requiredItem?: number) => {
- return requiredItem ? ownedItems.includes(requiredItem) : false;
- };
-
- const renderMission = (mission: Mission) => {
- const missionId = Array.isArray(mission.id) ? mission.id[0] : mission.id;
- const isCompleted = completedMissions.includes(missionId);
-
- return (
-
-
-
-
-
- {mission.name}
-
-
- {mission.description}
-
-
-
-
- );
- };
-
- return (
-
- {minimized ? (
-
setMinimized(false)} className="bg-blue-600 text-white flex items-center space-x-2">
-
- Help
-
- ) : (
-
-
-
- setShowPopup(true)} className="text-gray-300 hover:text-white">
-
-
- setMinimized(true)}
- className="bg-gray-700 text-gray-300 hover:bg-gray-600 px-2 py-1 text-sm"
- >
- Minimize
-
- {/* Expansion Button */}
- setShowModal(true)} // Show modal when clicked
- className="bg-gray-700 text-gray-300 hover:bg-gray-600 p-2"
- >
-
-
-
-
- {showPopup && (
-
-
-
-
Welcome!
- setShowPopup(false)} className="text-gray-400 hover:text-white">
-
-
-
-
- Follow this mission guide for a walkthrough of different projects and actions. Use your research station (Plus icon) to unlock new projects and data sources.
-
-
-
- )}
-
-
-
- Mission Guide for {categories[currentCategory].name} Pathway
-
-
-
-
- setCurrentCategory((currentCategory - 1 + categories.length) % categories.length)}
- className="bg-gray-700 text-gray-300 hover:bg-gray-600 p-2"
- >
-
-
- setCurrentCategory((currentCategory + 1) % categories.length)}
- className="bg-gray-700 text-gray-300 hover:bg-gray-600 p-2"
- >
-
-
-
-
-
- {scrollableMissions.map(renderMission)}
-
-
-
- )}
-
- {/* Modal for expanded view */}
-
- {showModal && ( // Only show modal if showModal state is true
-
-
-
-
Mission Guide
- setShowModal(false)} className="text-gray-400 hover:text-white">
-
-
-
-
- {scrollableMissions.map(renderMission)} {/* Display expanded list of missions */}
-
-
-
- )}
-
-
- );
-};
-
-// Research station - walk the user through this. Then upload data, verify/vet (consensus), then we introduce travel. Add a "close"/swipe-down option so that the tutorial section can be hidden/minimised. Then we go through the guide for the different views....and determine the differentials from Pathway.tsx and this new list
-// As well as researching for other projects/mission modules that aren't in `mission-selector`
-// We'll also need to update this for different planets & chapters
-
-const dialogueSteps: DialogueStep[] = [
-
-];
\ No newline at end of file
diff --git a/components/Projects/(classifications)/Collections/All.tsx b/components/Projects/(classifications)/Collections/All.tsx
deleted file mode 100644
index 83777a98..00000000
--- a/components/Projects/(classifications)/Collections/All.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-'use client';
-
-import React, { useEffect, useState } from 'react';
-import { useSession, useSupabaseClient } from '@supabase/auth-helpers-react';
-import { DiscoveryCardSingle } from './Classification';
-
-export function DiscoveryCards() {
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const [classifications, setClassifications] = useState([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
-
- useEffect(() => {
- const fetchClassifications = async () => {
- if (!session?.user) {
- setError('User session not found.');
- setLoading(false);
- return;
- };
-
- setLoading(true);
- setError(null);
- try {
- const { data, error } = await supabase
- .from('classifications')
- .select('*')
- .eq('author', session.user.id);
-
- if (error) throw error;
-
- setClassifications(data);
- } catch (error) {
- console.error('Error fetching classifications:', error);
- setError('Failed to load classifications.');
- } finally {
- setLoading(false);
- };
- };
-
- fetchClassifications();
- }, [session, supabase]);
-
- if (loading) return Loading...
;
- if (error) return {error}
;
- if (classifications.length === 0) return No classifications found for this user.
;
-
- return (
-
- {classifications.map((classification) => (
-
- ))}
-
- );
-};
\ No newline at end of file
diff --git a/components/Projects/(classifications)/Collections/ByActivePlanet.tsx b/components/Projects/(classifications)/Collections/ByActivePlanet.tsx
deleted file mode 100644
index ff3832f0..00000000
--- a/components/Projects/(classifications)/Collections/ByActivePlanet.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-'use client';
-
-import React, { useEffect, useState } from 'react';
-import { useSupabaseClient } from '@supabase/auth-helpers-react';
-import { DiscoveryCardSingle } from './Classification';
-
-interface DiscoveryCardsByActivePlanetProps {
- activePlanet: number;
-};
-
-export function DiscoveryCardsByActivePlanet({ activePlanet }: DiscoveryCardsByActivePlanetProps) {
- const supabase = useSupabaseClient();
- const [classifications, setClassifications] = useState([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
-
- useEffect(() => {
- const fetchClassifications = async () => {
- setLoading(true);
- setError(null);
- try {
- const { data, error } = await supabase
- .from('classifications')
- .select('id')
- .filter('classificationConfiguration->activePlanet', 'eq', activePlanet);
-
- if (error) throw error;
-
- setClassifications(data);
- } catch (error) {
- console.error('Error fetching classifications:', error);
- setError('Failed to load classifications.');
- } finally {
- setLoading(false);
- }
- };
-
- fetchClassifications();
- }, [activePlanet, supabase]);
-
- if (loading) return Loading...
;
- if (error) return {error}
;
- if (classifications.length === 0) return No classifications found for active planet {activePlanet}.
;
-
- return (
-
- {classifications.map((classification) => (
-
- ))}
-
- );
-}
diff --git a/components/Projects/(classifications)/Collections/ByAnomaly.tsx b/components/Projects/(classifications)/Collections/ByAnomaly.tsx
deleted file mode 100644
index 8f7731dd..00000000
--- a/components/Projects/(classifications)/Collections/ByAnomaly.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-'use client';
-
-import React, { useEffect, useState } from 'react';
-import { useSession, useSupabaseClient } from '@supabase/auth-helpers-react';
-import { DiscoveryCardSingle } from './Classification';
-
-interface DiscoveryCardsByUserAndAnomalyProps {
- anomalyId: number;
-};
-
-export function DiscoveryCardsByUserAndAnomaly({ anomalyId }: DiscoveryCardsByUserAndAnomalyProps) {
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const [classifications, setClassifications] = useState([]);
- const [totalClassifications, setTotalClassifications] = useState(null);
- const [userClassificationsCount, setUserClassificationsCount] = useState(null);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
-
- useEffect(() => {
- const fetchClassifications = async () => {
- setLoading(true);
- setError(null);
-
- // Check if session is available
- if (!session?.user?.id) {
- setError('No user session found.');
- setLoading(false);
- return;
- }
-
- try {
- // Fetch total classifications for this anomaly
- const { count: totalCount, error: totalError } = await supabase
- .from('classifications')
- .select('id', { count: 'exact' })
- .eq('anomaly', anomalyId);
-
- if (totalError) {
- console.error('Error fetching total classifications:', totalError);
- throw totalError;
- };
-
- setTotalClassifications(totalCount);
-
- // Fetch the number of classifications the user has made for this anomaly
- const { count: userCount, error: userError } = await supabase
- .from('classifications')
- .select('id', { count: 'exact' })
- .eq('author', session.user.id)
- .eq('anomaly', anomalyId);
-
- if (userError) {
- console.error('Error fetching user classifications count:', userError);
- throw userError;
- };
-
- setUserClassificationsCount(userCount);
-
- // Fetch the actual classification data for the user
- const { data, error: classificationsError } = await supabase
- .from('classifications')
- .select('id')
- .eq('author', session.user.id)
- .eq('anomaly', anomalyId);
-
- if (classificationsError) {
- console.error('Error fetching classifications data:', classificationsError);
- throw classificationsError;
- }
-
- setClassifications(data);
- } catch (error) {
- console.error('Error fetching classifications:', error);
- setError('Failed to load classifications.');
- } finally {
- setLoading(false);
- }
- };
-
- fetchClassifications();
- }, [anomalyId, supabase, session?.user?.id]);
-
- if (loading) return Loading...
;
- if (error) return {error}
;
-
- return (
-
- {/* Display total classifications and user-specific count */}
-
-
Total classifications for this anomaly: {totalClassifications ?? 'N/A'}
-
Your classifications for this anomaly: {userClassificationsCount ?? 'N/A'}
-
-
- {classifications.length === 0 ? (
-
No classifications found for this anomaly by user
- ) : (
- classifications.map((classification) => (
-
- ))
- )}
-
- );
-};
\ No newline at end of file
diff --git a/components/Projects/(classifications)/Collections/ByClassType.tsx b/components/Projects/(classifications)/Collections/ByClassType.tsx
deleted file mode 100644
index 31e8c9ea..00000000
--- a/components/Projects/(classifications)/Collections/ByClassType.tsx
+++ /dev/null
@@ -1,98 +0,0 @@
-'use client';
-
-import React, { useEffect, useState } from 'react';
-import { useSession, useSupabaseClient } from '@supabase/auth-helpers-react';
-import { DiscoveryCardSingle } from './Classification';
-import { ChevronLeft, ChevronRight } from 'lucide-react';
-
-interface DiscoveryCardsByClassificationTypeProps {
- classificationtype: string;
-};
-
-export function DiscoveryCardsByClassificationType({ classificationtype }: DiscoveryCardsByClassificationTypeProps) {
- const supabase = useSupabaseClient();
- const session = useSession();
-
- const [classifications, setClassifications] = useState([]);
- const [loading, setLoading] = useState(true);
- const [error, setError] = useState(null);
- const [currentIndex, setCurrentIndex] = useState(0);
-
- useEffect(() => {
- const fetchClassifications = async () => {
- setLoading(true);
- setError(null);
- try {
- const { data, error } = await supabase
- .from('classifications')
- .select('*')
- .eq('classificationtype', classificationtype);
-
- if (error) throw error;
-
- setClassifications(data);
- } catch (error) {
- console.error('Error fetching classifications:', error);
- setError('Failed to load classifications.');
- } finally {
- setLoading(false);
- }
- };
-
- if (classificationtype) {
- fetchClassifications();
- }
- }, [classificationtype, supabase]);
-
- const goToNext = () => {
- if (currentIndex < classifications.length - 1) {
- setCurrentIndex(currentIndex + 1);
- }
- };
-
- const goToPrev = () => {
- if (currentIndex > 0) {
- setCurrentIndex(currentIndex - 1);
- }
- };
-
- if (loading) return Loading...
;
- if (error) return {error}
;
- if (classifications.length === 0) return No classifications found for this classification type
;
-
- return (
-
-
- {/* Left Arrow Button */}
-
-
-
-
- {/* Horizontal Scrolling Container */}
-
- {classifications.map((classification, index) => (
-
-
-
- ))}
-
-
- {/* Right Arrow Button */}
-
-
-
-
-
- );
-};
\ No newline at end of file
diff --git a/components/Projects/(classifications)/FormConfigurations.ts b/components/Projects/(classifications)/FormConfigurations.ts
index 29cc0374..2b835eb2 100644
--- a/components/Projects/(classifications)/FormConfigurations.ts
+++ b/components/Projects/(classifications)/FormConfigurations.ts
@@ -18,7 +18,7 @@ export interface ClassificationFormProps {
anomalyId: string;
missionNumber: number;
assetMentioned: string | string[];
- originatingStructure?: number;
+ // structureItemId?: number;
structureItemId?: number;
};
diff --git a/components/Projects/(classifications)/FreeForm.tsx b/components/Projects/(classifications)/FreeForm.tsx
index 8950f201..915e6bf6 100644
--- a/components/Projects/(classifications)/FreeForm.tsx
+++ b/components/Projects/(classifications)/FreeForm.tsx
@@ -4,22 +4,21 @@ import { useEffect, useRef, useState } from 'react';
import useSound from 'use-sound';
import Webcam from "react-webcam";
import { useSupabaseClient, useSession } from '@supabase/auth-helpers-react';
-import { useActivePlanet } from '@/context/ActivePlanet';
+
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
-import { Upload, ChevronRight, Camera } from "lucide-react";
+import { Upload, ChevronRight, Camera } from 'lucide-react';
-const STRUCTURE_OPTIONS: Record = { // Update to add `dataSources...` identifiers
+const STRUCTURE_OPTIONS: Record = {
Telescope: ["Sunspot", "Asteroid", "Planet", "Star", "Nebula", "Crater"],
LIDAR: ["Planetary Cloud", "Neutrino", "Earth Cloud", "Surface"],
Zoodex: ["Bird", "Penguin", "Owl", "Other Animal"],
};
const FreeformUploadData = () => {
- const supabase = useSupabaseClient();
+ const supabase = useSupabaseClient();
const session = useSession();
- const { activePlanet } = useActivePlanet();
const webcamRef = useRef(null);
const [loadingContent, setLoadingContent] = useState(false);
@@ -33,6 +32,7 @@ const FreeformUploadData = () => {
const [anomalyType, setAnomalyType] = useState("");
const [structure, setStructure] = useState("");
const [uploads, setUploads] = useState([]);
+ const [showForm, setShowForm] = useState(false);
const takeScreenshot = async () => {
if (loadingContent || buttonPressed) return;
@@ -46,26 +46,31 @@ const FreeformUploadData = () => {
if (imageSrc) {
const resizedImage = await resizeImage(imageSrc);
setCaptureImage(resizedImage);
+ setShowForm(true);
}
};
const uploadImage = async (e: React.ChangeEvent) => {
- if (loadingContent || buttonPressed) return;
- setButtonPressed(true);
- setTimeout(() => {
- setButtonPressed(false);
- setLoadingContent(true);
- }, 200);
-
- const files = e.target.files;
- if (files && files.length > 0) {
- const file = files[0];
- const reader = new FileReader();
- reader.onloadend = () => {
- setCaptureImage(reader.result as string);
- };
- reader.readAsDataURL(file);
- }
+ if (loadingContent || buttonPressed) return;
+ setButtonPressed(true);
+ setLoadingContent(true);
+
+ const files = e.target.files;
+ if (files && files.length > 0) {
+ const file = files[0];
+ const reader = new FileReader();
+ reader.onloadend = async () => {
+ const resizedImage = await resizeImage(reader.result as string);
+ setCaptureImage(resizedImage);
+ setShowForm(true);
+ setButtonPressed(false);
+ setLoadingContent(false);
+ };
+ reader.readAsDataURL(file);
+ } else {
+ setButtonPressed(false);
+ setLoadingContent(false);
+ }
};
const handleSubmitClassification = async (event: React.FormEvent) => {
@@ -110,7 +115,6 @@ const FreeformUploadData = () => {
.insert({
content: comment || null,
author: session?.user?.id,
- location: activePlanet?.id,
source: 'freeform',
file_url: imageUrl ? imageUrl : null,
configuration: classificationConfiguration,
@@ -120,6 +124,14 @@ const FreeformUploadData = () => {
console.error('Supabase error:', error.message);
} else {
console.log('Classification added successfully', data);
+ // Reset form and go back to camera view
+ setShowForm(false);
+ setCaptureImage(null);
+ setComment("");
+ setCloudName("");
+ setLocation("");
+ setAnomalyType("");
+ setStructure("");
}
} catch (err) {
console.error('Unexpected error during classification insert:', err);
@@ -127,96 +139,99 @@ const FreeformUploadData = () => {
};
return (
-
-
@@ -284,7 +284,7 @@ export const RoverPhoto: React.FC = () => {
anomalyType="roverImg"
missionNumber={13714101}
assetMentioned={rover.avatar_url}
- originatingStructure={rover.id}
+ // structureItemId={rover.id}
structureItemId={3102}
/>
)}
diff --git a/components/Projects/Lidar/Clouds.tsx b/components/Projects/Lidar/Clouds.tsx
index dd15e054..e9582601 100644
--- a/components/Projects/Lidar/Clouds.tsx
+++ b/components/Projects/Lidar/Clouds.tsx
@@ -135,7 +135,7 @@ export function StarterLidar() {
anomalyType="cloud"
missionNumber={100000034}
assetMentioned={imageUrl || ""}
- originatingStructure={3105}
+ structureItemId={3105}
/>
diff --git a/components/Projects/Telescopes/DiskDetector.tsx b/components/Projects/Telescopes/DiskDetector.tsx
index f0fa5c99..9864de0f 100644
--- a/components/Projects/Telescopes/DiskDetector.tsx
+++ b/components/Projects/Telescopes/DiskDetector.tsx
@@ -336,7 +336,7 @@ export function TelescopeDiskDetector() {
anomalyType="DiskDetective"
missionNumber={100000033}
assetMentioned={imageUrl || ""}
- originatingStructure={3103}
+ structureItemId={3103}
/>
) : (
diff --git a/components/Projects/Telescopes/Sunspots.tsx b/components/Projects/Telescopes/Sunspots.tsx
index e007db9d..4ab1588a 100644
--- a/components/Projects/Telescopes/Sunspots.tsx
+++ b/components/Projects/Telescopes/Sunspots.tsx
@@ -279,7 +279,7 @@ export function TelescopeSunspotDetector() {
anomalyType="sunspot"
missionNumber={100000032}
assetMentioned={imageUrl || ""}
- originatingStructure={3103}
+ structureItemId={3103}
/>
diff --git a/components/Projects/Zoodex/burrowingOwls.tsx b/components/Projects/Zoodex/burrowingOwls.tsx
index 6cc6a068..47372b05 100644
--- a/components/Projects/Zoodex/burrowingOwls.tsx
+++ b/components/Projects/Zoodex/burrowingOwls.tsx
@@ -319,7 +319,7 @@ export function BurrowingOwl() {
anomalyType="zoodex-burrowingOwl"
missionNumber={100000035}
assetMentioned={imageUrl || ""}
- originatingStructure={3104}
+ structureItemId={3104}
/>
diff --git a/components/Projects/Zoodex/iguanasFromAbove.tsx b/components/Projects/Zoodex/iguanasFromAbove.tsx
index 19d08350..31c3aa18 100644
--- a/components/Projects/Zoodex/iguanasFromAbove.tsx
+++ b/components/Projects/Zoodex/iguanasFromAbove.tsx
@@ -287,7 +287,7 @@ export function ZoodexIguanas() {
anomalyType="zoodex-iguanasFromAbove"
missionNumber={100000036}
assetMentioned={imageUrl || ''}
- originatingStructure={3104}
+ structureItemId={3104}
/>
diff --git a/components/Projects/Zoodex/penguinWatch.tsx b/components/Projects/Zoodex/penguinWatch.tsx
index e7deecd7..86ae2428 100644
--- a/components/Projects/Zoodex/penguinWatch.tsx
+++ b/components/Projects/Zoodex/penguinWatch.tsx
@@ -264,7 +264,7 @@ export function PenguinWatch() {
anomalyType="zoodex-penguinWatch"
missionNumber={2000000102}
assetMentioned={imageUrl || ""}
- originatingStructure={3104}
+ structureItemId={3104}
/>
diff --git a/components/Projects/Zoodex/planktonPortal.tsx b/components/Projects/Zoodex/planktonPortal.tsx
index 91958c6d..15526880 100644
--- a/components/Projects/Zoodex/planktonPortal.tsx
+++ b/components/Projects/Zoodex/planktonPortal.tsx
@@ -118,7 +118,7 @@ export const PlanktonPortalTutorial: React.FC