From 83bfc0355dc199d4b68f0f0fc87d1887f38b0635 Mon Sep 17 00:00:00 2001 From: Denozordec Date: Sat, 18 Jul 2026 20:24:51 +0700 Subject: [PATCH] feat(auth): enhance CreateUserSheet with improved layout and error handling - Added useEffect to reset admin state when the sheet is closed. - Updated SheetContent to include a close button and improved styling. - Enhanced form structure with better accessibility and user experience. - Integrated error display using Alert component for form submission feedback. --- apps/web/src/routes/_auth.admin.index.tsx | 165 ++++++++++++++++------ 1 file changed, 121 insertions(+), 44 deletions(-) diff --git a/apps/web/src/routes/_auth.admin.index.tsx b/apps/web/src/routes/_auth.admin.index.tsx index 501260a..849e58b 100644 --- a/apps/web/src/routes/_auth.admin.index.tsx +++ b/apps/web/src/routes/_auth.admin.index.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from 'react' +import { useEffect, useMemo, useState } from 'react' import { createFileRoute } from '@tanstack/react-router' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { @@ -8,9 +8,15 @@ import { useReactTable, type ColumnDef, } from '@tanstack/react-table' +import { XIcon } from 'lucide-react' import type { AdminUser, CreateUserRequest } from '@authportal/shared' import { PageShell } from '@/components/page-shell' import { UserAccessSheet } from '@/components/reui-kit/user-access-sheet' +import { + Alert, + AlertDescription, + AlertTitle, +} from '@/components/reui/alert' import { Badge } from '@/components/reui/badge' import { Frame, @@ -29,7 +35,9 @@ import { Input } from '@authportal/ui/components/input' import { Checkbox } from '@authportal/ui/components/checkbox' import { Sheet, + SheetClose, SheetContent, + SheetDescription, SheetFooter, SheetHeader, SheetTitle, @@ -43,6 +51,9 @@ import { Skeleton } from '@authportal/ui/components/skeleton' import { api, ApiError } from '@/lib/api-client' import { usersQueryKey, usersQueryOptions } from '@/queries/auth' +/** Same shell as UserAccessSheet / solution-users-1. @see https://reui.io/preview/base/solution-users-1 */ +const mutedIconButtonClassName = 'text-muted-foreground hover:text-foreground' + export const Route = createFileRoute('/_auth/admin/')({ component: AdminUsersPage, }) @@ -300,14 +311,44 @@ function CreateUserSheet({ }) { const [isAdmin, setIsAdmin] = useState(false) + useEffect(() => { + if (!open) setIsAdmin(false) + }, [open]) + return ( - - - Новый пользователь + + +
+ + Новый пользователь + + +
+ + Создание учётной записи портала +
+
{ e.preventDefault() const fd = new FormData(e.currentTarget) @@ -321,45 +362,81 @@ function CreateUserSheet({ }) }} > - - - Имя - - - - Email - - - - Пароль - - - - - {error ?

{error}

: null} - - - +
+ + + Имя + + + + Email + + + + Пароль + + + + setIsAdmin(v === true)} + /> + + Администратор портала + + + + + {error ? ( + + Ошибка + {error} + + ) : null} +
+ + +
+ + +