import Head from 'next/head'; import Link from 'next/link'; import { useRef } from 'react'; import prisma from '../../lib/prisma'; import Shell from '../../components/Shell'; import SettingsShell from '../../components/Settings'; import { signIn, useSession, getSession } from 'next-auth/client'; export default function Settings(props) { const [ session, loading ] = useSession(); const usernameRef = useRef(); const nameRef = useRef(); const descriptionRef = useRef(); if (loading) { return

Loading...

; } else { if (!session) { window.location.href = "/auth/login"; } } async function updateProfileHandler(event) { event.preventDefault(); const enteredUsername = usernameRef.current.value; const enteredName = nameRef.current.value; const enteredDescription = descriptionRef.current.value; // TODO: Add validation const response = await fetch('/api/user/profile', { method: 'PATCH', body: JSON.stringify({username: enteredUsername, name: enteredName, description: enteredDescription}), headers: { 'Content-Type': 'application/json' } }); console.log(response); } return( Profile | Calendso

Profile

Review and change your public page details.

{window.location.hostname}/
{props.user.avatar && } {!props.user.avatar &&
}

); } export async function getServerSideProps(context) { const session = await getSession(context); const user = await prisma.user.findFirst({ where: { email: session.user.email, }, select: { id: true, username: true, name: true, email: true, bio: true, avatar: true } }); return { props: {user}, // will be passed to the page component as props } }