import Head from 'next/head'; import type { Session } from 'next-auth'; import { useSession } from 'next-auth/react'; import { useState } from 'react'; import { Button, HorizontalDivider, TextInput, useToast } from '@tih/ui'; import Container from '~/components/shared/Container'; import { trpc } from '~/utils/trpc'; function SettingsForm({ session, }: Readonly<{ session: Session; }>) { const { showToast } = useToast(); const updateProfileMutation = trpc.useMutation( ['user.settings.profile.update'], { onError: () => { showToast({ subtitle: 'Please check that you are logged in.', title: 'Failed to update profile', variant: 'failure', }); }, onSuccess: () => { showToast({ title: 'Updated profile!', variant: 'success', }); }, }, ); const [name, setName] = useState(session?.user?.name); const [email, setEmail] = useState(session?.user?.email); return (

Settings

This information will be displayed publicly so be careful what you share.

{ event.preventDefault(); updateProfileMutation.mutate({ email: email ? email : undefined, name: name ? name : undefined, }); }}>
setName(val)} />
setEmail(val)} />
{/*
{session?.user?.image ? ( {session?.user?.email ) : ( )}
*/}
); } export default function SettingsPage() { const { data: session, status } = useSession(); const isSessionLoading = status === 'loading'; if (isSessionLoading) { return null; } if (session == null) { return

You are not signed in

; } return ( <> Settings | Tech Interview Handbook ); }