<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timbrature Dipendenti</title>
</head>
<body>
<h1>Timbratura Dipendenti</h1>
<form id="timbraturaForm">
<label>Nome:</label>
<input type="text" id="nome" required>
<label>Tipo:</label>
<select id="tipo">
<option value="entrata">Entrata</option>
<option value="uscita">Uscita</option>
</select>
<button type="submit">Registra</button>
</form>
<script>
document.getElementById('timbraturaForm').addEventListener('submit', function(e) {
e.preventDefault();
const nome = document.getElementById('nome').value;
const tipo = document.getElementById('tipo').value;
fetch('/timbratura', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ nome, tipo })
})
.then(response => response.json())
.then(data => alert(data.message))
.catch(err => console.error(err));
});
</script>
</body>
</html>