AppFlowy-Cloud/admin_frontend/templates/users.html

57 lines
1.6 KiB
HTML

<!doctype html>
<html lang="en">
<body>
<h1>User List</h1>
<!-- Button to create new user -->
<button id="createUserBtn">Create User</button>
<ul id="userList"></ul>
<table>
<tr>
<th>Id</th>
<th>Email</th>
<th>Created At</th>
<th>Action</th>
</tr>
{% for user in users %}
<tr>
<td>{{ user.email|escape }}</td>
<td>{{ user.created_at|escape }}</td>
<td><a href="/web/admin/users/{{ user.id }}" class="btn">Go</a></td>
</tr>
{% endfor %}
</table>
<script>
document.getElementById('createUserBtn').addEventListener('click', function() {
// Get the email from the user
const email = prompt('Please enter the new user email:');
// TODO: Validate the email, if valid, send to server and update UI
if (email) {
// Assuming you will use fetch API or another method to send the data to the server
// Example:
// fetch('/createUser', {
// method: 'POST',
// body: JSON.stringify({ email: email }),
// headers: {
// 'Content-Type': 'application/json',
// }
// })
// .then(response => response.json())
// .then(data => {
// // Update the UI as needed, e.g., add a new row to the table
// console.log('User created:', data);
// })
// .catch((error) => {
// console.error('Error:', error);
// });
}
});
</script>
</body>
</html>