forked from polka_billy/porridger
Updated sign up interface
This commit is contained in:
@ -2,8 +2,6 @@ import { FormEventHandler, useCallback } from 'react'
|
||||
import { Button, Form } from 'react-bootstrap'
|
||||
|
||||
import { useSignIn, useSignUp } from '../hooks/api'
|
||||
import { composeSignUpBody } from '../api/signup'
|
||||
import { composeSignInBody } from '../api/token'
|
||||
|
||||
type AuthFormProps = {
|
||||
register: boolean,
|
||||
@ -23,11 +21,11 @@ function AuthForm({ goBack, register }: AuthFormProps) {
|
||||
|
||||
void (async () => {
|
||||
const accountCreated = register ? (
|
||||
await handleSignUp(composeSignUpBody(formData))
|
||||
await handleSignUp(formData)
|
||||
) : true
|
||||
|
||||
if (accountCreated) {
|
||||
if (await handleSignIn(composeSignInBody(formData))) {
|
||||
if (await handleSignIn(formData)) {
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
@ -37,23 +35,11 @@ function AuthForm({ goBack, register }: AuthFormProps) {
|
||||
|
||||
return (
|
||||
<Form onSubmit={handleAuth}>
|
||||
<Form.Group className='mb-3' controlId='email'>
|
||||
<Form.Label>Почта</Form.Label>
|
||||
<Form.Control name='email' type='email' required />
|
||||
<Form.Group className='mb-3' controlId='username'>
|
||||
<Form.Label>Как вас называть?</Form.Label>
|
||||
<Form.Control name='username' type='text' required />
|
||||
</Form.Group>
|
||||
|
||||
{register && <>
|
||||
<Form.Group className='mb-3' controlId='name'>
|
||||
<Form.Label>Имя</Form.Label>
|
||||
<Form.Control name='name' type='text' required />
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group className='mb-3' controlId='surname'>
|
||||
<Form.Label>Фамилия</Form.Label>
|
||||
<Form.Control name='surname' type='text' required />
|
||||
</Form.Group>
|
||||
</>}
|
||||
|
||||
<Form.Group className='mb-3' controlId='password'>
|
||||
<Form.Label>Пароль</Form.Label>
|
||||
<Form.Control name='password' type='password' required />
|
||||
|
Reference in New Issue
Block a user