added some new pages

This commit is contained in:
Jelaletdin12
2026-05-12 12:41:13 +05:00
parent ab7fdf46b3
commit f415acd649
40 changed files with 4022 additions and 30 deletions

View File

@@ -0,0 +1,15 @@
import { useTranslation } from 'react-i18next'
import { RoleForm } from '@/features/roles/components/roleForm'
export default function RoleCreatePage() {
const { t } = useTranslation()
return (
<div>
<h1 className="text-2xl font-bold text-foreground mb-6">
{t('roles.actions.create', 'Rol dörediň')}
</h1>
<RoleForm mode="create" />
</div>
)
}

View File

@@ -0,0 +1,46 @@
import { useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { RoleForm } from '@/features/roles/components/roleForm'
import { useRole } from '@/features/roles/hooks/useRoles'
import { Skeleton } from '@/components/ui/skeleton'
export default function RoleEditPage() {
const { t } = useTranslation()
const { id } = useParams<{ id: string }>()
const roleId = Number(id)
const { data: role, isLoading, isError } = useRole(roleId)
if (isLoading) {
return (
<div>
<Skeleton className="h-8 w-48 mb-6" />
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
{Array.from({ length: 3 }).map((_, i) => (
<div key={i} className="grid grid-cols-[220px_1fr] items-center p-5">
<Skeleton className="h-4 w-24" />
<Skeleton className="h-9 w-full" />
</div>
))}
</div>
</div>
)
}
if (isError || !role) {
return (
<p className="text-destructive text-sm">
{t('common.fetchError', 'Maglumat ýüklenmedi.')}
</p>
)
}
return (
<div>
<h1 className="text-2xl font-bold text-foreground mb-6">
{t('roles.editTitle', 'Rol üýtget')}: {role.name?.tk}
</h1>
<RoleForm mode="edit" initialData={role} roleId={roleId} />
</div>
)
}

View File

@@ -0,0 +1,194 @@
import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Eye, Pencil, Trash2 } from 'lucide-react'
import type { ColumnDef, VisibilityState } from '@tanstack/react-table'
import { DataTable } from '@/components/dataTable'
import { DataTableToolbar } from '@/components/dataTableToolbar'
import { Button } from '@/components/ui/button'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { usePermissions, useDeletePermission } from '@/features/permissions/hooks/usePermissions'
import type { Permission } from '@/features/permissions/api/permissionsApi'
// ─── Column meta for toolbar ──────────────────────────────────────────────────
const COLUMN_META = [
{ id: 'id', label: 'ID' },
{ id: 'code', label: 'Kod' },
{ id: 'name', label: 'Ady' },
{ id: 'guard_name', label: 'Guard name' },
]
// ─── PermissionsPage ──────────────────────────────────────────────────────────
export default function PermissionsPage() {
const { t } = useTranslation()
const navigate = useNavigate()
// ── State ──────────────────────────────────────────────────────────────────
const [search, setSearch] = useState('')
const [page, setPage] = useState(1)
const [perPage, setPerPage] = useState(25)
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({})
const [columnOrder, setColumnOrder] = useState<string[]>([])
const [deleteId, setDeleteId] = useState<number | null>(null)
// ── Data ───────────────────────────────────────────────────────────────────
const { data, isLoading } = usePermissions({ search, page, per_page: perPage })
const deletePermission = useDeletePermission()
// ── Columns ────────────────────────────────────────────────────────────────
const columns: ColumnDef<Permission>[] = [
{
accessorKey: 'id',
header: 'ID',
size: 70,
cell: ({ row }) => (
<span className="text-primary font-semibold">{row.original.id}</span>
),
},
{
accessorKey: 'code',
header: t('permissions.fields.code', 'Kod'),
},
{
accessorKey: 'name',
header: t('permissions.fields.name', 'Ady'),
cell: ({ row }) => <span>{row.original.name?.tk ?? '—'}</span>,
},
{
accessorKey: 'guard_name',
header: 'Guard name',
},
{
id: 'actions',
header: '',
size: 120,
enableSorting: false,
enableHiding: false,
cell: ({ row }) => (
<div className="flex items-center justify-end gap-1">
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-primary"
onClick={() => navigate(`/settings/users/permissions/${row.original.id}`)}
>
<Eye size={15} />
</Button>
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-blue-500"
onClick={() => navigate(`/settings/users/permissions/${row.original.id}/edit`)}
>
<Pencil size={15} />
</Button>
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-destructive"
onClick={() => setDeleteId(row.original.id)}
>
<Trash2 size={15} />
</Button>
</div>
),
},
]
// ── Handlers ───────────────────────────────────────────────────────────────
const handleConfirmDelete = () => {
if (deleteId === null) return
deletePermission.mutate(deleteId, {
onSuccess: () => setDeleteId(null),
onError: () => setDeleteId(null),
})
}
// ── Render ─────────────────────────────────────────────────────────────────
return (
<div>
{/* Page heading */}
<div className="flex items-center justify-between mb-6">
<h1 className="text-2xl font-bold text-foreground">
{t('permissions.title', 'Rugsatlar')}
</h1>
<Button onClick={() => navigate('/settings/users/permissions/create')}>
{t('permissions.actions.create', 'Rugsat dörediň')}
</Button>
</div>
{/* Toolbar */}
<DataTableToolbar
searchValue={search}
onSearchChange={(v) => { setSearch(v); setPage(1) }}
searchPlaceholder={t('permissions.searchPlaceholder', 'Gözlemek...')}
columns={COLUMN_META}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
perPageOptions={[10, 25, 50, 100]}
perPage={perPage}
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
/>
{/* Table */}
<DataTable
columns={columns}
data={data?.data ?? []}
isLoading={isLoading}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
getRowId={(row) => String(row.id)}
currentPage={data?.meta?.current_page ?? 1}
totalPages={data?.meta?.last_page ?? 1}
totalCount={data?.meta?.total ?? 0}
onPageChange={setPage}
/>
{/* Delete confirmation dialog */}
<AlertDialog
open={deleteId !== null}
onOpenChange={(open) => { if (!open) setDeleteId(null) }}
>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{t('permissions.deleteDialog.title', 'Rugsaty pozmak')}
</AlertDialogTitle>
<AlertDialogDescription>
{t(
'permissions.deleteDialog.description',
'Bu rugsaty pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylmaz.',
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
<AlertDialogAction
onClick={handleConfirmDelete}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{deletePermission.isPending
? t('common.deleting', 'Pozulýar...')
: t('common.delete', 'Poz')}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
)
}

View File

@@ -0,0 +1,15 @@
import { useTranslation } from 'react-i18next'
import { PermissionForm } from '@/features/permissions/components/permissionsForm'
export default function PermissionCreatePage() {
const { t } = useTranslation()
return (
<div>
<h1 className="text-2xl font-bold text-foreground mb-6">
{t('permissions.actions.create', 'Rugsat dörediň')}
</h1>
<PermissionForm mode="create" />
</div>
)
}

View File

@@ -0,0 +1,46 @@
import { useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { PermissionForm } from '@/features/permissions/components/permissionsForm'
import { usePermission } from '@/features/permissions/hooks/usePermissions'
import { Skeleton } from '@/components/ui/skeleton'
export default function PermissionEditPage() {
const { t } = useTranslation()
const { id } = useParams<{ id: string }>()
const permissionId = Number(id)
const { data: permission, isLoading, isError } = usePermission(permissionId)
if (isLoading) {
return (
<div>
<Skeleton className="h-8 w-56 mb-6" />
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
{Array.from({ length: 3 }).map((_, i) => (
<div key={i} className="grid grid-cols-[220px_1fr] items-center p-5">
<Skeleton className="h-4 w-24" />
<Skeleton className="h-9 w-full" />
</div>
))}
</div>
</div>
)
}
if (isError || !permission) {
return (
<p className="text-destructive text-sm">
{t('common.fetchError', 'Maglumat ýüklenmedi.')}
</p>
)
}
return (
<div>
<h1 className="text-2xl font-bold text-foreground mb-6">
{t('permissions.editTitle', 'Rugsaty üýtget')}: {permission.name?.tk}
</h1>
<PermissionForm mode="edit" initialData={permission} permissionId={permissionId} />
</div>
)
}

View File

@@ -0,0 +1,181 @@
import { useState } from 'react'
import { useParams, useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Pencil, Trash2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { Skeleton } from '@/components/ui/skeleton'
import { Section, InfoRow } from '@/components/viewPageComponents'
import { usePermission, useDeletePermission } from '@/features/permissions/hooks/usePermissions'
// ─── LangTabs ─────────────────────────────────────────────────────────────────
type LangKey = 'tk' | 'ru' | 'en'
const LANG_TABS: { key: LangKey; label: string }[] = [
{ key: 'tk', label: 'Türkmen' },
{ key: 'ru', label: 'Русский' },
{ key: 'en', label: 'English' },
]
function LangTabs({
active,
onChange,
}: {
active: LangKey
onChange: (l: LangKey) => void
}) {
return (
<div className="flex gap-1 justify-end mb-2">
{LANG_TABS.map((tab) => (
<button
key={tab.key}
type="button"
onClick={() => onChange(tab.key)}
className={`px-3 py-0.5 text-xs font-medium rounded-md transition-colors ${
active === tab.key
? 'text-primary border-b-2 border-primary'
: 'text-muted-foreground hover:text-foreground'
}`}
>
{tab.label}
</button>
))}
</div>
)
}
// ─── PermissionViewPage ───────────────────────────────────────────────────────
export default function PermissionViewPage() {
const { t } = useTranslation()
const { id } = useParams<{ id: string }>()
const navigate = useNavigate()
const permissionId = Number(id)
const [activeLang, setActiveLang] = useState<LangKey>('tk')
const [showDelete, setShowDelete] = useState(false)
const { data: permission, isLoading, isError } = usePermission(permissionId)
const deletePermission = useDeletePermission()
const handleConfirmDelete = () => {
deletePermission.mutate(permissionId, {
onSuccess: () => navigate('/settings/users/permissions'),
onError: () => setShowDelete(false),
})
}
// ── Loading skeleton ───────────────────────────────────────────────────────
if (isLoading) {
return (
<div>
<Skeleton className="h-8 w-72 mb-6" />
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
{Array.from({ length: 4 }).map((_, i) => (
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-3 px-4">
<Skeleton className="h-4 w-20" />
<Skeleton className="h-4 w-40" />
</div>
))}
</div>
</div>
)
}
if (isError || !permission) {
return (
<p className="text-destructive text-sm">
{t('common.fetchError', 'Maglumat ýüklenmedi.')}
</p>
)
}
// ── Render ─────────────────────────────────────────────────────────────────
return (
<div>
{/* Page heading + actions */}
<div className="flex items-start justify-between mb-6">
<h1 className="text-2xl font-bold text-foreground">
{t('permissions.viewTitle', 'Rugsat giňişleýin')}: {permission.name?.tk}
</h1>
<div className="flex items-center gap-2">
<Button
variant="outline"
size="icon"
className="text-muted-foreground hover:text-destructive hover:border-destructive"
onClick={() => setShowDelete(true)}
>
<Trash2 size={16} />
</Button>
<Button
variant="outline"
size="icon"
className="text-muted-foreground hover:text-blue-500 hover:border-blue-500"
onClick={() => navigate(`/settings/users/permissions/${permissionId}/edit`)}
>
<Pencil size={16} />
</Button>
</div>
</div>
{/* Detail section */}
<Section>
<InfoRow label="ID" value={permission.id} />
<InfoRow label={t('permissions.fields.code', 'Kod')} value={permission.code} />
{/* Name row — with lang switcher */}
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
<span className="text-sm text-muted-foreground pt-1">
{t('permissions.fields.name', 'Ady')}
</span>
<div>
<LangTabs active={activeLang} onChange={setActiveLang} />
<span className="text-sm text-foreground">
{permission.name?.[activeLang] || '—'}
</span>
</div>
</div>
<InfoRow label={t('permissions.fields.guardName', 'Guard name')} value={permission.guard_name} />
</Section>
{/* Delete dialog */}
<AlertDialog open={showDelete} onOpenChange={setShowDelete}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{t('permissions.deleteDialog.title', 'Rugsaty pozmak')}
</AlertDialogTitle>
<AlertDialogDescription>
{t(
'permissions.deleteDialog.description',
'Bu rugsaty pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylmaz.',
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
<AlertDialogAction
onClick={handleConfirmDelete}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{deletePermission.isPending
? t('common.deleting', 'Pozulýar...')
: t('common.delete', 'Poz')}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
)
}

View File

@@ -0,0 +1,194 @@
import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Eye, Pencil, Trash2 } from 'lucide-react'
import type { ColumnDef, VisibilityState } from '@tanstack/react-table'
import { DataTable } from '@/components/dataTable'
import { DataTableToolbar } from '@/components/dataTableToolbar'
import { Button } from '@/components/ui/button'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { useRoles, useDeleteRole } from '@/features/roles/hooks/useRoles'
import type { Role } from '@/features/roles/api/rolesApi'
// ─── Column meta for toolbar ──────────────────────────────────────────────────
const COLUMN_META = [
{ id: 'id', label: 'ID' },
{ id: 'code', label: 'Kod' },
{ id: 'name', label: 'Ady' },
{ id: 'guard_name', label: 'Guard name' },
]
// ─── RolesPage ────────────────────────────────────────────────────────────────
export default function RolesPage() {
const { t } = useTranslation()
const navigate = useNavigate()
// ── State ──────────────────────────────────────────────────────────────────
const [search, setSearch] = useState('')
const [page, setPage] = useState(1)
const [perPage, setPerPage] = useState(25)
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({})
const [columnOrder, setColumnOrder] = useState<string[]>([])
const [deleteId, setDeleteId] = useState<number | null>(null)
// ── Data ───────────────────────────────────────────────────────────────────
const { data, isLoading } = useRoles({ search, page, per_page: perPage })
const deleteRole = useDeleteRole()
// ── Columns ────────────────────────────────────────────────────────────────
const columns: ColumnDef<Role>[] = [
{
accessorKey: 'id',
header: 'ID',
size: 70,
cell: ({ row }) => (
<span className="text-primary font-semibold">{row.original.id}</span>
),
},
{
accessorKey: 'code',
header: t('roles.fields.code', 'Kod'),
},
{
accessorKey: 'name',
header: t('roles.fields.name', 'Ady'),
cell: ({ row }) => <span>{row.original.name?.tk ?? '—'}</span>,
},
{
accessorKey: 'guard_name',
header: 'Guard name',
},
{
id: 'actions',
header: '',
size: 120,
enableSorting: false,
enableHiding: false,
cell: ({ row }) => (
<div className="flex items-center justify-end gap-1">
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-primary"
onClick={() => navigate(`/settings/users/roles/${row.original.id}`)}
>
<Eye size={15} />
</Button>
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-blue-500"
onClick={() => navigate(`/settings/users/roles/${row.original.id}/edit`)}
>
<Pencil size={15} />
</Button>
<Button
variant="ghost"
size="icon"
className="h-8 w-8 text-muted-foreground hover:text-destructive"
onClick={() => setDeleteId(row.original.id)}
>
<Trash2 size={15} />
</Button>
</div>
),
},
]
// ── Handlers ───────────────────────────────────────────────────────────────
const handleConfirmDelete = () => {
if (deleteId === null) return
deleteRole.mutate(deleteId, {
onSuccess: () => setDeleteId(null),
onError: () => setDeleteId(null),
})
}
// ── Render ─────────────────────────────────────────────────────────────────
return (
<div>
{/* Page heading */}
<div className="flex items-center justify-between mb-6">
<h1 className="text-2xl font-bold text-foreground">
{t('roles.title', 'Rollar')}
</h1>
<Button onClick={() => navigate('/settings/users/roles/create')}>
{t('roles.actions.create', 'Rol dörediň')}
</Button>
</div>
{/* Toolbar */}
<DataTableToolbar
searchValue={search}
onSearchChange={(v) => { setSearch(v); setPage(1) }}
searchPlaceholder={t('roles.searchPlaceholder', 'Gözlemek...')}
columns={COLUMN_META}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
perPageOptions={[10, 25, 50, 100]}
perPage={perPage}
onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
/>
{/* Table */}
<DataTable
columns={columns}
data={data?.data ?? []}
isLoading={isLoading}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
getRowId={(row) => String(row.id)}
currentPage={data?.meta?.current_page ?? 1}
totalPages={data?.meta?.last_page ?? 1}
totalCount={data?.meta?.total ?? 0}
onPageChange={setPage}
/>
{/* Delete confirmation dialog */}
<AlertDialog
open={deleteId !== null}
onOpenChange={(open) => { if (!open) setDeleteId(null) }}
>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{t('roles.deleteDialog.title', 'Roly pozmak')}
</AlertDialogTitle>
<AlertDialogDescription>
{t(
'roles.deleteDialog.description',
'Bu roly pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylmaz.',
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
<AlertDialogAction
onClick={handleConfirmDelete}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{deleteRole.isPending
? t('common.deleting', 'Pozulýar...')
: t('common.delete', 'Poz')}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
)
}

View File

@@ -0,0 +1,181 @@
import { useState } from 'react'
import { useParams, useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Pencil, Trash2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { Skeleton } from '@/components/ui/skeleton'
import { Section, InfoRow } from '@/components/viewPageComponents'
import { useRole, useDeleteRole } from '@/features/roles/hooks/useRoles'
// ─── LangTabs ─────────────────────────────────────────────────────────────────
type LangKey = 'tk' | 'ru' | 'en'
const LANG_TABS: { key: LangKey; label: string }[] = [
{ key: 'tk', label: 'Türkmen' },
{ key: 'ru', label: 'Русский' },
{ key: 'en', label: 'English' },
]
function LangTabs({
active,
onChange,
}: {
active: LangKey
onChange: (l: LangKey) => void
}) {
return (
<div className="flex gap-1 justify-end mb-2">
{LANG_TABS.map((tab) => (
<button
key={tab.key}
type="button"
onClick={() => onChange(tab.key)}
className={`px-3 py-0.5 text-xs font-medium rounded-md transition-colors ${
active === tab.key
? 'text-primary border-b-2 border-primary'
: 'text-muted-foreground hover:text-foreground'
}`}
>
{tab.label}
</button>
))}
</div>
)
}
// ─── RoleViewPage ─────────────────────────────────────────────────────────────
export default function RoleViewPage() {
const { t } = useTranslation()
const { id } = useParams<{ id: string }>()
const navigate = useNavigate()
const roleId = Number(id)
const [activeLang, setActiveLang] = useState<LangKey>('tk')
const [showDelete, setShowDelete] = useState(false)
const { data: role, isLoading, isError } = useRole(roleId)
const deleteRole = useDeleteRole()
const handleConfirmDelete = () => {
deleteRole.mutate(roleId, {
onSuccess: () => navigate('/settings/users/roles'),
onError: () => setShowDelete(false),
})
}
// ── Loading skeleton ───────────────────────────────────────────────────────
if (isLoading) {
return (
<div>
<Skeleton className="h-8 w-72 mb-6" />
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
{Array.from({ length: 4 }).map((_, i) => (
<div key={i} className="grid grid-cols-[220px_1fr] items-center py-3 px-4">
<Skeleton className="h-4 w-20" />
<Skeleton className="h-4 w-40" />
</div>
))}
</div>
</div>
)
}
if (isError || !role) {
return (
<p className="text-destructive text-sm">
{t('common.fetchError', 'Maglumat ýüklenmedi.')}
</p>
)
}
// ── Render ─────────────────────────────────────────────────────────────────
return (
<div>
{/* Page heading + actions */}
<div className="flex items-start justify-between mb-6">
<h1 className="text-2xl font-bold text-foreground">
{t('roles.viewTitle', 'Rol giňişleýin')}: {role.name?.tk}
</h1>
<div className="flex items-center gap-2">
<Button
variant="outline"
size="icon"
className="text-muted-foreground hover:text-destructive hover:border-destructive"
onClick={() => setShowDelete(true)}
>
<Trash2 size={16} />
</Button>
<Button
variant="outline"
size="icon"
className="text-muted-foreground hover:text-blue-500 hover:border-blue-500"
onClick={() => navigate(`/settings/users/roles/${roleId}/edit`)}
>
<Pencil size={16} />
</Button>
</div>
</div>
{/* Detail section */}
<Section>
<InfoRow label="ID" value={role.id} />
<InfoRow label={t('roles.fields.code', 'Kod')} value={role.code} />
{/* Name row — with lang switcher */}
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
<span className="text-sm text-muted-foreground pt-1">
{t('roles.fields.name', 'Ady')}
</span>
<div>
<LangTabs active={activeLang} onChange={setActiveLang} />
<span className="text-sm text-foreground">
{role.name?.[activeLang] || '—'}
</span>
</div>
</div>
<InfoRow label={t('roles.fields.guardName', 'Guard name')} value={role.guard_name} />
</Section>
{/* Delete dialog */}
<AlertDialog open={showDelete} onOpenChange={setShowDelete}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{t('roles.deleteDialog.title', 'Roly pozmak')}
</AlertDialogTitle>
<AlertDialogDescription>
{t(
'roles.deleteDialog.description',
'Bu roly pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylmaz.',
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t('common.cancel', 'Ýatyr')}</AlertDialogCancel>
<AlertDialogAction
onClick={handleConfirmDelete}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{deleteRole.isPending
? t('common.deleting', 'Pozulýar...')
: t('common.delete', 'Poz')}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
)
}