2025-12-29 18:01:16 +08:00
|
|
|
"use client"
|
2025-12-30 18:35:37 +08:00
|
|
|
import { Suspense } from "react"
|
2026-01-06 14:57:55 +08:00
|
|
|
import { bindAdmin, getPageUsers } from "@/actions/user"
|
2025-12-29 18:01:16 +08:00
|
|
|
import { DataTable, useDataTable } from "@/components/data-table"
|
2025-12-30 14:40:07 +08:00
|
|
|
import { Button } from "@/components/ui/button"
|
2026-01-06 14:57:55 +08:00
|
|
|
import { useFetch } from "@/hooks/data"
|
2025-12-29 18:01:16 +08:00
|
|
|
import type { User } from "@/models/user"
|
|
|
|
|
|
|
|
|
|
export default function UserPage() {
|
|
|
|
|
const table = useDataTable<User>((page, size) => getPageUsers({ page, size }))
|
2026-01-06 14:57:55 +08:00
|
|
|
const bind = useFetch((id: number) => bindAdmin({ id }), {
|
|
|
|
|
done: "用户已认领",
|
|
|
|
|
fail: "用户认领失败",
|
|
|
|
|
})
|
2025-12-29 18:01:16 +08:00
|
|
|
return (
|
|
|
|
|
<div>
|
2025-12-30 18:35:37 +08:00
|
|
|
<Suspense>
|
|
|
|
|
<DataTable<User>
|
|
|
|
|
{...table}
|
|
|
|
|
columns={[
|
|
|
|
|
{ header: "账号", accessorKey: "username" },
|
|
|
|
|
{ header: "手机", accessorKey: "phone" },
|
|
|
|
|
{ header: "邮箱", accessorKey: "email" },
|
|
|
|
|
{ header: "姓名", accessorKey: "name" },
|
|
|
|
|
{ header: "余额", accessorKey: "balance" },
|
|
|
|
|
{ header: "认证状态", accessorKey: "id_type" },
|
|
|
|
|
{ header: "账号状态", accessorKey: "status" },
|
|
|
|
|
{ header: "联系方式", accessorKey: "contact_wechat" },
|
|
|
|
|
{ header: "管理员", accessorKey: "admin_id" },
|
|
|
|
|
{ header: "最后登录时间", accessorKey: "last_login" },
|
|
|
|
|
{ header: "创建时间", accessorKey: "created_at" },
|
|
|
|
|
{
|
|
|
|
|
header: "操作",
|
2026-01-06 14:57:55 +08:00
|
|
|
cell: ctx => (
|
|
|
|
|
<Button
|
|
|
|
|
size={"sm"}
|
|
|
|
|
onClick={() => bind(ctx.row.original.id)}
|
|
|
|
|
disabled={ctx.row.original.admin_id !== null}
|
|
|
|
|
>
|
|
|
|
|
{ctx.row.original.admin_id !== null ? "已认领" : "认领"}
|
|
|
|
|
</Button>
|
2025-12-30 18:35:37 +08:00
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
</Suspense>
|
2025-12-29 18:01:16 +08:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|