From 48517034f23b6874e1c8f29cb46467e727a8f5ce Mon Sep 17 00:00:00 2001 From: sijinhui Date: Mon, 29 Apr 2024 23:09:57 +0800 Subject: [PATCH] fix little bug --- app/app/(admin)/components/users-table.tsx | 92 ++-------------------- 1 file changed, 5 insertions(+), 87 deletions(-) diff --git a/app/app/(admin)/components/users-table.tsx b/app/app/(admin)/components/users-table.tsx index 6b13820fc..84c3ac0a0 100644 --- a/app/app/(admin)/components/users-table.tsx +++ b/app/app/(admin)/components/users-table.tsx @@ -5,11 +5,9 @@ import { User } from "@prisma/client"; import { Space, Table, - Tag, Input, Button, notification as notificationModule, - Popconfirm, Checkbox, Modal, Form, @@ -40,9 +38,6 @@ interface SearchTextProps { setSearchText: Dispatch>; } -type DataIndex = keyof User; -type InputRef = GetRef; - function UserTableSearchInput({ users, setUsers, setLoading }: UserInterface) { const [searchText, setSearchText] = useState(""); // 这里直接搜索,并获取数据不传递搜索的值给表格了。 @@ -89,14 +84,6 @@ function UsersTable({ users, setUsers, loading }: UserInterface) { notificationModule.useNotification(); const [editUserModal, editUserModalContextHolder] = Modal.useModal(); const [editUserForm] = Form.useForm(); - const [newPassword, setNewPassword] = useState(""); - - const newPasswordChange = (e: React.ChangeEvent) => { - // if ((e.nativeEvent as InputEvent).isComposing) { - // return; - // } - setNewPassword(e.target.value.trim()); - }; const handleUserEdit = (method: "POST" | "PUT", record: User | undefined) => { editUserModal.confirm({ @@ -193,44 +180,6 @@ function UsersTable({ users, setUsers, loading }: UserInterface) { }); }; - const confirmPassword = async (id: string) => { - console.log("-----", newPassword, id); - try { - fetch(`/api/admin/users/${id}`, { - method: "put", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - password: newPassword, - }), - credentials: "include", - }) - .then((response) => response.json()) - .then((res) => { - if (res["result"] == "ok") { - openNotification("info", { - message: "修改密码", - description: `${id} 密码修改成功`, - }); - } - }) - .catch((error) => { - console.log("e", error); - openNotification("error", { - message: "修改密码", - description: `${id} 密码修改失败`, - }); - }); - } catch { - openNotification("error", { - message: "修改密码", - description: `${id} 密码修改失败`, - }); - } - setNewPassword(""); - }; - const openNotification = (level: string, arms: NotificationArgsProps) => { if (level === "error") { notification.error({ @@ -312,49 +261,18 @@ function UsersTable({ users, setUsers, loading }: UserInterface) { ); }, }, - // { - // title: "编辑", - // dataIndex: "", - // key: "id", - // width: 80, - // render: (value) => { - // return ( - //
- // 编辑 - //
- // ); - // }, - // }, { title: "Action", dataIndex: "", key: "id", render: (_, record) => ( - handleUserEdit("PUT", record)}> + - - handleDeleteUser(record)}>删除 + + ), },