import type { ReactElement } from 'react'; import type { GetServerSidePropsContext, InferGetServerSidePropsType } from 'next'; import { useSession, getCsrfToken, signIn } from 'next-auth/react'; import { useRouter } from 'next/router'; import Image from 'next/image'; import toast from 'react-hot-toast'; import { SessionProvider } from 'next-auth/react'; import { useState } from 'react'; import classNames from 'classnames'; import WellKnownURLs from '@components/connection/WellKnownURLs'; const Login = ({ csrfToken }: InferGetServerSidePropsType) => { const router = useRouter(); const { status } = useSession(); const [loading, setLoading] = useState(false); const [email, setEmail] = useState(''); if (status === 'authenticated') { router.push('/admin/connection'); } const onSubmit = async (event: React.FormEvent) => { event.preventDefault(); setLoading(true); const response = await signIn('email', { email, csrfToken, redirect: false, }); setLoading(false); if (!response) { return; } const { error } = response; if (error) { toast.error(error); return; } toast.success('A sign in link has been sent to your email address.'); }; return ( <>
BoxyHQ logo

BoxyHQ Admin UI

Enterprise readiness for B2B SaaS, straight out of the box.

); }; Login.getLayout = function getLayout(page: ReactElement) { return {page}; }; export const getServerSideProps = async (context: GetServerSidePropsContext) => { return { props: { csrfToken: await getCsrfToken(context), }, }; }; export default Login;