-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsignup.js
34 lines (31 loc) · 827 Bytes
/
signup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { useState } from 'react'
import { supabase } from '../supabase-client'
import AuthForm from '../components/auth-form'
import { useRouter } from 'next/dist/client/router'
export default function Signup() {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const router = useRouter()
const submitForm = async (evt) => {
evt.preventDefault()
const { error } = await supabase.auth.signUp({
email,
password,
});
if (!error) {
router.push('/signin')
}
}
return (
<>
<h1>Sign up</h1>
<AuthForm
email={email}
onEmailChange={(evt) => setEmail(evt.target.value)}
password={password}
onPasswordChange={(evt) => setPassword(evt.target.value)}
onSubmit={submitForm}
/>
</>
)
}