diff --git a/apps/admin/src/sections/user/index.tsx b/apps/admin/src/sections/user/index.tsx index 88e58a9..061c22e 100644 --- a/apps/admin/src/sections/user/index.tsx +++ b/apps/admin/src/sections/user/index.tsx @@ -31,6 +31,13 @@ import { SheetTitle, SheetTrigger, } from "@workspace/ui/components/sheet"; +import { FilePenLine } from 'lucide-react'; +import { + Popover, + PopoverClose, + PopoverContent, + PopoverTrigger, +} from '@workspace/ui/components/popover'; import { Switch } from "@workspace/ui/components/switch"; import { Tabs, @@ -39,7 +46,7 @@ import { TabsTrigger, } from "@workspace/ui/components/tabs"; import { Combobox } from "@workspace/ui/composed/combobox"; -import { ConfirmButton } from "@workspace/ui/composed/confirm-button"; +// import { ConfirmButton } from "@workspace/ui/composed/confirm-button"; import { ProTable, type ProTableActions, @@ -50,13 +57,13 @@ import { } from "@workspace/ui/services/admin/group"; import { createUser, - deleteUser, + // deleteUser, getUserDetail, getUserList, updateUserBasicInfo, } from "@workspace/ui/services/admin/user"; import { parseDeviceType } from "@workspace/ui/utils/device"; -import { useCallback, useRef, useState } from "react"; +import React, { useRef, useState, useCallback } from 'react'; import { useTranslation } from "react-i18next"; import { toast } from "sonner"; import { Display } from "@/components/display"; @@ -72,6 +79,44 @@ import { NotifySettingsForm } from "./user-profile/notify-settings-form"; import UserSubscription from "./user-subscription"; // import EditUserGroupDialog from "./edit-user-group-dialog"; + +// 为 RemarkForm 组件定义 props 类型 +interface RemarkFormProps { + initialRemark?: string | null; + onSave: (remark: string) => void; + CloseComponent: React.ComponentType<{ asChild?: boolean; children: React.ReactNode }>; +} +// 新的子组件,在管理它自己的备注状态 +const RemarkForm: React.FC = ({ onSave, initialRemark, CloseComponent }) => { + const [remark, setRemark] = useState(initialRemark ?? ''); + + const handleInputChange = (event: React.ChangeEvent) => { + setRemark(event.target.value); + }; + + const handleSaveClick = () => { + onSave(remark); + }; + + return ( + <> +
备注
+ + + + + + ); +}; + export default function User() { const { t } = useTranslation("user"); const [loading, setLoading] = useState(false); @@ -139,7 +184,7 @@ export default function User() { userId={row.id} />, , - {t("delete", "Delete")} } - />, + />,*/ @@ -232,7 +277,7 @@ export default function User() { accessorKey: "id", header: "ID", }, - { + /*{ id: "deleted_at", accessorKey: "deleted_at", header: t("isDeleted", "Deleted"), @@ -244,11 +289,11 @@ export default function User() { {t("normal", "Normal")} ); }, - }, + },*/ { id: "auth_methods", accessorKey: "auth_methods", - header: t("userName", "Username"), + header: '设备码/邮箱', cell: ({ row }) => { const method = row.original.auth_methods?.[0]; const identifier = method?.auth_identifier || ""; @@ -259,23 +304,48 @@ export default function User() { const display = isDevice ? deviceNo || identifier : identifier; return (
- {method?.auth_type} - + */} {deviceType && ( - - {deviceType} - + + {deviceType} + )} {display} + + +
+ {row.original?.remark ? `(${row.original.remark})` : ''} + +
+
+ + { + const { + id, + } = row.original; + await updateUserBasicInfo({ + user_id: id, + remark, + } as unknown as API.UpdateUserBasiceInfoRequest); + toast.success(t('updateSuccess')); + ref.current?.refresh(); + }} + /> + +
); }, }, - { + /* { id: "balance", accessorKey: "balance", header: t("balance", "Balance"), @@ -290,7 +360,7 @@ export default function User() { cell: ({ row }) => ( ), - }, + },*/ { id: "commission", accessorKey: "commission", @@ -531,12 +601,11 @@ function UserSearchBar({ }} value={searchType} > - + - {t("email", "Email")} - {t("deviceSearch", "Device")} + 设备码/邮箱 {t("userId", "User ID")} {t("subscription", "Subscription")} diff --git a/packages/ui/src/components/popover.tsx b/packages/ui/src/components/popover.tsx index fd36ed0..2b0f9c4 100644 --- a/packages/ui/src/components/popover.tsx +++ b/packages/ui/src/components/popover.tsx @@ -43,5 +43,6 @@ function PopoverAnchor({ }: React.ComponentProps) { return ; } +const PopoverClose = PopoverPrimitive.Close; -export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }; +export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverClose }; diff --git a/packages/ui/src/services/admin/typings.d.ts b/packages/ui/src/services/admin/typings.d.ts index f645419..196b790 100644 --- a/packages/ui/src/services/admin/typings.d.ts +++ b/packages/ui/src/services/admin/typings.d.ts @@ -2438,6 +2438,7 @@ declare namespace API { group_locked: boolean; auth_methods: UserAuthMethod[]; user_devices: UserDevice[]; + remark: string; rules: string[]; created_at: number; updated_at: number;