完善用户认领功能

Signed-off-by: luorijun <luorijun@outlook.com>
This commit is contained in:
2026-01-06 14:57:55 +08:00
parent 0c5598c927
commit a27e856f07
5 changed files with 242 additions and 108 deletions

View File

@@ -1,13 +1,17 @@
"use client"
import { Suspense } from "react"
import { getPageUsers } from "@/actions/user"
import { bindAdmin, getPageUsers } from "@/actions/user"
import { DataTable, useDataTable } from "@/components/data-table"
import { Button } from "@/components/ui/button"
import { useFetch } from "@/hooks/data"
import type { User } from "@/models/user"
export default function UserPage() {
const table = useDataTable<User>((page, size) => getPageUsers({ page, size }))
const bind = useFetch((id: number) => bindAdmin({ id }), {
done: "用户已认领",
fail: "用户认领失败",
})
return (
<div>
<Suspense>
@@ -27,10 +31,14 @@ export default function UserPage() {
{ header: "创建时间", accessorKey: "created_at" },
{
header: "操作",
cell: () => (
<div>
<Button></Button>
</div>
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>
),
},
]}