Loading...
;
if (error) return
diff --git a/components/Projects/(classifications)/Collections/Classification.tsx b/components/Projects/(classifications)/Collections/Classification.tsx
index ad4417fe..56ad2863 100644
--- a/components/Projects/(classifications)/Collections/Classification.tsx
+++ b/components/Projects/(classifications)/Collections/Classification.tsx
@@ -44,10 +44,6 @@ const generateImagePlaceholder = (name: string) => {
return canvas.toDataURL();
};
-interface DiscoveryCardSingleProps {
- classificationId: number;
-};
-
const extractImageUrls = (media: any): string[] => {
let imageUrls: string[] = [];
@@ -75,21 +71,33 @@ const extractImageUrls = (media: any): string[] => {
export function DiscoveryCardSingle({ classificationId }: DiscoveryCardSingleProps) {
const supabase = useSupabaseClient();
const [classification, setClassification] = useState
(null);
+ const [anomaly, setAnomaly] = useState(null); // For anomaly data
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchClassification = async () => {
setLoading(true);
try {
+ // Fetch classification data along with anomaly data (join anomalies table)
const { data, error } = await supabase
.from('classifications')
- .select('id, content, classificationtype, created_at, media, anomaly, classificationConfiguration')
+ .select('id, content, classificationtype, created_at, media, anomaly, classificationConfiguration, anomalies(avatar_url)')
.eq('id', classificationId)
.single();
if (error) throw error;
setClassification(data);
+ if (data.anomaly) {
+ // Fetch anomaly data separately if needed
+ const { data: anomalyData } = await supabase
+ .from('anomalies')
+ .select('avatar_url')
+ .eq('id', data.anomaly)
+ .single();
+
+ setAnomaly(anomalyData); // Store the anomaly's avatar_url
+ }
} catch (error) {
console.error('Error fetching classification:', error);
} finally {
@@ -103,9 +111,9 @@ export function DiscoveryCardSingle({ classificationId }: DiscoveryCardSinglePro
if (loading) return Loading...
;
if (!classification) return No classification found.
;
- const { content, classificationtype, created_at, media, anomaly, classificationConfiguration } = classification;
+ const { content, classificationtype, created_at, media, classificationConfiguration } = classification;
const discoveredOn = new Date(created_at).toLocaleDateString();
- const parentAnomaly = anomaly ? `Anomaly ID: ${anomaly}` : 'Earth';
+ const parentAnomaly = classification.anomaly ? `Anomaly ID: ${classification.anomaly}` : 'Earth';
// Extract URLs from the media column
const imageUrls = extractImageUrls(media);
@@ -137,6 +145,19 @@ export function DiscoveryCardSingle({ classificationId }: DiscoveryCardSinglePro
Parent Anomaly: {parentAnomaly}
+
+ {/* Display Anomaly Avatar if available */}
+ {anomaly?.avatar_url && (
+
Classification Configuration:
{JSON.stringify(classificationConfiguration, null, 2)}
@@ -158,9 +179,4 @@ export function DiscoveryCardSingle({ classificationId }: DiscoveryCardSinglePro
);
-};
-
-
-interface ClassificationConfiguration {
- [key: string]: string | number | boolean;
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/content/Starnet/YourClassifications.tsx b/content/Starnet/YourClassifications.tsx
index 6ad785c5..7691e729 100644
--- a/content/Starnet/YourClassifications.tsx
+++ b/content/Starnet/YourClassifications.tsx
@@ -1,11 +1,15 @@
-"use client";
+'use client';
-import React, { useState } from "react";
-import { DiscoveryCards } from "@/components/Projects/(classifications)/Collections/All";
-import { DiscoveryCardsByActivePlanet } from "@/components/Projects/(classifications)/Collections/ByActivePlanet";
-import { DiscoveryCardsByUserAndAnomaly } from "@/components/Projects/(classifications)/Collections/ByAnomaly";
+import React, { useState, useEffect } from 'react';
+import { useSupabaseClient } from '@supabase/auth-helpers-react';
+import { DiscoveryCardsByClassificationType } from '@/components/Projects/(classifications)/Collections/ByClassType';
+import { DiscoveryCardsByUserAndAnomaly } from '@/components/Projects/(classifications)/Collections/ByAnomaly';
export default function AllClassifications() {
+ const supabase = useSupabaseClient();
+ const [classificationTypes, setClassificationTypes] = useState
([]);
+ const [selectedType, setSelectedType] = useState('');
+
const [activePlanet, setActivePlanet] = useState(null);
const [anomalyId, setAnomalyId] = useState(null);
@@ -17,27 +21,55 @@ export default function AllClassifications() {
setAnomalyId(Number(e.target.value));
};
+ useEffect(() => {
+ const fetchClassificationTypes = async () => {
+ try {
+ const { data, error } = await supabase
+ .from('classifications')
+ .select('classificationtype') // Select classificationtype column
+ .neq('classificationtype', null); // Exclude null values
+
+ if (error) throw error;
+
+ // Remove duplicates manually by using Set
+ const uniqueTypes = Array.from(new Set(data.map((row: { classificationtype: string }) => row.classificationtype)));
+ setClassificationTypes(uniqueTypes);
+ } catch (error) {
+ console.error('Error fetching classification types:', error);
+ }
+ };
+
+ fetchClassificationTypes();
+ }, [supabase]);
+
+ const handleTypeChange = (e: React.ChangeEvent) => {
+ setSelectedType(e.target.value);
+ };
+
return (
-
-
-
Select Active Planet
+ Select Classification Type
- {activePlanet !== null && (
-
+ {selectedType && (
+
)}
-
*/}
);
-}
\ No newline at end of file
+};
\ No newline at end of file