-
+ {/* Horizontal step bar — sits above the form card */}
+
+
+ {/* Form card */}
+
+ {/* Card header */}
+
+
+ {currentStep + 1} / {STEPS.length}
+
+
+ {t(STEPS[currentStep].titleKey) || STEPS[currentStep].titleFallback}
+
-
- {completedCount} / {STEPS.length}
-
-
- {/* ── Sidebar + content layout ── */}
-
- {/* Sidebar */}
-
+ {/* Card body */}
+
+ {currentStep === 0 && }
+ {currentStep === 1 && }
+ {currentStep === 2 && }
+ {currentStep === 3 && }
+ {currentStep === 4 && }
+ {currentStep === 5 && }
+ {currentStep === 6 && }
+ {currentStep === 7 && }
+ {currentStep === 8 && }
+ {currentStep === 9 && }
+
- {/* Step card */}
-
- {/* Card header */}
-
-
- {currentStep + 1} / {STEPS.length}
-
-
- {t(STEPS[currentStep].titleKey) || STEPS[currentStep].titleFallback}
-
-
-
- {/* Card body */}
-
- {currentStep === 0 && }
- {currentStep === 1 && }
- {currentStep === 2 && }
- {currentStep === 3 && }
- {currentStep === 4 && }
- {currentStep === 5 && }
- {currentStep === 6 && }
- {currentStep === 7 && }
- {currentStep === 8 && }
- {currentStep === 9 && }
-
-
- {/* Card footer with navigation */}
-
-
-
- {isLastStep ? (
-
- ) : (
-
+ {/* Card footer */}
+
+
+
+
+ {isLastStep ? (
+
+ ) : (
+
+ )}
diff --git a/src/features/operators/api/operatorsApi.ts b/src/features/operators/api/operatorsApi.ts
new file mode 100644
index 0000000..bdd7d4f
--- /dev/null
+++ b/src/features/operators/api/operatorsApi.ts
@@ -0,0 +1,234 @@
+// ─── Types ────────────────────────────────────────────────────────────────────
+
+export interface Operator {
+ id: number
+ username: string
+ name: string
+ phone: string | null
+ email: string | null
+ isActive: boolean
+}
+
+export interface OperatorDetail extends Operator {
+ roles: OperatorRole[]
+ permissions: OperatorPermission[]
+ branches: OperatorBranch[]
+ loanLimits: OperatorLoanLimit[]
+ cardLimits: OperatorCardLimit[]
+ auditLogs: OperatorAuditLog[]
+}
+
+export interface OperatorRole {
+ id: number
+ code: string
+ name: string
+ guardName: string
+}
+
+export interface OperatorPermission {
+ id: number
+ name: string
+ guardName: string
+}
+
+export interface OperatorBranch {
+ id: number
+ name: string
+ region: string
+ district: string
+ uniqueCode: string
+ isActive: boolean
+ billingUsernameIbr: string
+ billingUsernameSber: string
+ billingUsernameVisa: string
+}
+
+export interface OperatorLoanLimit {
+ id: number
+ name: string
+ amount: number
+}
+
+export interface OperatorCardLimit {
+ id: number
+ name: string
+ amount: number
+}
+
+export interface OperatorAuditLog {
+ id: number
+ actionName: string
+ performedBy: string
+ target: string
+ status: string
+ createdAt: string
+}
+
+export interface OperatorsListResponse {
+ data: Operator[]
+ meta: {
+ currentPage: number
+ totalPages: number
+ totalCount: number
+ perPage: number
+ }
+}
+
+export interface CreateOperatorPayload {
+ username: string
+ name: string
+ phone?: string
+ email?: string
+ password: string
+ isActive: boolean
+}
+
+export interface UpdateOperatorPayload {
+ username?: string
+ name?: string
+ phone?: string
+ email?: string
+ password?: string
+ isActive?: boolean
+}
+
+export interface OperatorsListParams {
+ page?: number
+ perPage?: number
+ search?: string
+ isActive?: string
+}
+
+// ─── Mock Data & API ────────────────────────────────────────────────────────────
+
+const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
+
+let mockOperators: OperatorDetail[] = [
+ {
+ id: 1,
+ username: 'johndoe',
+ name: 'John Doe',
+ phone: '+99365123456',
+ email: 'johndoe@example.com',
+ isActive: true,
+ roles: [{ id: 1, code: 'ADMIN', name: 'Administrator', guardName: 'web' }],
+ permissions: [{ id: 1, name: 'create_user', guardName: 'web' }],
+ branches: [
+ {
+ id: 1,
+ name: 'Main Branch',
+ region: 'Aşgabat',
+ district: 'Kopetdag',
+ uniqueCode: '01',
+ isActive: true,
+ billingUsernameIbr: 'ibr_1',
+ billingUsernameSber: 'sber_1',
+ billingUsernameVisa: 'visa_1',
+ },
+ ],
+ loanLimits: [{ id: 1, name: 'Consumer Loan', amount: 50000 }],
+ cardLimits: [{ id: 1, name: 'Credit Card', amount: 10000 }],
+ auditLogs: [
+ {
+ id: 1,
+ actionName: 'Login',
+ performedBy: 'System',
+ target: 'johndoe',
+ status: 'Success',
+ createdAt: '2023-10-27T10:00:00Z',
+ },
+ ],
+ },
+ {
+ id: 2,
+ username: 'janedoe',
+ name: 'Jane Doe',
+ phone: '+99365654321',
+ email: 'janedoe@example.com',
+ isActive: false,
+ roles: [{ id: 2, code: 'OPERATOR', name: 'Operator', guardName: 'web' }],
+ permissions: [],
+ branches: [],
+ loanLimits: [],
+ cardLimits: [],
+ auditLogs: [],
+ },
+]
+
+export const operatorsApi = {
+ getAll: async (params: OperatorsListParams): Promise
=> {
+ await delay(500)
+ let filtered = [...mockOperators]
+ if (params.search) {
+ const q = params.search.toLowerCase()
+ filtered = filtered.filter(
+ (o) =>
+ o.name.toLowerCase().includes(q) ||
+ o.username.toLowerCase().includes(q)
+ )
+ }
+ return {
+ data: filtered,
+ meta: {
+ currentPage: params.page || 1,
+ totalPages: 1,
+ totalCount: filtered.length,
+ perPage: params.perPage || 10,
+ },
+ }
+ },
+
+ getById: async (id: number): Promise => {
+ await delay(500)
+ const op = mockOperators.find((o) => o.id === Number(id))
+ if (!op) throw new Error('Not found')
+ return op
+ },
+
+ create: async (payload: CreateOperatorPayload): Promise => {
+ await delay(500)
+ const newOp: OperatorDetail = {
+ id: mockOperators.length > 0 ? Math.max(...mockOperators.map((o) => o.id)) + 1 : 1,
+ ...payload,
+ phone: payload.phone || null,
+ email: payload.email || null,
+ roles: [],
+ permissions: [],
+ branches: [],
+ loanLimits: [],
+ cardLimits: [],
+ auditLogs: [],
+ }
+ mockOperators.push(newOp)
+ return newOp
+ },
+
+ update: async (id: number, payload: UpdateOperatorPayload): Promise => {
+ await delay(500)
+ const index = mockOperators.findIndex((o) => o.id === Number(id))
+ if (index === -1) throw new Error('Not found')
+ mockOperators[index] = { ...mockOperators[index], ...payload }
+ return mockOperators[index]
+ },
+
+ delete: async (id: number): Promise => {
+ await delay(500)
+ mockOperators = mockOperators.filter((o) => o.id !== Number(id))
+ },
+
+ assignRole: async (_operatorId: number, _roleId: number): Promise => {
+ await delay(500)
+ },
+
+ removeRole: async (_operatorId: number, _roleId: number): Promise => {
+ await delay(500)
+ },
+
+ assignPermission: async (_operatorId: number, _permissionId: number): Promise => {
+ await delay(500)
+ },
+
+ removePermission: async (_operatorId: number, _permissionId: number): Promise => {
+ await delay(500)
+ },
+}
\ No newline at end of file
diff --git a/src/features/operators/components/operatorForms.tsx b/src/features/operators/components/operatorForms.tsx
new file mode 100644
index 0000000..835e886
--- /dev/null
+++ b/src/features/operators/components/operatorForms.tsx
@@ -0,0 +1,253 @@
+import { useState, useEffect } from 'react'
+import { useNavigate } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { Button } from '@/components/ui/button'
+import { Checkbox } from '@/components/ui/checkbox'
+import { FormInput } from '@/components/formInput'
+import { useCreateOperator, useUpdateOperator } from '../hooks/useOperators'
+import type { Operator, CreateOperatorPayload, UpdateOperatorPayload } from '../api/operatorsApi'
+
+// ─── Types ────────────────────────────────────────────────────────────────────
+
+interface OperatorFormProps {
+ mode: 'create' | 'edit'
+ initialData?: Operator
+ operatorId?: number
+}
+
+interface FormState {
+ username: string
+ name: string
+ phone: string
+ email: string
+ password: string
+ isActive: boolean
+}
+
+interface FormErrors {
+ username?: string
+ name?: string
+ password?: string
+}
+
+// ─── OperatorForm ─────────────────────────────────────────────────────────────
+
+export function OperatorForm({ mode, initialData, operatorId }: OperatorFormProps) {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+
+ const createMutation = useCreateOperator()
+ const updateMutation = useUpdateOperator(operatorId ?? 0)
+
+ const isPending = createMutation.isPending || updateMutation.isPending
+
+ // ── Form state ──────────────────────────────────────────────────────────────
+ const [form, setForm] = useState({
+ username: '',
+ name: '',
+ phone: '',
+ email: '',
+ password: '',
+ isActive: true,
+ })
+
+ const [errors, setErrors] = useState({})
+
+ // Populate form in edit mode
+ useEffect(() => {
+ if (mode === 'edit' && initialData) {
+ setForm({
+ username: initialData.username ?? '',
+ name: initialData.name ?? '',
+ phone: initialData.phone ?? '',
+ email: initialData.email ?? '',
+ password: '',
+ isActive: initialData.isActive ?? true,
+ })
+ }
+ }, [mode, initialData])
+
+ // ── Helpers ─────────────────────────────────────────────────────────────────
+ const set = (field: keyof FormState) => (value: string) =>
+ setForm((prev) => ({ ...prev, [field]: value }))
+
+ const validate = (): boolean => {
+ const next: FormErrors = {}
+ if (!form.username.trim())
+ next.username = t('operators.errors.usernameRequired', 'Ulanyjy ady hökmany')
+ if (!form.name.trim())
+ next.name = t('operators.errors.nameRequired', 'Ady hökmany')
+ if (mode === 'create' && !form.password.trim())
+ next.password = t('operators.errors.passwordRequired', 'Açar sözi hökmany')
+ setErrors(next)
+ return Object.keys(next).length === 0
+ }
+
+ // ── Submit ──────────────────────────────────────────────────────────────────
+ const handleSubmit = () => {
+ if (!validate()) return
+
+ if (mode === 'create') {
+ const payload: CreateOperatorPayload = {
+ username: form.username.trim(),
+ name: form.name.trim(),
+ phone: form.phone.trim() || undefined,
+ email: form.email.trim() || undefined,
+ password: form.password,
+ isActive: form.isActive,
+ }
+ createMutation.mutate(payload, {
+ onSuccess: () => navigate('/operators'),
+ })
+ } else {
+ const payload: UpdateOperatorPayload = {
+ username: form.username.trim(),
+ name: form.name.trim(),
+ phone: form.phone.trim() || undefined,
+ email: form.email.trim() || undefined,
+ isActive: form.isActive,
+ }
+ if (form.password.trim()) {
+ payload.password = form.password
+ }
+ updateMutation.mutate(payload, {
+ onSuccess: () => navigate(`/operators/${operatorId}`),
+ })
+ }
+ }
+
+ // ── Render ──────────────────────────────────────────────────────────────────
+ return (
+
+ {/* Username */}
+
+
+ {t('operators.fields.username', 'Ulanyjy ady')}
+ *
+
+
+
+
+ {/* Name */}
+
+
+ {t('operators.fields.name', 'Ady')}
+ *
+
+
+
+
+ {/* Phone */}
+
+
+ {t('operators.fields.phone', 'Telefon')}
+
+
+
+
+ {/* Email */}
+
+
+ {t('operators.fields.email', 'E-poçta')}
+
+
+
+
+ {/* Password */}
+
+
+ {t('operators.fields.password', 'Açar sözi')}
+ {mode === 'create' && *}
+
+
+
+ {mode === 'edit' && (
+
+ {t(
+ 'operators.fields.passwordEditNote',
+ 'Boş goýsaňyz, açar sözi üýtgemez',
+ )}
+
+ )}
+
+
+
+ {/* isActive */}
+
+
+ {t('operators.fields.isActive', 'Işjeň')}
+
+ setForm((prev) => ({ ...prev, isActive: !!v }))}
+ disabled={isPending}
+ className="data-[state=checked]:bg-primary data-[state=checked]:border-primary"
+ />
+
+
+ {/* Actions */}
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/features/operators/hooks/useOperators.ts b/src/features/operators/hooks/useOperators.ts
new file mode 100644
index 0000000..92067c8
--- /dev/null
+++ b/src/features/operators/hooks/useOperators.ts
@@ -0,0 +1,130 @@
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
+import { toast } from 'sonner'
+import { useTranslation } from 'react-i18next'
+import {
+ operatorsApi,
+ type OperatorsListParams,
+ type CreateOperatorPayload,
+ type UpdateOperatorPayload,
+} from '../api/operatorsApi'
+
+// ─── Query Keys ───────────────────────────────────────────────────────────────
+
+export const operatorKeys = {
+ all: ['operators'] as const,
+ lists: () => [...operatorKeys.all, 'list'] as const,
+ list: (params: OperatorsListParams) => [...operatorKeys.lists(), params] as const,
+ details: () => [...operatorKeys.all, 'detail'] as const,
+ detail: (id: number) => [...operatorKeys.details(), id] as const,
+}
+
+// ─── useOperators ─────────────────────────────────────────────────────────────
+
+export function useOperators(params: OperatorsListParams) {
+ return useQuery({
+ queryKey: operatorKeys.list(params),
+ queryFn: () => operatorsApi.getAll(params),
+ placeholderData: (prev) => prev,
+ })
+}
+
+// ─── useOperator ──────────────────────────────────────────────────────────────
+
+export function useOperator(id: number) {
+ return useQuery({
+ queryKey: operatorKeys.detail(id),
+ queryFn: () => operatorsApi.getById(id),
+ enabled: !!id,
+ })
+}
+
+// ─── useCreateOperator ────────────────────────────────────────────────────────
+
+export function useCreateOperator() {
+ const queryClient = useQueryClient()
+ const { t } = useTranslation()
+
+ return useMutation({
+ mutationFn: (payload: CreateOperatorPayload) => operatorsApi.create(payload),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: operatorKeys.lists() })
+ toast.success(t('operators.createSuccess', 'Operator üstünlikli döredildi'))
+ },
+ onError: () => {
+ toast.error(t('operators.createError', 'Operator döretmekde ýalňyşlyk'))
+ },
+ })
+}
+
+// ─── useUpdateOperator ────────────────────────────────────────────────────────
+
+export function useUpdateOperator(id: number) {
+ const queryClient = useQueryClient()
+ const { t } = useTranslation()
+
+ return useMutation({
+ mutationFn: (payload: UpdateOperatorPayload) => operatorsApi.update(id, payload),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: operatorKeys.lists() })
+ queryClient.invalidateQueries({ queryKey: operatorKeys.detail(id) })
+ toast.success(t('operators.updateSuccess', 'Operator üstünlikli täzelendi'))
+ },
+ onError: () => {
+ toast.error(t('operators.updateError', 'Operator täzelemekde ýalňyşlyk'))
+ },
+ })
+}
+
+// ─── useDeleteOperator ────────────────────────────────────────────────────────
+
+export function useDeleteOperator() {
+ const queryClient = useQueryClient()
+ const { t } = useTranslation()
+
+ return useMutation({
+ mutationFn: (id: number) => operatorsApi.delete(id),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: operatorKeys.lists() })
+ toast.success(t('operators.deleteSuccess', 'Operator üstünlikli pozuldy'))
+ },
+ onError: () => {
+ toast.error(t('operators.deleteError', 'Operator pozmakda ýalňyşlyk'))
+ },
+ })
+}
+
+// ─── useAssignRole ────────────────────────────────────────────────────────────
+
+export function useAssignRole(operatorId: number) {
+ const queryClient = useQueryClient()
+ const { t } = useTranslation()
+
+ return useMutation({
+ mutationFn: (roleId: number) => operatorsApi.assignRole(operatorId, roleId),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: operatorKeys.detail(operatorId) })
+ toast.success(t('operators.roleAssigned', 'Rol birikdirildi'))
+ },
+ onError: () => {
+ toast.error(t('operators.roleAssignError', 'Rol birikdirmekde ýalňyşlyk'))
+ },
+ })
+}
+
+// ─── useRemoveRole ────────────────────────────────────────────────────────────
+
+export function useRemoveRole(operatorId: number) {
+ const queryClient = useQueryClient()
+ const { t } = useTranslation()
+
+ return useMutation({
+ mutationFn: (roleId: number) => operatorsApi.removeRole(operatorId, roleId),
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: operatorKeys.detail(operatorId) })
+ toast.success(t('operators.roleRemoved', 'Rol aýryldy'))
+ },
+ onError: () => {
+ toast.error(t('operators.roleRemoveError', 'Rol aýyrmakda ýalňyşlyk'))
+ },
+ })
+}
\ No newline at end of file
diff --git a/src/layouts/DashboardLayout.tsx b/src/layouts/DashboardLayout.tsx
index 2a5e570..221de7b 100644
--- a/src/layouts/DashboardLayout.tsx
+++ b/src/layouts/DashboardLayout.tsx
@@ -327,9 +327,9 @@ function AppSidebar() {
title: t("Users", "Ulanyjylar"),
icon: Users,
items: [
- { title: t("Operators", "Operatorlar"), url: "/users/operators" },
- { title: t("Clients", "Müşderiler"), url: "/users/clients" },
- { title: t("All users", "Ähli ulanyjylar"), url: "/users/all" },
+ { title: t("Operators", "Operatorlar"), url: "/operators" },
+ { title: t("Clients", "Müşderiler"), url: "/clients" },
+ { title: t("All users", "Ähli ulanyjylar"), url: "/all-users" },
],
},
{
diff --git a/src/pages/users/allUsers/index.tsx b/src/pages/users/allUsers/index.tsx
new file mode 100644
index 0000000..7848e10
--- /dev/null
+++ b/src/pages/users/allUsers/index.tsx
@@ -0,0 +1,281 @@
+import { useState } from 'react'
+import { useNavigate } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from 'lucide-react'
+
+import { DataTable, type ColumnDef } from '@/components/dataTable'
+import { DataTableToolbar, type ActiveFilter } from '@/components/dataTableToolbar'
+import { Button } from '@/components/ui/button'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@/components/ui/alert-dialog'
+import type { VisibilityState } from '@tanstack/react-table'
+
+import { useUsers, useDeleteUser } from '@/features/allUsers/hooks/useAllUsers'
+import type { UserListItem } from '@/features/allUsers/api/allUsersApi'
+
+// ─── Constants ────────────────────────────────────────────────────────────────
+
+const DEFAULT_PER_PAGE = 25
+
+// ─── UsersListPage ────────────────────────────────────────────────────────────
+
+export default function UsersListPage() {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+ const deleteUser = useDeleteUser()
+
+ // Table state
+ const [page, setPage] = useState(1)
+ const [perPage, setPerPage] = useState(DEFAULT_PER_PAGE)
+ const [search, setSearch] = useState('')
+ const [activeFilters, setActiveFilters] = useState([])
+ const [columnVisibility, setColumnVisibility] = useState({})
+ const [columnOrder, setColumnOrder] = useState([
+ 'id', 'username', 'name', 'phone', 'email', 'isActive', 'actions',
+ ])
+
+ // Delete confirm dialog
+ const [deleteTarget, setDeleteTarget] = useState(null)
+
+ // ── Derived filter values ───────────────────────────────────────────────────
+ const isActiveFilter = activeFilters.find((f) => f.fieldId === 'isActive')?.value ?? ''
+
+ // ── Data fetch ─────────────────────────────────────────────────────────────
+ const { data, isLoading } = useUsers({
+ page,
+ perPage,
+ search,
+ isActive: isActiveFilter || undefined,
+ })
+
+ // ── Handlers ───────────────────────────────────────────────────────────────
+ const handleSearchChange = (value: string) => {
+ setSearch(value)
+ setPage(1)
+ }
+
+ const handleFilterChange = (fieldId: string, value: string) => {
+ setActiveFilters((prev) => {
+ const rest = prev.filter((f) => f.fieldId !== fieldId)
+ return value ? [...rest, { fieldId, value }] : rest
+ })
+ setPage(1)
+ }
+
+ const handleFilterReset = () => {
+ setActiveFilters([])
+ setPage(1)
+ }
+
+ const handleDeleteConfirm = async () => {
+ if (!deleteTarget) return
+ await deleteUser.mutateAsync(deleteTarget.id)
+ setDeleteTarget(null)
+ }
+
+ // ── Columns ────────────────────────────────────────────────────────────────
+ const columns: ColumnDef[] = [
+ {
+ accessorKey: 'id',
+ header: 'ID',
+ size: 80,
+ cell: ({ row }) => (
+
+ {row.original.id}
+
+ ),
+ },
+ {
+ accessorKey: 'username',
+ header: t('users.fields.username', 'ULANYJY ADY'),
+ enableSorting: true,
+ cell: ({ row }) => (
+
+ {row.original.username}
+
+ ),
+ },
+ {
+ accessorKey: 'name',
+ header: t('users.fields.name', 'ADY'),
+ enableSorting: true,
+ cell: ({ row }) => (
+ {row.original.name}
+ ),
+ },
+ {
+ accessorKey: 'phone',
+ header: t('users.fields.phone', 'TELEFON'),
+ cell: ({ row }) => (
+ {row.original.phone}
+ ),
+ },
+ {
+ accessorKey: 'email',
+ header: t('users.fields.email', 'E-POÇTA'),
+ enableSorting: true,
+ cell: ({ row }) => (
+
+ {row.original.email ?? '—'}
+
+ ),
+ },
+ {
+ accessorKey: 'isActive',
+ header: t('users.fields.isActive', 'IŞJEŇ'),
+ size: 80,
+ cell: ({ row }) =>
+ row.original.isActive ? (
+
+ ) : (
+
+ ),
+ },
+ {
+ id: 'actions',
+ header: '',
+ size: 100,
+ enableHiding: false,
+ cell: ({ row }) => (
+
+
+
+
+
+ ),
+ },
+ ]
+
+ const columnMetas = columns
+ .filter((c) => 'accessorKey' in c || (c.id && c.id !== 'actions' && c.id !== 'select'))
+ .map((c) => ({
+ id: 'accessorKey' in c ? (c.accessorKey as string) : (c.id as string),
+ label:
+ typeof c.header === 'string'
+ ? c.header
+ : 'accessorKey' in c
+ ? (c.accessorKey as string)
+ : (c.id as string),
+ }))
+
+ // ── Render ─────────────────────────────────────────────────────────────────
+ return (
+
+ {/* Page header */}
+
+
+
+ {t('users.title', 'Ulanyjylar')}
+
+
+
+ {/* Toolbar */}
+
{ setPerPage(v); setPage(1) }}
+ actionLabel={t('users.actions.create', 'Ulanyjy dörediň')}
+ onAction={() => navigate('/all-users/create')}
+ />
+
+ {/* Table */}
+ String(row.id)}
+ currentPage={page}
+ totalPages={data?.totalPages ?? 1}
+ totalCount={data?.total}
+ onPageChange={setPage}
+ />
+
+ {/* Delete confirm dialog */}
+ !o && setDeleteTarget(null)}>
+
+
+
+ {t('users.deleteDialog.title', 'Ulanyjyny öçürmek')}
+
+
+ {t(
+ 'users.deleteDialog.description',
+ 'Siz "{name}" ulanyjysyny öçürjekmi? Bu amal yzyna gaýtarylyp bilinmez.',
+ ).replace('{name}', deleteTarget?.username ?? '')}
+
+
+
+ {t('common.cancel', 'Ýok')}
+
+ {t('common.delete', 'Öçür')}
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/users/allUsersCreate/index.tsx b/src/pages/users/allUsersCreate/index.tsx
new file mode 100644
index 0000000..72144a6
--- /dev/null
+++ b/src/pages/users/allUsersCreate/index.tsx
@@ -0,0 +1,44 @@
+import { useTranslation } from 'react-i18next'
+import { useNavigate } from 'react-router-dom'
+import { ChevronRight } from 'lucide-react'
+import { UserForm } from '@/features/allUsers/components/allUsersForm'
+
+// ─── UserCreatePage ───────────────────────────────────────────────────────────
+
+export default function UserCreatePage() {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+
+ return (
+
+ {/* Breadcrumb */}
+
+
+ {/* Title */}
+
+ {t('users.actions.create', 'Ulanyjy dörediň')}
+
+
+ {/* Shared form — create mode */}
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/users/allUsersEdit/index.tsx b/src/pages/users/allUsersEdit/index.tsx
new file mode 100644
index 0000000..1839f35
--- /dev/null
+++ b/src/pages/users/allUsersEdit/index.tsx
@@ -0,0 +1,45 @@
+import { useParams } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { Loader2 } from 'lucide-react'
+import { UserForm } from '@/features/allUsers/components/allUsersForm'
+import { useUser } from '@/features/allUsers/hooks/useAllUsers'
+
+// ─── UserEditPage ─────────────────────────────────────────────────────────────
+
+export default function UserEditPage() {
+ const { t } = useTranslation()
+ const { id } = useParams<{ id: string }>()
+ const userId = Number(id)
+
+ const { data: user, isLoading, isError } = useUser(userId)
+
+ if (isLoading) {
+ return (
+
+
+
+ )
+ }
+
+ if (isError || !user) {
+ return (
+
+ {t('common.notFound', 'Maglumat tapylmady')}
+
+ )
+ }
+
+ return (
+
+
+
+ {/* Title */}
+
+ {t('users.editTitle', 'Ulanyjy giňişleýin')}: {user.name} ({user.username})
+
+
+ {/* Shared form — edit mode, passes fetched data */}
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/users/allUsersView/index.tsx b/src/pages/users/allUsersView/index.tsx
new file mode 100644
index 0000000..3c46c6a
--- /dev/null
+++ b/src/pages/users/allUsersView/index.tsx
@@ -0,0 +1,284 @@
+import { useState } from 'react'
+import { useNavigate, useParams } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import {
+ ChevronRight,
+ Loader2,
+ Pencil,
+ Trash2,
+ CheckCircle2,
+ XCircle,
+ ChevronDown,
+ Plus,
+ Search,
+ SlidersHorizontal,
+ ChevronUp,
+} from 'lucide-react'
+import { Button } from '@/components/ui/button'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@/components/ui/alert-dialog'
+import { Section, InfoRow } from '@/components/viewPageComponents'
+import { useUser, useDeleteUser } from '@/features/allUsers/hooks/useAllUsers'
+
+// ─── Collapsible Section ──────────────────────────────────────────────────────
+
+interface CollapsibleBlockProps {
+ title: string
+ actionLabel: string
+ onAction: () => void
+ emptyMessage: string
+ searchPlaceholder?: string
+ showFilter?: boolean
+}
+
+function CollapsibleBlock({
+ title,
+ actionLabel,
+ onAction,
+ emptyMessage,
+ searchPlaceholder = 'Gözlemek',
+ showFilter = false,
+}: CollapsibleBlockProps) {
+ const [open, setOpen] = useState(true)
+ const [search, setSearch] = useState('')
+
+ return (
+
+
+
+ {open && (
+
+ {/* Sub-toolbar */}
+
+
+
+ setSearch(e.target.value)}
+ placeholder={searchPlaceholder}
+ className="h-8 pl-8 pr-3 rounded-md border border-border bg-background text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring w-48"
+ />
+
+
+ {showFilter && (
+
+ )}
+
+
+
+
+ {/* Empty state */}
+
+
+
{emptyMessage}
+
+
+
+ )}
+
+ )
+}
+
+// ─── 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 handleDeleteConfirm = async () => {
+ await deleteUser.mutateAsync(userId)
+ navigate('/users')
+ }
+
+ if (isLoading) {
+ return (
+
+
+
+ )
+ }
+
+ if (isError || !user) {
+ return (
+
+ {t('common.notFound', 'Maglumat tapylmady')}
+
+ )
+ }
+
+ return (
+
+ {/* Breadcrumb */}
+
+
+ {/* Title + actions */}
+
+
+ {t('users.viewTitle', 'Ulanyjy giňişleýin')}: {user.name} ({user.username})
+
+
+
+
+
+
+
+ {/* Main info */}
+
+
+
+
+
+
+
+ {user.isActive ? (
+
+ ) : (
+
+ )}
+
+
+
+ {/* Rollar */}
+
{}}
+ emptyMessage={t('users.empty.roles', 'Berlen kriteriýalara Rol gabat gelmedi.')}
+ searchPlaceholder={t('common.search', 'Gözlemek')}
+ />
+
+ {/* Rugsatlar */}
+ {}}
+ emptyMessage={t('users.empty.permissions', 'Berlen kriteriýalara Rugsat gabat gelmedi.')}
+ searchPlaceholder={t('common.search', 'Gözlemek')}
+ />
+
+ {/* Şahamçalar */}
+ {}}
+ emptyMessage={t('users.empty.branches', 'Berlen kriteriýalara Şahamça gabat gelmedi.')}
+ searchPlaceholder={t('common.search', 'Gözlemek')}
+ showFilter
+ />
+
+ {/* Ammallar */}
+ {}}
+ emptyMessage={t('users.empty.audit', 'Berlen kriteriýalara Hereket gabat gelmedi.')}
+ searchPlaceholder={t('common.search', 'Gözlemek')}
+ />
+
+ {/* 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')}
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/users/clients/index.tsx b/src/pages/users/clients/index.tsx
new file mode 100644
index 0000000..004feb6
--- /dev/null
+++ b/src/pages/users/clients/index.tsx
@@ -0,0 +1,227 @@
+import { useState } from 'react'
+import { useNavigate } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { Trash2, Eye, Pencil } from 'lucide-react'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@/components/ui/alert-dialog'
+import { Button } from '@/components/ui/button'
+import { DataTable, type ColumnDef } from '@/components/dataTable'
+import { DataTableToolbar } from '@/components/dataTableToolbar'
+import { useClients, useDeleteClient } from '@/features/clients/hooks/useClients'
+import type { Client } from '@/features/clients/api/clientsApi'
+
+export default function ClientsPage() {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+ const deleteMutation = useDeleteClient()
+
+ const [page, setPage] = useState(1)
+ const [perPage, setPerPage] = useState(25)
+ const [search, setSearch] = useState('')
+ const [isActiveFilter, setIsActiveFilter] = useState('')
+ const [columnVisibility, setColumnVisibility] = useState({})
+ const [columnOrder, setColumnOrder] = useState([])
+
+ const [deleteTarget, setDeleteTarget] = useState(null)
+
+ const { data, isLoading } = useClients({
+ page,
+ perPage,
+ search: search || undefined,
+ isActive: isActiveFilter || undefined,
+ })
+
+ const clients = data?.data ?? []
+ const totalPages = data?.meta.totalPages ?? 1
+ const totalCount = data?.meta.totalCount ?? 0
+
+ const columns: ColumnDef[] = [
+ {
+ accessorKey: 'id',
+ header: 'ID',
+ cell: ({ row }) => (
+ navigate(`/clients/${row.original.id}`)}
+ >
+ {row.original.id}
+
+ ),
+ size: 80,
+ },
+ {
+ accessorKey: 'username',
+ header: t('clients.fields.username', 'ULANYJY ADY'),
+ cell: ({ row }) => {row.original.username},
+ },
+ {
+ accessorKey: 'name',
+ header: t('clients.fields.name', 'ADY'),
+ cell: ({ row }) => {row.original.name},
+ },
+ {
+ accessorKey: 'phone',
+ header: t('clients.fields.phone', 'TELEFON'),
+ cell: ({ row }) => {row.original.phone ?? '—'},
+ },
+ {
+ accessorKey: 'email',
+ header: t('clients.fields.email', 'E-POÇTA'),
+ cell: ({ row }) => {row.original.email ?? '—'},
+ },
+ {
+ accessorKey: 'isActive',
+ header: t('clients.fields.isActive', 'IŞJEŇ'),
+ cell: ({ row }) =>
+ row.original.isActive ? (
+
+
+
+ ) : (
+
+
+
+ ),
+ size: 80,
+ },
+ {
+ id: 'actions',
+ header: '',
+ cell: ({ row }) => (
+
+
+
+
+
+ ),
+ size: 120,
+ enableSorting: false,
+ },
+ ]
+
+ const columnMetas = columns
+ .filter((c) => 'accessorKey' in c && c.accessorKey)
+ .map((c) => ({
+ id: ('accessorKey' in c ? String(c.accessorKey) : c.id) as string,
+ label: typeof c.header === 'string' ? c.header : ('accessorKey' in c ? String(c.accessorKey) : '') ?? '',
+ }))
+
+ return (
+
+
+
+ {t('clients.title', 'Müşderiler')}
+
+
+
+
{ setSearch(v); setPage(1) }}
+ searchPlaceholder={t('common.search', 'Gözlemek')}
+ columns={columnMetas}
+ columnVisibility={columnVisibility}
+ onColumnVisibilityChange={setColumnVisibility}
+ columnOrder={columnOrder}
+ onColumnOrderChange={setColumnOrder}
+ filterFields={[
+ {
+ id: 'isActive',
+ label: t('clients.fields.isActive', 'Işjeň'),
+ options: [
+ { value: 'true', label: t('common.active', 'Işjeň') },
+ { value: 'false', label: t('common.inactive', 'Işjeň däl') },
+ ],
+ },
+ ]}
+ activeFilters={[{ fieldId: 'isActive', value: isActiveFilter }]}
+ onFilterChange={(fieldId, value) => {
+ if (fieldId === 'isActive') setIsActiveFilter(value)
+ setPage(1)
+ }}
+ onFilterReset={() => { setIsActiveFilter(''); setPage(1) }}
+ perPageOptions={[10, 25, 50, 100]}
+ perPage={perPage}
+ onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
+ actionLabel={t('clients.createBtn', 'Müşderi dörediň')}
+ onAction={() => navigate('/clients/create')}
+ />
+
+ String(row.id)}
+ currentPage={page}
+ totalPages={totalPages}
+ totalCount={totalCount}
+ onPageChange={setPage}
+ enableRowSelection
+ />
+
+ !open && setDeleteTarget(null)}>
+
+
+ {t('clients.deleteTitle', 'Müşderini pozmak')}
+
+ {t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.', {
+ name: deleteTarget?.name ?? '',
+ })}
+
+
+
+ {t('common.cancel', 'Ýatyr')}
+ {
+ if (deleteTarget) {
+ deleteMutation.mutate(deleteTarget.id, {
+ onSuccess: () => setDeleteTarget(null),
+ })
+ }
+ }}
+ >
+ {t('common.delete', 'Poz')}
+
+
+
+
+
+ )
+}
diff --git a/src/pages/users/clientsCreate/index.tsx b/src/pages/users/clientsCreate/index.tsx
new file mode 100644
index 0000000..f03fa2d
--- /dev/null
+++ b/src/pages/users/clientsCreate/index.tsx
@@ -0,0 +1,34 @@
+import { useTranslation } from 'react-i18next'
+import { useNavigate } from 'react-router-dom'
+import { ChevronRight } from 'lucide-react'
+import { ClientForm } from '@/features/clients/components/clientForm'
+
+export default function ClientCreatePage() {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+
+ return (
+
+ {/* Breadcrumb */}
+
+
+ {/* Page heading */}
+
+ {t('clients.createTitle', 'Müşderi dörediň')}
+
+
+
+
+ )
+}
diff --git a/src/pages/users/clientsEdit/index.tsx b/src/pages/users/clientsEdit/index.tsx
new file mode 100644
index 0000000..a8aca47
--- /dev/null
+++ b/src/pages/users/clientsEdit/index.tsx
@@ -0,0 +1,37 @@
+import { useParams } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { ClientForm } from '@/features/clients/components/clientForm'
+import { useClient } from '@/features/clients/hooks/useClients'
+
+export default function ClientEditPage() {
+ const { id } = useParams<{ id: string }>()
+ const clientId = Number(id)
+ const { t } = useTranslation()
+
+ const { data: client, isLoading } = useClient(clientId)
+
+ return (
+
+
+
+ {/* Page heading */}
+
+ {t('clients.editTitle', 'Müşderi üýtget')}: {client?.name ?? ''}
+
+
+ {isLoading ? (
+
+ {Array.from({ length: 6 }).map((_, i) => (
+
+ ))}
+
+ ) : (
+
+ )}
+
+ )
+}
diff --git a/src/pages/users/clientsView/index.tsx b/src/pages/users/clientsView/index.tsx
new file mode 100644
index 0000000..7752443
--- /dev/null
+++ b/src/pages/users/clientsView/index.tsx
@@ -0,0 +1,294 @@
+import { useParams, useNavigate } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { Pencil, Trash2, ChevronDown, ChevronRight } from 'lucide-react'
+import { useState } from 'react'
+import { Button } from '@/components/ui/button'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@/components/ui/alert-dialog'
+import { Section, InfoRow, AuditLog } from '@/components/viewPageComponents'
+import { DataTable, type ColumnDef } from '@/components/dataTable'
+import { DataTableToolbar } from '@/components/dataTableToolbar'
+import { useClient, useDeleteClient } from '@/features/clients/hooks/useClients'
+import type { ClientRole, ClientBranch, ClientAuditLog } from '@/features/clients/api/clientsApi'
+
+export default function ClientDetailPage() {
+ const { id } = useParams<{ id: string }>()
+ const clientId = Number(id)
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+ const deleteMutation = useDeleteClient()
+
+ const { data: client, isLoading } = useClient(clientId)
+
+ const [deleteOpen, setDeleteOpen] = useState(false)
+ const [roleSearch, setRoleSearch] = useState('')
+ const [permSearch, setPermSearch] = useState('')
+ const [branchSearch, setBranchSearch] = useState('')
+ const [loanSearch, setLoanSearch] = useState('')
+ const [cardSearch, setCardSearch] = useState('')
+
+ const roleColumns: ColumnDef[] = [
+ {
+ accessorKey: 'id',
+ header: 'ID',
+ cell: ({ row }) => {row.original.id},
+ size: 80,
+ },
+ {
+ accessorKey: 'code',
+ header: t('roles.fields.code', 'KOD'),
+ cell: ({ row }) => {row.original.code},
+ },
+ {
+ accessorKey: 'name',
+ header: t('roles.fields.name', 'ADY'),
+ cell: ({ row }) => {row.original.name},
+ },
+ {
+ accessorKey: 'guardName',
+ header: t('roles.fields.guardName', 'GUARD NAME'),
+ cell: ({ row }) => {row.original.guardName},
+ },
+ {
+ id: 'actions',
+ header: '',
+ cell: () => (
+
+
+
+ ),
+ size: 60,
+ },
+ ]
+
+ const branchColumns: ColumnDef[] = [
+ {
+ accessorKey: 'id',
+ header: 'ID',
+ cell: ({ row }) => {row.original.id},
+ size: 60,
+ },
+ {
+ accessorKey: 'name',
+ header: t('branches.fields.name', 'ADY'),
+ cell: ({ row }) => {row.original.name},
+ },
+ {
+ accessorKey: 'region',
+ header: t('branches.fields.region', 'WELAÝAT'),
+ cell: ({ row }) => {row.original.region},
+ },
+ {
+ accessorKey: 'district',
+ header: t('branches.fields.district', 'ETRAP'),
+ cell: ({ row }) => {row.original.district},
+ },
+ {
+ accessorKey: 'uniqueCode',
+ header: t('branches.fields.uniqueCode', 'UNIKAL BELGI'),
+ cell: ({ row }) => {row.original.uniqueCode},
+ },
+ {
+ id: 'actions',
+ header: '',
+ cell: () => (
+
+
+
+ ),
+ size: 60,
+ },
+ ]
+
+ if (isLoading) {
+ return (
+
+ {Array.from({ length: 3 }).map((_, i) => (
+
+ ))}
+
+ )
+ }
+
+ if (!client) return null
+
+ const auditLogs = (client.auditLogs ?? []).map((log: ClientAuditLog) => ({
+ id: String(log.id),
+ action: log.actionName,
+ by: log.performedBy,
+ target: log.target,
+ status: log.status,
+ date: log.createdAt,
+ }))
+
+ const filteredRoles = (client.roles ?? []).filter((r) =>
+ r.name.toLowerCase().includes(roleSearch.toLowerCase()) || r.code.toLowerCase().includes(roleSearch.toLowerCase()),
+ )
+
+ const filteredBranches = (client.branches ?? []).filter((b) =>
+ b.name.toLowerCase().includes(branchSearch.toLowerCase()),
+ )
+
+ return (
+
+
+
+
+
+ {t('clients.detailTitle', 'Müşderi giňişleýin')}: {client.name}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {client.isActive ? (
+
+
+
+ ) : (
+
+
+
+ )}
+
+
+
+
{}}>
+ {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
+ {(filteredRoles.length > 0) ? (
+ String(r.id)} enableRowSelection />
+ ) : (
+ {}} />
+ )}
+
+
+
{}}>
+ {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
+ {(client.permissions ?? []).length === 0 ? (
+ {}} />
+ ) : null}
+
+
+
{}}>
+ {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
+ {(filteredBranches.length > 0) ? (
+ String(r.id)} enableRowSelection />
+ ) : (
+ {}} />
+ )}
+
+
+
{}}>
+ {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
+ {(client.loanOrders ?? []).length === 0 ? (
+ {}} />
+ ) : null}
+
+
+
{}}>
+ {}} columnOrder={[]} onColumnOrderChange={() => {}} hideAction />
+ {(client.cardOrders ?? []).length === 0 ? (
+ {}} />
+ ) : null}
+
+
+
+
+
+
+
+ {t('clients.deleteTitle', 'Müşderini pozmak')}
+
+ {t('clients.deleteConfirm', '{{name}} müşderisini pozmak isleýärsiňizmi?', { name: client.name })}
+
+
+
+ {t('common.cancel', 'Ýatyr')}
+ deleteMutation.mutate(clientId, { onSuccess: () => navigate('/clients') })}>
+ {t('common.delete', 'Poz')}
+
+
+
+
+
+ )
+}
+
+interface CollapsibleSectionProps { title: string; actionLabel: string; onAction: () => void; children: React.ReactNode }
+function CollapsibleSection({ title, actionLabel, onAction, children }: CollapsibleSectionProps) {
+ const [open, setOpen] = useState(true)
+ return (
+
+
setOpen((v) => !v)}>
+
{title}
+
+
+ {open && (
+
+
+
+
+ {children}
+
+ )}
+
+ )
+}
+
+interface EmptyStateProps { label: string; actionLabel: string; onAction: () => void }
+function EmptyState({ label, actionLabel, onAction }: EmptyStateProps) {
+ return (
+
+
+
{label}
+
+
+ )
+}
diff --git a/src/pages/users/operators/index.tsx b/src/pages/users/operators/index.tsx
new file mode 100644
index 0000000..c02fd2d
--- /dev/null
+++ b/src/pages/users/operators/index.tsx
@@ -0,0 +1,271 @@
+import { useState } from 'react'
+import { useNavigate } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { Trash2, Eye, Pencil } from 'lucide-react'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@/components/ui/alert-dialog'
+import { Button } from '@/components/ui/button'
+import { DataTable, type ColumnDef } from '@/components/dataTable'
+import { DataTableToolbar } from '@/components/dataTableToolbar'
+import { useOperators, useDeleteOperator } from '@/features/operators/hooks/useOperators'
+import type { Operator } from '@/features/operators/api/operatorsApi'
+
+// ─── OperatorsPage ────────────────────────────────────────────────────────────
+
+export default function OperatorsPage() {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+ const deleteMutation = useDeleteOperator()
+
+ // ── Table state ─────────────────────────────────────────────────────────────
+ const [page, setPage] = useState(1)
+ const [perPage, setPerPage] = useState(25)
+ const [search, setSearch] = useState('')
+ const [isActiveFilter, setIsActiveFilter] = useState('')
+ const [columnVisibility, setColumnVisibility] = useState({})
+ const [columnOrder, setColumnOrder] = useState([])
+
+ // ── Delete dialog ────────────────────────────────────────────────────────────
+ const [deleteTarget, setDeleteTarget] = useState(null)
+
+ // ── Query ────────────────────────────────────────────────────────────────────
+ const { data, isLoading } = useOperators({
+ page,
+ perPage,
+ search: search || undefined,
+ isActive: isActiveFilter || undefined,
+ })
+
+ const operators = data?.data ?? []
+ const totalPages = data?.meta.totalPages ?? 1
+ const totalCount = data?.meta.totalCount ?? 0
+
+ // ── Columns ──────────────────────────────────────────────────────────────────
+ const columns: ColumnDef[] = [
+ {
+ accessorKey: 'id',
+ header: 'ID',
+ cell: ({ row }) => (
+ navigate(`/operators/${row.original.id}`)}
+ >
+ {row.original.id}
+
+ ),
+ size: 80,
+ },
+ {
+ accessorKey: 'username',
+ header: t('operators.fields.username', 'ULANYJY ADY'),
+ cell: ({ row }) => (
+ {row.original.username}
+ ),
+ },
+ {
+ accessorKey: 'name',
+ header: t('operators.fields.name', 'ADY'),
+ cell: ({ row }) => (
+ {row.original.name}
+ ),
+ },
+ {
+ accessorKey: 'phone',
+ header: t('operators.fields.phone', 'TELEFON'),
+ cell: ({ row }) => (
+
+ {row.original.phone ?? '—'}
+
+ ),
+ },
+ {
+ accessorKey: 'email',
+ header: t('operators.fields.email', 'E-POÇTA'),
+ cell: ({ row }) => (
+
+ {row.original.email ?? '—'}
+
+ ),
+ },
+ {
+ accessorKey: 'isActive',
+ header: t('operators.fields.isActive', 'IŞJEŇ'),
+ cell: ({ row }) =>
+ row.original.isActive ? (
+
+
+
+ ) : (
+
+
+
+ ),
+ size: 80,
+ },
+ {
+ id: 'actions',
+ header: '',
+ cell: ({ row }) => (
+
+
+
+
+
+ ),
+ size: 120,
+ enableSorting: false,
+ },
+ ]
+
+ const columnMetas = columns
+ .filter((c) => 'accessorKey' in c && c.accessorKey)
+ .map((c) => ({
+ id: ('accessorKey' in c ? String(c.accessorKey) : c.id) as string,
+ label:
+ typeof c.header === 'string'
+ ? c.header
+ : ('accessorKey' in c ? String(c.accessorKey) : '') ?? '',
+ }))
+
+ // ── Render ───────────────────────────────────────────────────────────────────
+ return (
+
+ {/* Page header */}
+
+
+ {t('operators.title', 'Operatorlar')}
+
+
+
+ {/* Toolbar */}
+
{ setSearch(v); setPage(1) }}
+ searchPlaceholder={t('common.search', 'Gözlemek')}
+ columns={columnMetas}
+ columnVisibility={columnVisibility}
+ onColumnVisibilityChange={setColumnVisibility}
+ columnOrder={columnOrder}
+ onColumnOrderChange={setColumnOrder}
+ filterFields={[
+ {
+ id: 'isActive',
+ label: t('operators.fields.isActive', 'Işjeň'),
+ options: [
+ { value: 'true', label: t('common.active', 'Işjeň') },
+ { value: 'false', label: t('common.inactive', 'Işjeň däl') },
+ ],
+ },
+ ]}
+ activeFilters={[{ fieldId: 'isActive', value: isActiveFilter }]}
+ onFilterChange={(fieldId, value) => {
+ if (fieldId === 'isActive') setIsActiveFilter(value)
+ setPage(1)
+ }}
+ onFilterReset={() => { setIsActiveFilter(''); setPage(1) }}
+ perPageOptions={[10, 25, 50, 100]}
+ perPage={perPage}
+ onPerPageChange={(v) => { setPerPage(v); setPage(1) }}
+ actionLabel={t('operators.createBtn', 'Operator döredin')}
+ onAction={() => navigate('/operators/create')}
+ />
+
+ {/* Table */}
+ String(row.id)}
+ currentPage={page}
+ totalPages={totalPages}
+ totalCount={totalCount}
+ onPageChange={setPage}
+ enableRowSelection
+ />
+
+ {/* Delete dialog */}
+ !open && setDeleteTarget(null)}
+ >
+
+
+
+ {t('operators.deleteTitle', 'Operatory pozmak')}
+
+
+ {t(
+ 'operators.deleteConfirm',
+ '{{name}} operatoryny pozmak isleýärsiňizmi? Bu amaly yzyna gaýtaryp bolmaz.',
+ { name: deleteTarget?.name ?? '' },
+ )}
+
+
+
+ {t('common.cancel', 'Ýatyr')}
+ {
+ if (deleteTarget) {
+ deleteMutation.mutate(deleteTarget.id, {
+ onSuccess: () => setDeleteTarget(null),
+ })
+ }
+ }}
+ >
+ {t('common.delete', 'Poz')}
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/users/operatorsCreate/index.tsx b/src/pages/users/operatorsCreate/index.tsx
new file mode 100644
index 0000000..15d17b4
--- /dev/null
+++ b/src/pages/users/operatorsCreate/index.tsx
@@ -0,0 +1,36 @@
+// ─── OperatorCreatePage.tsx ───────────────────────────────────────────────────
+
+import { useTranslation } from 'react-i18next'
+import { useNavigate } from 'react-router-dom'
+import { ChevronRight } from 'lucide-react'
+import { OperatorForm } from '@/features/operators/components/operatorForms'
+
+export default function OperatorCreatePage() {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+
+ return (
+
+ {/* Breadcrumb */}
+
+
+ {/* Page heading */}
+
+ {t('operators.createTitle', 'Operator döredin')}
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/users/operatorsEdit/index.tsx b/src/pages/users/operatorsEdit/index.tsx
new file mode 100644
index 0000000..1c543e2
--- /dev/null
+++ b/src/pages/users/operatorsEdit/index.tsx
@@ -0,0 +1,37 @@
+// ─── OperatorEditPage.tsx ─────────────────────────────────────────────────────
+
+import { useParams, } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { OperatorForm } from '@/features/operators/components/operatorForms'
+import { useOperator } from '@/features/operators/hooks/useOperators'
+
+export default function OperatorEditPage() {
+ const { id } = useParams<{ id: string }>()
+ const operatorId = Number(id)
+ const { t } = useTranslation()
+
+ const { data: operator, isLoading } = useOperator(operatorId)
+
+ return (
+
+ {/* Page heading */}
+
+ {t('operators.editTitle', 'Operator üýtget')}: {operator?.name ?? ''}
+
+
+ {isLoading ? (
+
+ {Array.from({ length: 6 }).map((_, i) => (
+
+ ))}
+
+ ) : (
+
+ )}
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/users/operatorsView/index.tsx b/src/pages/users/operatorsView/index.tsx
new file mode 100644
index 0000000..175540e
--- /dev/null
+++ b/src/pages/users/operatorsView/index.tsx
@@ -0,0 +1,457 @@
+import { useParams, useNavigate } from 'react-router-dom'
+import { useTranslation } from 'react-i18next'
+import { Pencil, Trash2, ChevronDown } from 'lucide-react'
+import { useState } from 'react'
+import { Button } from '@/components/ui/button'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from '@/components/ui/alert-dialog'
+import { Section, InfoRow, AuditLog } from '@/components/viewPageComponents'
+import { DataTable, type ColumnDef } from '@/components/dataTable'
+import { DataTableToolbar } from '@/components/dataTableToolbar'
+import { useOperator, useDeleteOperator } from '@/features/operators/hooks/useOperators'
+import type { OperatorRole, OperatorBranch, OperatorAuditLog } from '@/features/operators/api/operatorsApi'
+
+// ─── OperatorDetailPage ───────────────────────────────────────────────────────
+
+export default function OperatorDetailPage() {
+ const { id } = useParams<{ id: string }>()
+ const operatorId = Number(id)
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+ const deleteMutation = useDeleteOperator()
+
+ const { data: operator, isLoading } = useOperator(operatorId)
+
+ const [deleteOpen, setDeleteOpen] = useState(false)
+ const [roleSearch, setRoleSearch] = useState('')
+ const [permSearch, setPermSearch] = useState('')
+ const [branchSearch, setBranchSearch] = useState('')
+
+ // ── Role columns ──────────────────────────────────────────────────────────
+ const roleColumns: ColumnDef[] = [
+ {
+ accessorKey: 'id',
+ header: 'ID',
+ cell: ({ row }) => (
+ {row.original.id}
+ ),
+ size: 80,
+ },
+ {
+ accessorKey: 'code',
+ header: t('roles.fields.code', 'KOD'),
+ cell: ({ row }) => {row.original.code},
+ },
+ {
+ accessorKey: 'name',
+ header: t('roles.fields.name', 'ADY'),
+ cell: ({ row }) => {row.original.name},
+ },
+ {
+ accessorKey: 'guardName',
+ header: t('roles.fields.guardName', 'GUARD NAME'),
+ cell: ({ row }) => {row.original.guardName},
+ },
+ {
+ id: 'actions',
+ header: '',
+ cell: ({ row }) => (
+
+
+
+
+
+ ),
+ size: 120,
+ },
+ ]
+
+ // ── Branch columns ────────────────────────────────────────────────────────
+ const branchColumns: ColumnDef[] = [
+ {
+ accessorKey: 'id',
+ header: 'ID',
+ cell: ({ row }) => (
+ {row.original.id}
+ ),
+ size: 60,
+ },
+ {
+ accessorKey: 'name',
+ header: t('branches.fields.name', 'ADY'),
+ cell: ({ row }) => {row.original.name},
+ },
+ {
+ accessorKey: 'region',
+ header: t('branches.fields.region', 'WELAÝAT'),
+ cell: ({ row }) => {row.original.region},
+ },
+ {
+ accessorKey: 'district',
+ header: t('branches.fields.district', 'ETRAP'),
+ cell: ({ row }) => {row.original.district},
+ },
+ {
+ accessorKey: 'uniqueCode',
+ header: t('branches.fields.uniqueCode', 'UNIKAL BELGI'),
+ cell: ({ row }) => {row.original.uniqueCode},
+ },
+ {
+ accessorKey: 'isActive',
+ header: t('branches.fields.isActive', 'IŞJEŇ'),
+ cell: ({ row }) =>
+ row.original.isActive ? (
+
+
+
+ ) : (
+
+
+
+ ),
+ size: 80,
+ },
+ {
+ accessorKey: 'billingUsernameIbr',
+ header: t('branches.fields.billingIbr', 'BILLING ULANYJY ADY'),
+ cell: ({ row }) => {row.original.billingUsernameIbr},
+ },
+ {
+ accessorKey: 'billingUsernameSber',
+ header: t('branches.fields.billingSber', 'BILLING USERNAME (SBER)'),
+ cell: ({ row }) => {row.original.billingUsernameSber},
+ },
+ {
+ accessorKey: 'billingUsernameVisa',
+ header: t('branches.fields.billingVisa', 'BILLING USERNAME (VISA)'),
+ cell: ({ row }) => {row.original.billingUsernameVisa},
+ },
+ {
+ id: 'actions',
+ header: '',
+ cell: () => (
+
+
+
+ ),
+ size: 60,
+ },
+ ]
+
+ if (isLoading) {
+ return (
+
+ {Array.from({ length: 3 }).map((_, i) => (
+
+ ))}
+
+ )
+ }
+
+ if (!operator) return null
+
+ // Map audit logs to AuditLog component format
+ const auditLogs = (operator.auditLogs ?? []).map((log: OperatorAuditLog) => ({
+ id: String(log.id),
+ action: log.actionName,
+ by: log.performedBy,
+ target: log.target,
+ status: log.status,
+ date: log.createdAt,
+ }))
+
+ const filteredRoles = (operator.roles ?? []).filter(
+ (r) =>
+ r.name.toLowerCase().includes(roleSearch.toLowerCase()) ||
+ r.code.toLowerCase().includes(roleSearch.toLowerCase()),
+ )
+
+ const filteredBranches = (operator.branches ?? []).filter((b) =>
+ b.name.toLowerCase().includes(branchSearch.toLowerCase()),
+ )
+
+ return (
+
+ {/* Page header */}
+
+
+ {t('operators.detailTitle', 'Operator giňişleýin')}: {operator.name}
+
+
+
+
+
+
+
+ {/* Basic info */}
+
+
+
+
+
+
+
+ {operator.isActive ? (
+
+
+
+ ) : (
+
+
+
+ )}
+
+
+
+ {/* Roles */}
+
{/* open role assign modal */}}
+ >
+ {}}
+ columnOrder={[]}
+ onColumnOrderChange={() => {}}
+ hideAction
+ />
+ String(r.id)}
+ enableRowSelection
+ />
+
+
+ {/* Permissions */}
+
{/* open permission modal */}}
+ >
+ {}}
+ columnOrder={[]}
+ onColumnOrderChange={() => {}}
+ hideAction
+ />
+ {(operator.permissions ?? []).length === 0 ? (
+ {}} />
+ ) : null}
+
+
+ {/* Branches */}
+
{}}
+ >
+ {}}
+ columnOrder={[]}
+ onColumnOrderChange={() => {}}
+ hideAction
+ />
+ String(r.id)}
+ enableRowSelection
+ />
+
+
+ {/* Karz sargyt */}
+
{}}
+ >
+ {(operator.loanLimits ?? []).length === 0 ? (
+ {}} />
+ ) : null}
+
+
+ {/* Kart sargyt */}
+
{}}
+ >
+ {(operator.cardLimits ?? []).length === 0 ? (
+ {}} />
+ ) : null}
+
+
+ {/* Audit log */}
+
+
+ {/* Delete dialog */}
+
+
+
+ {t('operators.deleteTitle', 'Operatory pozmak')}
+
+ {t('operators.deleteConfirm', '{{name}} operatoryny pozmak isleýärsiňizmi?', {
+ name: operator.name,
+ })}
+
+
+
+ {t('common.cancel', 'Ýatyr')}
+
+ deleteMutation.mutate(operatorId, {
+ onSuccess: () => navigate('/operators'),
+ })
+ }
+ >
+ {t('common.delete', 'Poz')}
+
+
+
+
+
+ )
+}
+
+// ─── CollapsibleSection ───────────────────────────────────────────────────────
+
+interface CollapsibleSectionProps {
+ title: string
+ actionLabel: string
+ onAction: () => void
+ children: React.ReactNode
+}
+
+function CollapsibleSection({ title, actionLabel, onAction, children }: CollapsibleSectionProps) {
+ const [open, setOpen] = useState(true)
+
+ return (
+
+
setOpen((v) => !v)}
+ >
+
{title}
+
+
+ {open && (
+
+
+
+
+ {children}
+
+ )}
+
+ )
+}
+
+// ─── EmptyState ───────────────────────────────────────────────────────────────
+
+interface EmptyStateProps {
+ label: string
+ actionLabel: string
+ onAction: () => void
+}
+
+function EmptyState({ label, actionLabel, onAction }: EmptyStateProps) {
+ return (
+
+
+
{label}
+
+
+ )
+}
\ No newline at end of file