forked from polka_billy/porridger
@ -1,14 +1,15 @@
|
||||
import { FormEventHandler } from 'react'
|
||||
import { Form, Button, Card, Tabs, Tab } from "react-bootstrap"
|
||||
import { Card, Tabs, Tab } from "react-bootstrap"
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import { useAuth } from "../hooks/api";
|
||||
import { setToken } from "../utils/auth";
|
||||
import { AuthForm } from '../components';
|
||||
|
||||
function LoginPage() {
|
||||
const navigate = useNavigate()
|
||||
|
||||
const { doAuth } = useAuth() // TODO: Add loading and error handling
|
||||
const { doAuth, loading, error } = useAuth()
|
||||
|
||||
const handleAuth = (newAccount: boolean): FormEventHandler<HTMLFormElement> => async (event) => {
|
||||
event.preventDefault();
|
||||
@ -36,57 +37,10 @@ function LoginPage() {
|
||||
<Card.Body>
|
||||
<Tabs defaultActiveKey="register" fill justify className="mb-3">
|
||||
<Tab eventKey="register" title="Регистрация">
|
||||
<Form onSubmit={handleAuth(true)}>
|
||||
<Form.Group className="mb-3" controlId="email">
|
||||
<Form.Label>Почта</Form.Label>
|
||||
<Form.Control type="email" required />
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group className="mb-3" controlId="name">
|
||||
<Form.Label>Имя</Form.Label>
|
||||
<Form.Control type="text" required />
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group className="mb-3" controlId="surname">
|
||||
<Form.Label>Фамилия</Form.Label>
|
||||
<Form.Control type="text" required />
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group className="mb-3" controlId="password">
|
||||
<Form.Label>Пароль</Form.Label>
|
||||
<Form.Control type="password" required />
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group className="mb-3" controlId="privacyPolicyConsent">
|
||||
<Form.Check label="<a>условиями обработки персональных данных</a>">
|
||||
<Form.Check.Input type="checkbox" required />
|
||||
<Form.Check.Label>
|
||||
Я согласен с <a href={`${document.location.origin}/privacy_policy.pdf`} target="_blank" rel="noopener noreferrer">условиями обработки персональных данных</a>
|
||||
</Form.Check.Label>
|
||||
</Form.Check>
|
||||
</Form.Group>
|
||||
|
||||
<Button variant="success" type="submit">
|
||||
Зарегистрироваться
|
||||
</Button>
|
||||
</Form>
|
||||
<AuthForm handleAuth={handleAuth(true)} register={true} loading={loading} error={error} />
|
||||
</Tab>
|
||||
<Tab eventKey="login" title="Вход">
|
||||
<Form onSubmit={handleAuth(false)}>
|
||||
<Form.Group className="mb-3" controlId="email">
|
||||
<Form.Label>Почта</Form.Label>
|
||||
<Form.Control type="email" required />
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group className="mb-3" controlId="password">
|
||||
<Form.Label>Пароль</Form.Label>
|
||||
<Form.Control type="password" required />
|
||||
</Form.Group>
|
||||
|
||||
<Button variant="success" type="submit">
|
||||
Войти
|
||||
</Button>
|
||||
</Form>
|
||||
<AuthForm handleAuth={handleAuth(false)} register={false} loading={loading} error={error} />
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</Card.Body>
|
||||
|
Reference in New Issue
Block a user