wip 9
This commit is contained in:
@@ -117,22 +117,22 @@ export default function AdminUsersPage() {
|
||||
<div className="relative h-full overflow-x-auto">
|
||||
{/* Add User Form */}
|
||||
{showAddForm && (
|
||||
<div className="absolute top-10 left-10 p-3 transition-all duration-200 bg-gray-200 rounded shadow-lg shadow-gray-500 dark:shadow-gray-900 dark:bg-gray-600">
|
||||
<div className="absolute left-10 top-10 rounded bg-gray-200 p-3 shadow-lg shadow-gray-500 transition-all duration-200 dark:bg-gray-600 dark:shadow-gray-900">
|
||||
<form onSubmit={handleCreateUser}
|
||||
className="flex flex-col gap-2 text-black dark:text-white text-sm">
|
||||
className="flex flex-col gap-2 text-sm text-black dark:text-white">
|
||||
<input
|
||||
type="text"
|
||||
value={newUsername}
|
||||
onChange={(e) => setNewUsername(e.target.value)}
|
||||
placeholder="Username"
|
||||
className="p-2 bg-gray-300 text-black dark:bg-gray-700 dark:text-white"
|
||||
className="bg-gray-300 p-2 text-black dark:bg-gray-700 dark:text-white"
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
value={newPassword}
|
||||
onChange={(e) => setNewPassword(e.target.value)}
|
||||
placeholder="Password"
|
||||
className="p-2 bg-gray-300 text-black dark:bg-gray-700 dark:text-white"
|
||||
className="bg-gray-300 p-2 text-black dark:bg-gray-700 dark:text-white"
|
||||
/>
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
@@ -144,7 +144,7 @@ export default function AdminUsersPage() {
|
||||
<label htmlFor="new_is_admin">Admin</label>
|
||||
</div>
|
||||
<button
|
||||
className="font-medium px-2 py-1 text-white bg-gray-500 dark:text-gray-800 hover:bg-gray-800 dark:hover:bg-gray-100"
|
||||
className="bg-gray-500 px-2 py-1 font-medium text-white hover:bg-gray-800 dark:text-gray-800 dark:hover:bg-gray-100"
|
||||
type="submit"
|
||||
>
|
||||
Create
|
||||
@@ -155,38 +155,38 @@ export default function AdminUsersPage() {
|
||||
|
||||
{/* Users Table */}
|
||||
<div className="min-w-full overflow-scroll rounded shadow">
|
||||
<table className="min-w-full leading-normal bg-white dark:bg-gray-700 text-sm">
|
||||
<table className="min-w-full bg-white text-sm leading-normal dark:bg-gray-700">
|
||||
<thead className="text-gray-800 dark:text-gray-400">
|
||||
<tr>
|
||||
<th className="p-3 font-normal text-left uppercase border-b border-gray-200 dark:border-gray-800 w-12">
|
||||
<th className="w-12 border-b border-gray-200 p-3 text-left font-normal uppercase dark:border-gray-800">
|
||||
<button onClick={() => setShowAddForm(!showAddForm)}>
|
||||
<Plus size={20} />
|
||||
</button>
|
||||
</th>
|
||||
<th className="p-3 font-normal text-left uppercase border-b border-gray-200 dark:border-gray-800">User</th>
|
||||
<th className="p-3 font-normal text-left uppercase border-b border-gray-200 dark:border-gray-800">Password</th>
|
||||
<th className="p-3 font-normal text-left uppercase border-b border-gray-200 dark:border-gray-800 text-center">
|
||||
<th className="border-b border-gray-200 p-3 text-left font-normal uppercase dark:border-gray-800">User</th>
|
||||
<th className="border-b border-gray-200 p-3 text-left font-normal uppercase dark:border-gray-800">Password</th>
|
||||
<th className="border-b border-gray-200 p-3 text-left text-center font-normal uppercase dark:border-gray-800">
|
||||
Permissions
|
||||
</th>
|
||||
<th className="p-3 font-normal text-left uppercase border-b border-gray-200 dark:border-gray-800 w-48">Created</th>
|
||||
<th className="w-48 border-b border-gray-200 p-3 text-left font-normal uppercase dark:border-gray-800">Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="text-black dark:text-white">
|
||||
{users.length === 0 ? (
|
||||
<tr>
|
||||
<td className="text-center p-3" colSpan={5}>No Results</td>
|
||||
<td className="p-3 text-center" colSpan={5}>No Results</td>
|
||||
</tr>
|
||||
) : (
|
||||
users.map((user) => (
|
||||
<tr key={user.id}>
|
||||
{/* Delete Button */}
|
||||
<td className="p-3 border-b border-gray-200 text-gray-800 dark:text-gray-400 cursor-pointer relative">
|
||||
<td className="relative cursor-pointer border-b border-gray-200 p-3 text-gray-800 dark:text-gray-400">
|
||||
<button onClick={() => handleDeleteUser(user.id)}>
|
||||
<Trash2 size={20} />
|
||||
</button>
|
||||
</td>
|
||||
{/* User ID */}
|
||||
<td className="p-3 border-b border-gray-200">
|
||||
<td className="border-b border-gray-200 p-3">
|
||||
<p>{user.id}</p>
|
||||
</td>
|
||||
{/* Password Reset */}
|
||||
@@ -196,20 +196,20 @@ export default function AdminUsersPage() {
|
||||
const password = prompt(`Enter new password for ${user.id}`);
|
||||
if (password) handleUpdatePassword(user.id, password);
|
||||
}}
|
||||
className="font-medium px-2 py-1 text-white bg-gray-500 dark:text-gray-800 hover:bg-gray-800 dark:hover:bg-gray-100"
|
||||
className="bg-gray-500 px-2 py-1 font-medium text-white hover:bg-gray-800 dark:text-gray-800 dark:hover:bg-gray-100"
|
||||
>
|
||||
Reset
|
||||
</button>
|
||||
</td>
|
||||
{/* Admin Toggle */}
|
||||
<td className="flex gap-2 justify-center p-3 border-b border-gray-200 text-center min-w-40">
|
||||
<td className="flex min-w-40 justify-center gap-2 border-b border-gray-200 p-3 text-center">
|
||||
<button
|
||||
onClick={() => handleToggleAdmin(user.id, true)}
|
||||
disabled={user.admin}
|
||||
className={`px-2 py-1 rounded-md text-white dark:text-black ${
|
||||
className={`rounded-md px-2 py-1 text-white dark:text-black ${
|
||||
user.admin
|
||||
? 'bg-gray-800 dark:bg-gray-100 cursor-default'
|
||||
: 'bg-gray-400 dark:bg-gray-600 cursor-pointer'
|
||||
? 'cursor-default bg-gray-800 dark:bg-gray-100'
|
||||
: 'cursor-pointer bg-gray-400 dark:bg-gray-600'
|
||||
}`}
|
||||
>
|
||||
admin
|
||||
@@ -217,17 +217,17 @@ export default function AdminUsersPage() {
|
||||
<button
|
||||
onClick={() => handleToggleAdmin(user.id, false)}
|
||||
disabled={!user.admin}
|
||||
className={`px-2 py-1 rounded-md text-white dark:text-black ${
|
||||
className={`rounded-md px-2 py-1 text-white dark:text-black ${
|
||||
!user.admin
|
||||
? 'bg-gray-800 dark:bg-gray-100 cursor-default'
|
||||
: 'bg-gray-400 dark:bg-gray-600 cursor-pointer'
|
||||
? 'cursor-default bg-gray-800 dark:bg-gray-100'
|
||||
: 'cursor-pointer bg-gray-400 dark:bg-gray-600'
|
||||
}`}
|
||||
>
|
||||
user
|
||||
</button>
|
||||
</td>
|
||||
{/* Created Date */}
|
||||
<td className="p-3 border-b border-gray-200">
|
||||
<td className="border-b border-gray-200 p-3">
|
||||
<p>{user.created_at}</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user