diff --git a/.DS_Store b/.DS_Store index 3b497b8c..47a57e45 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/components/Content/Assets/PlanetCharacter.tsx b/components/Content/Assets/PlanetCharacter.tsx new file mode 100644 index 00000000..ca40ec3a --- /dev/null +++ b/components/Content/Assets/PlanetCharacter.tsx @@ -0,0 +1,66 @@ +import React, { useEffect, useState } from 'react'; +import Image from 'next/image'; + +export const RoverCharacter: React.FC<{ position: { x: number; y: number } }> = ({ position }) => { + const [angle, setAngle] = useState(0); + const [direction, setDirection] = useState(1); + + useEffect(() => { + const interval = setInterval(updateAnimation, 50); + return () => clearInterval(interval); + }, []); + + const updateAnimation = () => { + const newAngle = angle + 1 * direction; + if (newAngle >= 10 || newAngle <= -10) { + setDirection(direction * -1); + } + setAngle(newAngle); + }; + + return ( +
+ Character +
+ ); +}; + +export const PlanetCharacter: React.FC<{ position: { x: number; y: number } }> = ({ position }) => { + const [angle, setAngle] = useState(0); + const [direction, setDirection] = useState(1); + + useEffect(() => { + const interval = setInterval(updateAnimation, 50); + return () => clearInterval(interval); + }, []); + + const updateAnimation = () => { + const newAngle = angle + 1 * direction; + if (newAngle >= 10 || newAngle <= -10) { + setDirection(direction * -1); + } + setAngle(newAngle); + }; + + return ( +
+ Character +
+ ); +}; + +export default PlanetCharacter; \ No newline at end of file diff --git a/components/Content/Inventory/UserOwnedItems.tsx b/components/Content/Inventory/UserOwnedItems.tsx index 077e2364..97603429 100644 --- a/components/Content/Inventory/UserOwnedItems.tsx +++ b/components/Content/Inventory/UserOwnedItems.tsx @@ -81,10 +81,80 @@ const OwnedItemsList: React.FC = () => { })} ); - }; +}; export default OwnedItemsList; +interface InventoryItem { + id: number; + name: string; + icon_url: string; + quantity: number; +} + +export const ItemsVerticalList: React.FC = () => { + const session = useSession(); + const [itemDetails, setItemDetails] = useState([]); + const supabase = useSupabaseClient(); + + useEffect(() => { + const fetchOwnedItems = async () => { + try { + if (!session) return; + + const user = session.user.id; + // Fetch owned items from the database + const { data: ownedItemsData, error: ownedItemsError } = await supabase + .from('inventoryUSERS') + .select('*') + .eq('owner', user) + .gt('id', 20); + + if (ownedItemsError) { + throw ownedItemsError; + } + + if (ownedItemsData) { + const itemIds = ownedItemsData.map(item => item.item); + // Fetch details of owned items + const { data: itemDetailsData, error: itemDetailsError } = await supabase + .from('inventoryITEMS') + .select('*') + .in('id', itemIds); + + if (itemDetailsError) { + throw itemDetailsError; + } + + if (itemDetailsData) { + setItemDetails(itemDetailsData); + } + } + } catch (error) { + console.error('Error fetching owned items:', error.message); + } + }; + + fetchOwnedItems(); + }, [session]); + + return ( +
+ {itemDetails.map(item => ( +
+
+
+ {item.name} +
+

{item.name}

+
+

x{item.quantity}

+
+ ))} +
+ ); +}; + export const SectorStructureOwned: React.FC<{ sectorid: string }> = ({ sectorid }) => { const supabase = useSupabaseClient(); const session = useSession(); diff --git a/components/Content/Planets/GalleryList.tsx b/components/Content/Planets/GalleryList.tsx index c83e78f8..6c7792ce 100644 --- a/components/Content/Planets/GalleryList.tsx +++ b/components/Content/Planets/GalleryList.tsx @@ -122,8 +122,8 @@ const PlanetGalleryWithSectors: React.FC = () => { let query = supabase .from('basePlanets') .select('*') - .order('created_at', { ascending: false }) - .limit(200); + .order('created_at', { ascending: true }) + .limit(3); // Set this to be owned planets const { data, error } = await query; @@ -302,12 +302,12 @@ export const Garden: React.FC = ({ onClose }) => {
- + */}
diff --git a/components/Content/Planets/Sectors/Grid.tsx b/components/Content/Planets/Sectors/Grid.tsx new file mode 100644 index 00000000..37aff83f --- /dev/null +++ b/components/Content/Planets/Sectors/Grid.tsx @@ -0,0 +1,67 @@ +import { useSupabaseClient } from "@supabase/auth-helpers-react"; +import Link from "next/link"; +import React, { useEffect, useState } from "react"; + +export default function PublicSectorsGrid() { + const supabase = useSupabaseClient(); + + const [sectors, setSectors] = useState([]); + + async function fetchSectors() { + try { + const { data, error } = await supabase + .from('basePlanetSectors') + .select('*') + .limit(10) + + if (error) { + console.assert('Error fetching sector data: ', error.message); + return; + }; + + setSectors(data); + } catch (error) { + console.error(error); + }; + }; + + useEffect(() => { + fetchSectors(); + }, []) + + return ( + + ); +}; \ No newline at end of file diff --git a/components/Content/Planets/Sectors/SectorSetup.tsx b/components/Content/Planets/Sectors/SectorSetup.tsx index fb6b8d59..44ad81af 100644 --- a/components/Content/Planets/Sectors/SectorSetup.tsx +++ b/components/Content/Planets/Sectors/SectorSetup.tsx @@ -29,7 +29,7 @@ export default function CreateBasePlanetSector() { } } catch (error) { console.error(error.message); - } + }; }; fetchUserPlanet(); diff --git a/components/Content/Populate/StructureCreate.tsx b/components/Content/Populate/StructureCreate.tsx index ba57b20c..bce364e6 100644 --- a/components/Content/Populate/StructureCreate.tsx +++ b/components/Content/Populate/StructureCreate.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react"; import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; import axios from "axios"; import Link from "next/link"; +import { LightkurveBaseGraph } from "../Planets/PlanetData/ContentPlaceholder"; interface Structure { id: number; @@ -162,9 +163,61 @@ interface PlacedStructuresProps { export const PlacedStructures = ({ sectorId }) => { const supabase = useSupabaseClient(); const [placedStructures, setPlacedStructures] = useState([]); + const [usingStructure, setUsingStructure] = useState(null); + + // Planet data + const [planetData, setPlanetData] = useState(null); + + useEffect(() => { + if (sectorId) { + getPlanetData(); + }; + }, [sectorId]); + + const getPlanetData = async () => { + try { + const { data, error } = await supabase + .from('basePlanetSectors') + .select('anomaly') + .eq("id", sectorId); + + if (data) { + setPlanetId(data); + } + + if (error) { + throw error; + } + } catch (error) { + console.error(error.message); + } + try { + const { data, error } = await supabase + .from("basePlanets") + .select("*") + .eq("id", planetId) + .single(); + + if (data) { + setPlanetData(data); + }; + + if (error) { + throw error; + }; + } catch (error: any) { + console.error(error.message); + }; + }; + + const [planetId, setPlanetId] = useState(null); + const handleClosePopup = () => { + setUsingStructure(null); + }; useEffect(() => { const fetchPlacedStructures = async () => { + console.log('Planet id', planetId) try { // Fetch all structure items from inventoryITEMS table const { data: structureItems, error: structureItemsError } = await supabase @@ -223,7 +276,35 @@ export const PlacedStructures = ({ sectorId }) => { {structure.present && ( handleStructureClick(structure.id)}> - View More + {structure.id === 22 && ( +
+ {/*