Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
118 lines
3.1 KiB
TypeScript
118 lines
3.1 KiB
TypeScript
'use client'
|
|
|
|
import { coerceToString } from '@/helpers'
|
|
import type { PaginationListColumnType } from '@/types'
|
|
import PaginatedList from '@/components/PaginatedList'
|
|
import StatusChip from '@/components/ui/StatusChip'
|
|
import PageNavbar from '@/components/layouts/PageNavbar'
|
|
import AdminTableViewButton from '@/components/ui/AdminTableViewButton'
|
|
import { APP_ROUTES } from '@/constants/routes'
|
|
import {
|
|
getIdentityStatus,
|
|
getUserAccountStatus,
|
|
getUserRole,
|
|
IDENTITY_STATUS_FILTER_ITEMS,
|
|
USER_ACCOUNT_STATUS_FILTER_ITEMS,
|
|
USER_ROLE_FILTER_ITEMS,
|
|
} from '@/constants/status'
|
|
import { API_ROUTES } from '@/services/config'
|
|
import { formatIranianMobile, formatPersianDate } from '@/lib/formatters'
|
|
|
|
const columns: PaginationListColumnType[] = [
|
|
{
|
|
field: 'firstName',
|
|
label: 'نام',
|
|
filterable: true,
|
|
type: 'text',
|
|
sortable: false,
|
|
},
|
|
{
|
|
field: 'lastName',
|
|
label: 'نام خانوادگی',
|
|
filterable: true,
|
|
type: 'text',
|
|
sortable: false,
|
|
},
|
|
{
|
|
field: 'mobile',
|
|
label: 'موبایل',
|
|
filterable: true,
|
|
type: 'text',
|
|
sortable: true,
|
|
},
|
|
{
|
|
field: 'role',
|
|
label: 'نقش',
|
|
filterable: true,
|
|
type: 'select',
|
|
sortable: true,
|
|
filterItems: USER_ROLE_FILTER_ITEMS,
|
|
},
|
|
{
|
|
field: 'status',
|
|
label: 'وضعیت',
|
|
filterable: true,
|
|
type: 'select',
|
|
sortable: true,
|
|
filterItems: USER_ACCOUNT_STATUS_FILTER_ITEMS,
|
|
},
|
|
{
|
|
field: 'identityStatus',
|
|
label: 'احراز هویت',
|
|
filterable: true,
|
|
type: 'select',
|
|
sortable: false,
|
|
filterItems: IDENTITY_STATUS_FILTER_ITEMS,
|
|
},
|
|
{
|
|
field: 'lastLoginAt',
|
|
label: 'آخرین ورود',
|
|
filterable: true,
|
|
sortable: true,
|
|
type: 'dateFromTo',
|
|
},
|
|
{
|
|
field: 'createdAt',
|
|
label: 'تاریخ ثبت',
|
|
filterable: true,
|
|
sortable: true,
|
|
type: 'dateFromTo',
|
|
},
|
|
{
|
|
field: 'actions',
|
|
label: 'عملیات',
|
|
},
|
|
]
|
|
|
|
const UsersPage = () => {
|
|
return (
|
|
<section className="h-full w-full text-right">
|
|
<PageNavbar pageTitle="کاربران" />
|
|
<div className="admin-page-container">
|
|
<PaginatedList
|
|
columns={columns}
|
|
url={API_ROUTES.USERS.ADMIN_LIST}
|
|
>
|
|
{{
|
|
mobile: (_row, cellValue) => formatIranianMobile(cellValue),
|
|
role: (_row, cellValue) => <StatusChip {...getUserRole(coerceToString(cellValue))} />,
|
|
status: (_row, cellValue) => <StatusChip {...getUserAccountStatus(coerceToString(cellValue))} />,
|
|
identityStatus: (_row, cellValue) => <StatusChip {...getIdentityStatus(coerceToString(cellValue))} />,
|
|
lastLoginAt: (_row, cellValue) => formatPersianDate(cellValue),
|
|
createdAt: (_row, cellValue) => formatPersianDate(cellValue),
|
|
actions: (row) => (
|
|
<AdminTableViewButton
|
|
label="مشاهده کاربر"
|
|
mode="navigate"
|
|
to={APP_ROUTES.USER_DETAIL(String(row.id))}
|
|
/>
|
|
),
|
|
}}
|
|
</PaginatedList>
|
|
</div>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
export default UsersPage
|