From 2a517ef3adbbae6672f35734b4c99369046d3b0b Mon Sep 17 00:00:00 2001 From: jihye Date: Thu, 9 Dec 2021 17:49:35 +0000 Subject: [PATCH] present user name and profile photo Co-authored-by: moggach <43313455+Moggach@users.noreply.github.com> --- components/Account.js | 84 +++++++++---------------------------------- 1 file changed, 16 insertions(+), 68 deletions(-) diff --git a/components/Account.js b/components/Account.js index b074ad0..061ba92 100644 --- a/components/Account.js +++ b/components/Account.js @@ -3,76 +3,24 @@ import { supabase } from '../utils/supabaseClient'; import Image from 'next/image'; export default function Account({ userProfile, setUserProfile }) { - const [loading, setLoading] = useState(true); - const [email, setEmail] = useState(null); - const [avatar, setAvatar] = useState(null); - const [username, setUsername] = useState(null); - const [loggedinAt, setLoggedinAt] = useState(null); - - // useEffect(() => { - // getProfile(); - // }, []); - - // async function getProfile() { - // try { - // setLoading(true); - // const user = supabase.auth.user(); - - // let { data, error, status } = await supabase - // .from('profiles') - // .select('username, avatar') - // .eq('id', user.id) - // .single(); - - // if (error && status !== 406) { - // throw error; - // } - - // if (data) { - // setUsername(data.username); - // setAvatar(data.avatar); - // } - // } catch (error) { - // alert(error.message); - // } finally { - // setLoading(false); - // } - // } - - // async function updateProfile({ username }) { - // try { - // setLoading(true); - // const user = supabase.auth.user(); - - // const updates = { - // id: profiles.id, - // username, - // }; - - // let { error } = await supabase.from('users').upsert(updates, { - // returning: 'minimal', // Don't return the value after inserting - // }); - - // if (error) { - // throw error; - // } - // } catch (error) { - // alert(error.message); - // } finally { - // setLoading(false); - // } - // } - console.log('userProfile on Account :', userProfile); return ( <> - Hello - {/*
Welcome {username}!
-
You last signed in at
- {/* {username} */} - {/*
- -
*/}{' '} - */ +
+ {userProfile === null ? ( + 'Loding' + ) : ( +
+

Welcome {userProfile.username}

{' '} + {`image + +
+ )} +
); }