From 76d96b0f1a44348a0825ccce566ea2917d413e1e Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Mon, 23 Oct 2023 14:51:41 +1100 Subject: [PATCH 01/24] =?UTF-8?q?=F0=9F=90=AD=F0=9F=8F=9F=EF=B8=8F=20?= =?UTF-8?q?=E2=86=9D=20Sector=20data=20now=20visible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Planets/IndividualPlanet.tsx | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/components/Content/Planets/IndividualPlanet.tsx b/components/Content/Planets/IndividualPlanet.tsx index 76035b4d..6483efa5 100644 --- a/components/Content/Planets/IndividualPlanet.tsx +++ b/components/Content/Planets/IndividualPlanet.tsx @@ -50,11 +50,10 @@ export default function IndividualPlanet({ id }: { id: string }) { if (planetId) { getPlanetData(); fetchPostsForPlanet(id); - // fetchSectorsForPlanet(inventoryPlanetId); - fetchSectorsForPlanetTest(); + fetchSectorsForPlanet(); checkUserInventory(); } - }); + }, [session]); const getPlanetData = async () => { try { @@ -126,29 +125,13 @@ export default function IndividualPlanet({ id }: { id: string }) { }; }; - async function fetchSectorsForPlanet(planetId: string) { + async function fetchSectorsForPlanet() { try { const { data, error } = await supabase .from('planetsssSECTORS') .select('*') - .eq('planetId', inventoryPlanetId); - if (error) { - console.error('Error fetching sectors data:', error.message); - return; - }; - - setSectors(data); - } catch (error) { - console.error(error); - }; - }; - - async function fetchSectorsForPlanetTest() { - try { - const { data, error } = await supabase - .from('planetsssSECTORS') - .select('*') + setSectors(data); if (error) { console.error('Error fetching sectors data:', error.message); @@ -239,7 +222,7 @@ export default function IndividualPlanet({ id }: { id: string }) { {hasPlanetInInventory && (<>

{inventoryPlanetId}

- {/* */} + )} From f3872cb07aadc8a9f0e352c8f1b1632700425030 Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Wed, 18 Oct 2023 20:14:58 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=F0=9F=91=9A=F0=9F=8E=A4=20=E2=86=9D=20Ne?= =?UTF-8?q?w=20sidebar=20wip=20hm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Content/Planets/CreatePlanetSector.tsx | 18 +++ components/Section/Layout.tsx | 21 +-- components/Section/Sidebar.tsx | 133 +++++++++++++++++- 3 files changed, 157 insertions(+), 15 deletions(-) create mode 100644 components/Content/Planets/CreatePlanetSector.tsx diff --git a/components/Content/Planets/CreatePlanetSector.tsx b/components/Content/Planets/CreatePlanetSector.tsx new file mode 100644 index 00000000..41519088 --- /dev/null +++ b/components/Content/Planets/CreatePlanetSector.tsx @@ -0,0 +1,18 @@ +import React, { useEffect, useState } from "react"; +import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react"; + +function CreatePlanetSectorComponent ({ planetId }) { + const supabase = useSupabaseClient(); + const session = useSession(); + + const [isLoading, setIsLoading] = useState(false); + + const createSector = () => { + if (!session) { return; }; + + if (!planetId) { return; }; + + // Generate random mineral deposits - will later be set in db + const depsitCount = Math.floor(Math.random() * 5); + } +} \ No newline at end of file diff --git a/components/Section/Layout.tsx b/components/Section/Layout.tsx index f3fab0fc..1dabdde1 100644 --- a/components/Section/Layout.tsx +++ b/components/Section/Layout.tsx @@ -1,4 +1,4 @@ -import Sidebar from "./Sidebar"; +import Sidebar, { DesktopSidebar } from "./Sidebar"; import Navbar from "./Navbar"; import React, { ReactNode, useEffect, useState } from "react"; import Bottombar from "../Core/BottomBar"; @@ -26,16 +26,17 @@ const Layout: React.FC = ({ children }) => { return ( <> - -
- -
{children}
- {isMobile && ( -
- -
- )} + {/* Navbar component goes here */} +
+ +
{children}
+ {isMobile && ( +
+
{children}
+ +
+ )} ); }; diff --git a/components/Section/Sidebar.tsx b/components/Section/Sidebar.tsx index 36c4cb16..93b2669f 100644 --- a/components/Section/Sidebar.tsx +++ b/components/Section/Sidebar.tsx @@ -80,7 +80,7 @@ const Sidebar: React.FC = () => { >

- Kategori Diskusi + Components

    {navCategoryItems.map((item, idx) => ( @@ -89,7 +89,7 @@ const Sidebar: React.FC = () => {

- Pengaturan + Your stuff

    {navSettingItems.map((item, idx) => ( @@ -122,7 +122,7 @@ const Sidebar: React.FC = () => { onClick={() => setOpenAside(false)} > - Tutup Menu + Menu
@@ -132,11 +132,134 @@ const Sidebar: React.FC = () => { className="w-full flex items-center justify-start space-x-2" > - Buka Menu + Menu
); }; -export default Sidebar; \ No newline at end of file +export default Sidebar; + +export function DesktopSidebar () { + return ( +
+
+
+
Star Sailors Alpha 0.2.1
+
+ +
+
+); +}; \ No newline at end of file From a8966440c146449a26bcf2cb57b29015bd08ae4d Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Tue, 17 Oct 2023 16:58:15 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=F0=9F=8C=8C=F0=9F=92=BE=20=E2=86=9D=20Ne?= =?UTF-8?q?w=20ring=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Planets/Base/IndividualBasePlanet.tsx | 228 ++++++++++++++++++ components/Section/Layout.tsx | 6 +- components/Section/Sidebar.tsx | 28 +-- pages/planets/[id].tsx | 4 +- public/assets/governance/dashboard.svg | 8 +- public/assets/governance/payment.svg | 2 +- public/assets/governance/search.svg | 2 +- public/assets/ui/planet.svg | 2 +- 8 files changed, 256 insertions(+), 24 deletions(-) create mode 100644 components/Content/Planets/Base/IndividualBasePlanet.tsx diff --git a/components/Content/Planets/Base/IndividualBasePlanet.tsx b/components/Content/Planets/Base/IndividualBasePlanet.tsx new file mode 100644 index 00000000..f4bd3f55 --- /dev/null +++ b/components/Content/Planets/Base/IndividualBasePlanet.tsx @@ -0,0 +1,228 @@ +import React, { useState, useEffect } from "react"; +import { useRouter } from "next/router"; +import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react"; +import { LayoutNoNav } from "../../../Section/Layout"; + +export default function IndividualBasePlanet({ id }: { id: string }) { + const router = useRouter(); + + const supabase = useSupabaseClient(); + const session = useSession(); + + const [planetData, setPlanetData] = useState(null); + const [planetPosts, setPlanetPosts] = useState([]); + const { id: planetId } = router.query; + const [hasPlanetInInventory, setHasPlanetInInventory] = useState(false); + const [inventoryPlanetId, setInventoryPlanetId] = useState( + null + ); + const [sectors, setSectors] = useState([]); + + const [screenWidth, setScreenWidth] = useState(0); + const [showSidebar, setShowSidebar] = useState(true); + + useEffect(() => { + const handleResize = () => { + setScreenWidth(window.innerWidth); + }; + handleResize(); + window.addEventListener("resize", handleResize); + return () => { + window.removeEventListener("resize", handleResize); + }; + }, []); + + useEffect(() => { + setShowSidebar(screenWidth >= 800); + }, [screenWidth]); + + useEffect(() => { + if (planetId) { + getPlanetData(); + fetchPostsForPlanet(id); + // fetchSectorsForPlanet(); + checkUserInventory(); + } + }, [session]); + + const getPlanetData = async () => { + 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); + } + }; + + async function fetchPostsForPlanet(planetId) { + try { + const { data: postsData, error: postsError } = await supabase + .from("posts_duplicates") + .select( + "id, content, created_at, media, profiles(id, avatar_url, username)" + ) + .eq("planets2", planetId) + .order("created_at", { ascending: false }); + + if (postsData) { + setPlanetPosts(postsData); + } + + if (postsError) { + throw postsError; + } + } catch (error: any) { + console.error("Error fetching posts:", error.message); + } + } + + if (!planetData) { + return
Loading...
; + } + + const { content, avatar_url, type, deepnote, cover } = planetData; + + async function checkUserInventory() { + if (!session || !planetId) { + return; + } + + const { data, error } = await supabase + .from("inventoryPLANETS") + .select() + .eq("planet_id", planetId) + .eq("owner_id", session?.user?.id); + + if (error) { + console.error("Error checking user inventory:", error); + return; + } + + if (data.length > 0) { + setHasPlanetInInventory(true); + setInventoryPlanetId(data[0].id); + } + } + +// async function fetchSectorsForPlanet() { +// try { +// const { data, error } = await supabase +// .from("basePlanetsSECTORS") +// .select("*"); + +// setSectors(data); + +// if (error) { +// console.error("Error fetching sectors data:", error.message); +// return; +// } + +// setSectors(data); +// console.log(data); +// } catch (error) { +// console.error(error); +// } +// } + + const rings = [2, 3, 4]; + const planetSizeMobile = 8; // 8% of the screen size + const planetSizeDesktop = 14; // 14% of the screen size + const ringSizeFactor = 2.12; // Start rings around 2 times the size of the planet image + const ringCount = 3; // Number of rings + + return ( + +
+ {/* Background Styles */} + +
+
+ {/* {planetPosts?.length > 0 && + planetPosts.map((post) => ( + + ))} */} + + {/* Rings */} + {[...Array(ringCount)].map((_, index) => ( +
+ +
+ ))} + + {/* Planet Image */} + Planet Image +
+

{type}

+
+