-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ππ β First part of the new (test) user config created for #26
- Loading branch information
1 parent
7315f94
commit bb76261
Showing
11 changed files
with
116 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<AnomalyContext.Provider value={{ planet }}> | ||
{ children } | ||
</AnomalyContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<UserContextProvider> | ||
<Layout hideNavigation={false}>{/* Should be <ProfileLayout></> */} | ||
<Card noPadding={true}> | ||
<div className="relative overflow-hidden rounded-md"> | ||
<UserCoverImage url={user?.cover} editable={true} onChange={fetchUser()} /> | ||
<div className="absolute top-40 mt-12 left-4 w-full z-20"> | ||
{user && (<PostCardAvatar // Add upload handler from AccountAvatarV1 | ||
url={user?.avatar_url} | ||
size={120} /> )} | ||
</div> | ||
<div className="p-4 pt-0 md:pt-4 pb-0"> | ||
<div className="ml-24 md:ml-40 mt-1"> | ||
<div className="flex ml-0"> {/* Profile Name - Set up styling rule to remove the ml-10 on mobile */}<h1 className="text-3xl font-bold">{user?.full_name}</h1>{/* Only show userma,e on mouseover, along with the address (like a metamask profile view) <p className="@apply text-blue-200 leading-4 mb-2 mt-2">{profile?.username}</p>*/}</div> | ||
<div className="text-gray-500 leading-4 mt-1 ml-0">{user?.location}</div><div className="items-center cursor-pointer absolute right-0 bottom-0 m-2"><label className="flex items-center gap-2 bg-white py-1 px-2 rounded-md shadow-md shadow-black cursor-pointer"> | ||
<input type='file' className='hidden' /> {/* Use this to update location, address (will later be handled by Thirdweb), username, profile pic. Maybe just have a blanket button to include the cover as well */} | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-6 h-6"><path strokeLinecap="round" strokeLinejoin="round" d="M6.827 6.175A2.31 2.31 0 015.186 7.23c-.38.054-.757.112-1.134.175C2.999 7.58 2.25 8.507 2.25 9.574V18a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9.574c0-1.067-.75-1.994-1.802-2.169a47.865 47.865 0 00-1.134-.175 2.31 2.31 0 01-1.64-1.055l-.822-1.316a2.192 2.192 0 00-1.736-1.039 48.774 48.774 0 00-5.232 0 2.192 2.192 0 00-1.736 1.039l-.821 1.316z" /><path strokeLinecap="round" strokeLinejoin="round" d="M16.5 12.75a4.5 4.5 0 11-9 0 4.5 4.5 0 019 0zM18.75 10.5h.008v.008h-.008V10.5z" /></svg>Update profile</label> | ||
</div> | ||
{/*<div className="@apply text-blue-200 leading-4 mb-2 mt-2 ml-10">{profile?.address}{/* | Only show this on mouseover {profile?.username}*/}{/*</div> {/* Profile Location (from styles css) */} | ||
</div> | ||
<ProfileTabs activeTab={tab} userId={user?.id} /> | ||
</div> | ||
</div> | ||
</Card> | ||
<ProfileContent activeTab={tab} userId={userId} /> | ||
</Layout> | ||
</UserContextProvider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from "react"; | ||
import UserPage from "../User"; | ||
|
||
export default function User () { | ||
return <UserPage /> | ||
} |