Spaces:
Running
Running
File size: 2,987 Bytes
29f9c32 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChipFlow Commander - Login</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
</head>
<body class="bg-gray-100">
<div class="min-h-screen flex items-center justify-center">
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md">
<div class="text-center mb-8">
<h1 class="text-2xl font-bold text-gray-800">ChipFlow Commander</h1>
<p class="text-gray-600">Admin & Owner Login</p>
</div>
<form id="loginForm">
<div class="mb-4">
<label class="block text-gray-700 mb-2">Username</label>
<input type="text" name="username" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required>
</div>
<div class="mb-6">
<label class="block text-gray-700 mb-2">Password</label>
<input type="password" name="password" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required>
</div>
<button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg font-bold transition">
Login
</button>
<div id="errorMessage" class="mt-4 text-red-500 text-sm hidden"></div>
</form>
</div>
</div>
<script>
feather.replace();
document.getElementById('loginForm').addEventListener('submit', async function(e) {
e.preventDefault();
const formData = new FormData(this);
const errorElement = document.getElementById('errorMessage');
try {
// Simulate API call
const response = await fetch('/api/login', {
method: 'POST',
body: formData
});
if (!response.ok) {
const error = await response.json();
errorElement.textContent = error.message || 'Login failed';
errorElement.classList.remove('hidden');
return;
}
// Redirect based on role
const { role } = await response.json();
window.location.href = role === 'owner' ? 'admin_dashboard.html' : 'admin_dashboard.html';
} catch (err) {
errorElement.textContent = 'Network error. Please try again.';
errorElement.classList.remove('hidden');
}
});
</script>
</body>
</html> |