From ca9d842c875c8867aca8ec7c5f533bde1be3f975 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Sat, 8 May 2021 18:20:48 +0530 Subject: Added Registration form --- modern/src/LoginPage.js | 118 +++--------------------------------------------- 1 file changed, 6 insertions(+), 112 deletions(-) (limited to 'modern/src/LoginPage.js') diff --git a/modern/src/LoginPage.js b/modern/src/LoginPage.js index 30275e51..3d4b17f4 100644 --- a/modern/src/LoginPage.js +++ b/modern/src/LoginPage.js @@ -1,14 +1,8 @@ import React, { useState } from 'react'; -import { useDispatch } from 'react-redux'; -import { useHistory } from 'react-router-dom'; -import { sessionActions } from './store'; -import { Grid, useMediaQuery, makeStyles, InputLabel, Select, MenuItem, FormControl, Button, TextField, Paper, Link } from '@material-ui/core'; +import { useMediaQuery, makeStyles, Paper } from '@material-ui/core'; import { useTheme } from '@material-ui/core/styles'; -import RegisterDialog from './RegisterDialog'; -import { useSelector } from 'react-redux'; -import t from './common/localization'; -import Logo from './Logo'; +import LoginForm from './components/LoginForm'; const useStyles = makeStyles(theme => ({ root: { @@ -45,123 +39,23 @@ const useStyles = makeStyles(theme => ({ padding: theme.spacing(5), width: "100%", }, - logo: { - textAlign: 'center', - }, })); const LoginPage = () => { const classes = useStyles(); const theme = useTheme(); - const dispatch = useDispatch(); - const history = useHistory(); - - const [failed, setFailed] = useState(false); - const [email, setEmail] = useState(''); - const [password, setPassword] = useState(''); - const [registerDialogShown, setRegisterDialogShown] = useState(false); - const registrationEnabled = useSelector(state => state.session.server ? state.session.server['registration'] : false); + const [CurrentForm, setCurrentForm] = useState(() => LoginForm); const matches = useMediaQuery(theme.breakpoints.down('md')); - const handleEmailChange = (event) => { - setEmail(event.target.value); - } - - const handlePasswordChange = (event) => { - setPassword(event.target.value); - } - - const handleRegister = () => { - setRegisterDialogShown(true); - } - - const handleRegisterResult = () => { - setRegisterDialogShown(false); - } - - const handleLogin = async (event) => { - event.preventDefault(); - const response = await fetch('/api/session', { method: 'POST', body: new URLSearchParams(`email=${email}&password=${password}`) }); - if (response.ok) { - const user = await response.json(); - dispatch(sessionActions.updateUser(user)); - history.push('/'); - } else { - setFailed(true); - setPassword(''); - } - } - return (
- {!matches && } + {!matches && Traccar }
-
- - - {matches && } - - - - - - - - - - - - - - - - - {t('loginLanguage')} - - - - - - - {t('loginReset')} - - - + +
-- cgit v1.2.3