frontend/src/pages/Register/index.tsx
2023-05-22 18:17:01 +03:00

45 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import react from 'react'
import { Block } from '../../elements/Block'
import { Input } from '../../elements/Input'
import './style.css'
import { Button } from '../../elements/Button'
import { register, signin } from '../../client'
import { useNavigate } from "react-router-dom";
const yandexConnect = require('react-yandex-login')
const {YandexLogin, YandexLogout} = yandexConnect;
const clientID = '11e53cfa7add4c55b84168d408a22eb1';
export const Register: react.FC = () => {
const navigate = useNavigate();
const [username, setUseranme] = react.useState('');
const [password, setPassword] = react.useState('');
return <div className='centered'>
<Block className='reg-block'>
<h4>Регистрация</h4>
<Input placeholder='Почта' className='reg-input' onChange={setUseranme}/>
<Input placeholder='Пароль' className='reg-input' onChange={setPassword}/>
<Input placeholder='Пароль еще раз' className='reg-input'/>
<Button className='' onClick={() => {
register(username, password).then((e) => {
signin(username, password).then((e) => {
localStorage.setItem('token', e.access);
navigate('/event-match')
});
});
}}>Зарегистрироваться</Button>
<div className="separator">
<div className="sep-item"></div>
<span>или</span>
<div className="sep-item"></div>
</div>
<YandexLogin clientID={clientID} onSuccess={() => {}}>
<button className="btn-y">Yandex login</button>
</YandexLogin>
</Block>
</div>
}