diff --git a/components/Planets/PlanetCard.tsx b/components/Planets/PlanetCard.tsx index 30c0e716..892515d9 100644 --- a/components/Planets/PlanetCard.tsx +++ b/components/Planets/PlanetCard.tsx @@ -4,6 +4,7 @@ import Card from "../Card"; import { useSupabaseClient } from "@supabase/auth-helpers-react"; import PlanetEditor, { PlanetEditorFromData } from "../../pages/generator/planet-editor"; import StakePlay from "../../pages/stake/play"; +import UtterancesComments from "../Lens/Utterances"; export function PlanetCard ({ activeTab, planetId }) { const supabase = useSupabaseClient(); @@ -26,7 +27,7 @@ export function PlanetCard ({ activeTab, planetId }) { {activeTab === 'refs' && (
Planet Name -
+ )}; {activeTab === 'sandbox' && (
diff --git a/components/PostCard.tsx b/components/PostCard.tsx index 279b7680..9f6bb4f2 100644 --- a/components/PostCard.tsx +++ b/components/PostCard.tsx @@ -7,7 +7,7 @@ import AccountAvatar, { PostCardAvatar } from "./AccountAvatar"; import { Database } from "../utils/database.types"; import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; import { UserContext } from "../context/UserContext"; -import UtterancesComments from "./Lens/Utterances"; +// import UtterancesComments from "./Lens/Utterances"; import en from 'javascript-time-ago/locale/en.json'; import TimeAgo from "javascript-time-ago"; diff --git a/components/Posts/ProfileCard.jsx b/components/Posts/ProfileCard.jsx index a4b6a1e5..ecb182e0 100644 --- a/components/Posts/ProfileCard.jsx +++ b/components/Posts/ProfileCard.jsx @@ -1,5 +1,4 @@ import React, { useEffect, useState } from "react" -import UtterancesComments from "../Lens/Utterances" import Card from "../Card" import FriendInfo from "../FriendInfo" import PostCard from "../PostCard" @@ -59,7 +58,6 @@ export function ProfileContent ({ activeTab, userId }) {

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut doloremque harum maxime mollitia perferendis praesentium quaerat. Adipisci, delectus eum fugiat incidunt iusto molestiae nesciunt odio porro quae quaerat, reprehenderit, sed.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet assumenda error necessitatibus nesciunt quas quidem quisquam reiciendis, similique. Amet consequuntur facilis iste iure minima nisi non praesentium ratione voluptas voluptatem?

-
)} {activeTab === 'friends' && ( diff --git a/components/Posts/ProfileNavigation.tsx b/components/Posts/ProfileNavigation.tsx index 20084e93..76f3097b 100644 --- a/components/Posts/ProfileNavigation.tsx +++ b/components/Posts/ProfileNavigation.tsx @@ -6,7 +6,7 @@ export default function ProfileTabs ({ userId, activeTab }) { return (
- + diff --git a/context/AnomalyContext.js b/context/AnomalyContext.js new file mode 100644 index 00000000..5c35f00e --- /dev/null +++ b/context/AnomalyContext.js @@ -0,0 +1,26 @@ +import { createContext, useEffect, useState } from "react"; +import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; + +export const AnomalyContext = createContext ( { } ); + +export default function AnomalyContextProvider ( { children, planetId } ) { + const session = useSession(); + const supabase = useSupabaseClient(); + const [planet, setAnomaly] = useState(null); + + useEffect(() => { + if (!session?.user?.id) { return; }; + supabase.from('planets') // Change to specific anomaly table + .select() + .eq('id', planetId ) + .then( result => { + setAnomaly ( result.data?.[0] ); + }); + }, [planetId]); + + return ( + + { children } + + ); +}; \ No newline at end of file diff --git a/context/UserContext.js b/context/UserContext.js index b0370a51..45ae0f8d 100644 --- a/context/UserContext.js +++ b/context/UserContext.js @@ -1,16 +1,15 @@ -import {createContext, useEffect, useState} from "react"; -import {useSession, useSupabaseClient} from "@supabase/auth-helpers-react"; +import { createContext, useEffect, useState } from "react"; +import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; export const UserContext = createContext({}); -export function UserContextProvider({children}) { +export function UserContextProvider ( { children } ) { const session = useSession(); const supabase = useSupabaseClient(); const [profile,setProfile] = useState(null); + useEffect(() => { - if (!session?.user?.id) { - return; - } + if (!session?.user?.id) { return; }; supabase.from('profiles') .select() .eq('id', session.user.id) @@ -20,8 +19,8 @@ export function UserContextProvider({children}) { }, [session?.user?.id]); return ( - - {children} + + { children } ); } \ No newline at end of file diff --git a/pages/posts/Profile.tsx b/pages/posts/Profile.tsx index 440c1d71..8145d585 100644 --- a/pages/posts/Profile.tsx +++ b/pages/posts/Profile.tsx @@ -29,9 +29,7 @@ export default function ProfilePage () { const planetId = 'cebdc7a2-d8af-45b3-b37f-80f328ff54d6'; useEffect(() => { - if (!userId) { - return; - } + if (!userId) { return; }; fetchProfile(); fetchPlanet(); }, [userId]); diff --git a/pages/posts/User.tsx b/pages/posts/User.tsx new file mode 100644 index 00000000..3db8e127 --- /dev/null +++ b/pages/posts/User.tsx @@ -0,0 +1,71 @@ +import React, { useState, useEffect } from "react"; +import { useRouter } from "next/router"; + +import Layout from "../../components/Layout"; +import Card from "../../components/Card"; + +import { Database } from "../../utils/database.types"; +import { useSupabaseClient, useSession } from "@supabase/auth-helpers-react"; +//import AnomalyContextProvider from '../../context/AnomalyContext'; +import { UserContext, UserContextProvider } from "../../context/UserContext"; +import { ProfileContent } from "../../components/Posts/ProfileCard"; + +import ProfileTabs from "../../components/Posts/ProfileNavigation"; +import UserCoverImage from "../../components/Cover"; +import { PostCardAvatar } from "../../components/AccountAvatar"; + +type Profiles = Database['public']['Tables']['profiles']['Row']; + +export default function UserPage () { + const supabase = useSupabaseClient(); + const session = useSession(); + const [user, setUser] = useState(null); + + const router = useRouter(); + const tab = router?.query?.tab?.[0] || 'posts'; + const userId = router.query.id; + + useEffect(() => { + if ( !userId ) { return; }; + fetchUser(); + }, [userId]); + + function fetchUser () { + supabase.from('profiles') + .select() + .eq("id", userId) + .then( result => { + if ( result.error ) { throw result.error; }; + if ( result.data ) { setUser ( result.data[0] ); }; + }) + } + + return ( + + {/* Should be */} + +
+ +
+ {user && ( )} +
+
+
+
{/* Profile Name - Set up styling rule to remove the ml-10 on mobile */}

{user?.full_name}

{/* Only show userma,e on mouseover, along with the address (like a metamask profile view)

{profile?.username}

*/}
+
{user?.location}
+
+ {/*
{profile?.address}{/* | Only show this on mouseover {profile?.username}*/}{/*
{/* Profile Location (from styles css) */} +
+ +
+
+
+ +
+
+ ) +} \ No newline at end of file diff --git a/pages/posts/profile/[id].tsx b/pages/posts/profile/[id].tsx index e93bcd68..f79c7c5e 100644 --- a/pages/posts/profile/[id].tsx +++ b/pages/posts/profile/[id].tsx @@ -1,6 +1,5 @@ import ProfilePage from "../Profile"; import React from "react"; -import { useRouter } from "next/router"; export default function Profile () { return diff --git a/pages/posts/profile/[id]/[...tab].tsx b/pages/posts/profile/[id]/[...tab].tsx index c276271e..27435937 100644 --- a/pages/posts/profile/[id]/[...tab].tsx +++ b/pages/posts/profile/[id]/[...tab].tsx @@ -1,4 +1,4 @@ -import ProfilePage from "../../profile"; +import ProfilePage from "../../Profile"; export default function ProfileTab () { return ; diff --git a/pages/posts/user/[id].tsx b/pages/posts/user/[id].tsx new file mode 100644 index 00000000..883bf4c1 --- /dev/null +++ b/pages/posts/user/[id].tsx @@ -0,0 +1,6 @@ +import React from "react"; +import UserPage from "../User"; + +export default function User () { + return +} \ No newline at end of file