import { useState } from "react"; import { useNavigate, useParams } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { Pencil, Trash2, CheckCircle2, XCircle, Inbox } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog"; import { Section, InfoRow, CollapsibleSection, } from "@/components/viewPageComponents"; import { DataTableToolbar } from "@/components/dataTableToolbar"; import { useUser, useDeleteUser } from "@/features/allUsers/hooks/useAllUsers"; // ─── EmptyState ─────────────────────────────────────────────────────────────── interface EmptyStateProps { label: string; } function EmptyState({ label }: EmptyStateProps) { return (

{label}

); } // ─── UserViewPage ───────────────────────────────────────────────────────────── export default function UserViewPage() { const { t } = useTranslation(); const navigate = useNavigate(); const { id } = useParams<{ id: string }>(); const userId = Number(id); const { data: user, isLoading, isError } = useUser(userId); const deleteUser = useDeleteUser(); const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [roleSearch, setRoleSearch] = useState(""); const [permSearch, setPermSearch] = useState(""); const [branchSearch, setBranchSearch] = useState(""); const [auditSearch, setAuditSearch] = useState(""); const handleDeleteConfirm = async () => { await deleteUser.mutateAsync(userId); navigate("/users"); }; if (isLoading) { return (
{Array.from({ length: 5 }).map((_, i) => (
))}
); } if (isError || !user) { return (
{t("common.notFound", "Maglumat tapylmady")}
); } return (
{/* Title + actions */}

{t("users.viewTitle", "Ulanyjy giňişleýin")}: {user.name} ( {user.username})

{/* Main info */}
{user.isActive ? ( ) : ( )}
{/* Rollar */} {}} columnOrder={[]} onColumnOrderChange={() => {}} actionLabel={t("users.actions.addRole", "Rol birikdiriň")} onAction={() => {}} /> {/* Rugsatlar */} {}} columnOrder={[]} onColumnOrderChange={() => {}} actionLabel={t("users.actions.addPermission", "Rugsat birikdiriň")} onAction={() => {}} /> {/* Şahamçalar */} {}} columnOrder={[]} onColumnOrderChange={() => {}} actionLabel={t("users.actions.addBranch", "Şahamça birikdiriň")} onAction={() => {}} /> {/* Ammallar */} {}} columnOrder={[]} onColumnOrderChange={() => {}} actionLabel={t("users.actions.addAction", "Hereket")} onAction={() => {}} /> {/* Delete dialog */} {t("users.deleteDialog.title", "Ulanyjyny öçürmek")} {t( "users.deleteDialog.description", 'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.', ).replace("{name}", user.username)} {t("common.cancel", "Ýok")} {t("common.delete", "Öçür")}
); }