adding current revision information
This commit is contained in:
1 parent
789465483c
commit
920947e556
64 files changed
+5963
-18
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import api from '../services/api';
|
||||
import { Button, TextField, Container, Typography } from '@mui/material';
|
||||
|
||||
const Login: React.FC = () => {
|
||||
const [username, setUsername] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleLogin = async () => {
|
||||
try {
|
||||
const response = await api.post('/token', new URLSearchParams({
|
||||
username: username,
|
||||
password: password,
|
||||
}));
|
||||
localStorage.setItem('token', response.data.access_token);
|
||||
navigate('/');
|
||||
} catch (error) {
|
||||
console.error('Login failed', error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Container maxWidth="xs">
|
||||
<Typography variant="h4" component="h1" gutterBottom>
|
||||
Login
|
||||
</Typography>
|
||||
<TextField
|
||||
label="Username"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
margin="normal"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
/>
|
||||
<TextField
|
||||
label="Password"
|
||||
type="password"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
margin="normal"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
<Button variant="contained" color="primary" fullWidth onClick={handleLogin}>
|
||||
Login
|
||||
</Button>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default Login;
|
||||
Reference in new issue
Block a user