mirror of
https://github.com/marcogll/ap_pos.git
synced 2026-01-13 13:15:16 +00:00
feat: Add initial setup page and functionality for admin account creation
- Created setup.html for the initial configuration of the admin account. - Implemented setup.js to handle form submission and validation. - Added logo images for branding. - Introduced storage.js for API data handling (load, save, remove). - Added styles.css for consistent styling across the application.
This commit is contained in:
36
setup.js
Normal file
36
setup.js
Normal file
@@ -0,0 +1,36 @@
|
||||
document.getElementById('setupForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const name = document.getElementById('fullName').value;
|
||||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
const confirmPassword = document.getElementById('confirmPassword').value;
|
||||
const errorMessage = document.getElementById('error-message');
|
||||
|
||||
if (password !== confirmPassword) {
|
||||
errorMessage.textContent = 'Las contraseñas no coinciden.';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/setup', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ name, username, password })
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
alert('Cuenta de administrador creada exitosamente. Ahora serás redirigido a la página de inicio de sesión.');
|
||||
window.location.href = '/login.html';
|
||||
} else {
|
||||
errorMessage.textContent = result.error || 'Ocurrió un error al crear la cuenta.';
|
||||
}
|
||||
} catch (error) {
|
||||
errorMessage.textContent = 'Error de conexión con el servidor.';
|
||||
console.error('Error en el setup:', error);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user