Skip to content

Commit

Permalink
present user name and profile photo
Browse files Browse the repository at this point in the history
Co-authored-by: moggach <[email protected]>
  • Loading branch information
jijip41 and Moggach committed Dec 9, 2021
1 parent 25036fe commit 2a517ef
Showing 1 changed file with 16 additions and 68 deletions.
84 changes: 16 additions & 68 deletions components/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
{/* <div>Welcome {username}!</div>
<div>You last signed in at</div>
{/* <Image src={avatar} alt={username} width={500} height={500} /> */}
{/* <div>
<button onClick={() => supabase.auth.signOut()}>Sign Out</button>
</div> */}{' '}
*/
<div>
{userProfile === null ? (
'Loding'
) : (
<div>
<p>Welcome {userProfile.username}</p>{' '}
<Image
src={userProfile.avatar}
alt={`image of ${userProfile.username}`}
width={500}
height={500}
/>
<button onClick={() => supabase.auth.signOut()}>Sign Out</button>
</div>
)}
</div>
</>
);
}

0 comments on commit 2a517ef

Please sign in to comment.