From cee5acab1d595e85f97fa799bcdbf99a1af012e4 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 27 May 2026 11:59:43 +0000 Subject: [PATCH] fix: modal styling - solid bg, full-width dropdown, labels --- src/components/admin/UserManagementPanel.jsx | 146 ++++++++++++------- 1 file changed, 92 insertions(+), 54 deletions(-) diff --git a/src/components/admin/UserManagementPanel.jsx b/src/components/admin/UserManagementPanel.jsx index 98fc6bf..fd8b53d 100644 --- a/src/components/admin/UserManagementPanel.jsx +++ b/src/components/admin/UserManagementPanel.jsx @@ -49,7 +49,7 @@ async function adminApi(method, body) { return json; } -/* ── Custom dropdown (matches app design system) ── */ +/* ── Custom dropdown (matches app design system, full-width) ── */ function RoleDropdown({ value, onChange }) { const [open, setOpen] = useState(false); const ref = useRef(null); @@ -66,17 +66,17 @@ function RoleDropdown({ value, onChange }) { const pick = (role) => { onChange(role); setOpen(false); }; return ( -
+
{open && ( -
+
{ROLES.map((r) => { const sel = r === value; return ( @@ -85,8 +85,8 @@ function RoleDropdown({ value, onChange }) { type="button" onClick={() => pick(r)} className={[ - 'flex w-full items-center justify-between px-4 py-2.5 text-left text-sm transition', - sel ? 'bg-[var(--color-accent-soft)] text-[var(--color-text)]' : 'text-[var(--color-text)] hover:bg-[var(--color-surface-strong)]', + 'flex w-full items-center justify-between px-4 py-3 text-left text-sm transition', + sel ? 'bg-[var(--color-accent-soft)] text-[var(--color-accent)]' : 'text-[var(--color-text)] hover:bg-[var(--color-surface)]', ].join(' ')} > {ROLE_LABELS[r]} @@ -100,6 +100,80 @@ function RoleDropdown({ value, onChange }) { ); } +/* ── Add-user modal ── */ +function AddUserModal({ onSubmit, onClose, submitting, error }) { + const [form, setForm] = useState({ name: '', email: '', role: 'manager' }); + const nameRef = useRef(null); + + useEffect(() => { nameRef.current?.focus(); }, []); + + return ( +
+
e.stopPropagation()} + > +

Новый пользователь

+
{ + e.preventDefault(); + onSubmit(form); + }} + className="space-y-4" + > +
+ + setForm((f) => ({ ...f, name: e.target.value }))} + /> +
+
+ + setForm((f) => ({ ...f, email: e.target.value }))} + /> +
+
+ + setForm((f) => ({ ...f, role: r }))} + /> +
+ {error && ( +
{error}
+ )} +
+ + +
+
+
+
+ ); +} + export default function UserManagementPanel() { const [users, setUsers] = useState([]); const [roles, setRoles] = useState([]); @@ -110,7 +184,6 @@ export default function UserManagementPanel() { const [editForm, setEditForm] = useState({ name: '', email: '', role: '' }); const [saving, setSaving] = useState(false); const [deleteConfirmId, setDeleteConfirmId] = useState(null); - const [addForm, setAddForm] = useState({ name: '', email: '', role: '' }); const [addSubmitting, setAddSubmitting] = useState(false); const [addError, setAddError] = useState(null); @@ -146,16 +219,14 @@ export default function UserManagementPanel() { }; /* ── Add via edge function ── */ - const handleAddUser = async (e) => { - e.preventDefault(); + const handleAddUser = async (form) => { setAddError(null); - if (!addForm.name || !addForm.email || !addForm.role) { setAddError('Все поля обязательны.'); return; } + if (!form.name || !form.email || !form.role) { setAddError('Все поля обязательны.'); return; } setAddSubmitting(true); try { - await adminApi('POST', { email: addForm.email, name: addForm.name, role: addForm.role }); + await adminApi('POST', { email: form.email, name: form.name, role: form.role }); await fetchUsers(); setShowAddForm(false); - setAddForm({ name: '', email: '', role: '' }); } catch (err) { setAddError(err.message || 'Не удалось добавить пользователя.'); } finally { setAddSubmitting(false); } @@ -199,54 +270,21 @@ export default function UserManagementPanel() {
{users.length} пользователей
{/* Add user modal */} {showAddForm && ( -
{ setShowAddForm(false); setAddError(null); }}> -
e.stopPropagation()}> -

Новый пользователь

-
- setAddForm((f) => ({ ...f, name: e.target.value }))} - /> - setAddForm((f) => ({ ...f, email: e.target.value }))} - /> - setAddForm((f) => ({ ...f, role: r }))} - /> - {addError &&
{addError}
} -
- - -
- -
-
+ { setShowAddForm(false); setAddError(null); }} + submitting={addSubmitting} + error={addError} + /> )} {/* Error */}