diff --git a/frontend/src/routes/Login.tsx b/frontend/src/routes/Login.tsx new file mode 100644 index 0000000..9c4cec4 --- /dev/null +++ b/frontend/src/routes/Login.tsx @@ -0,0 +1,43 @@ +import { useState, FormEvent } from 'react' +import Box from '@mui/material/Box' +import Card from '@mui/material/Card' +import CardContent from '@mui/material/CardContent' +import TextField from '@mui/material/TextField' +import Button from '@mui/material/Button' +import Typography from '@mui/material/Typography' +import Alert from '@mui/material/Alert' +import { authApi } from '../api' + +export default function Login() { + const [username, setUsername] = useState('') + const [password, setPassword] = useState('') + const [error, setError] = useState('') + + const handleSubmit = async (e: FormEvent) => { + e.preventDefault() + setError('') + try { + await authApi.login(username, password) + window.location.href = '/configs' + } catch { + setError('Invalid username or password') + } + } + + return ( + + + + Shorefront + Sign in to manage your Shorewall configs + {error && {error}} + + setUsername(e.target.value)} sx={{ mb: 2 }} size="small" required /> + setPassword(e.target.value)} sx={{ mb: 3 }} size="small" required /> + + + + + + ) +}