You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import { route } from 'preact-router'
|
|
|
|
import { useState } from 'preact/hooks'
|
|
|
|
export const LoginPage = () => {
|
|
const [username, setUsername] = useState('')
|
|
|
|
const login = async () => {
|
|
await fetch(`/api/login`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
username,
|
|
}),
|
|
})
|
|
|
|
route('/')
|
|
}
|
|
|
|
return (
|
|
<main class="login">
|
|
<div class="logo">PHC / Problemi</div>
|
|
<div class="subtitle">Accedi</div>
|
|
|
|
<div class="form">
|
|
<label for="login-username">Username</label>
|
|
<input
|
|
id="login-username"
|
|
type="text"
|
|
value={username}
|
|
onInput={e => setUsername(e.target.value)}
|
|
/>
|
|
|
|
<div class="fill">
|
|
<button onClick={() => login()}>Accedi</button>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|