"use client" import { useState } from "react" import { CopyIcon } from "lucide-react" import { toast } from "sonner" import { type AdminUser } from "@/lib/api/admin" import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" type ResetPasswordDialogsProps = { open: boolean saving: boolean item: AdminUser | null password: string onOpenChange: (open: boolean) => void onConfirm: () => Promise } export function ResetPasswordDialogs({ open, saving, item, password, onOpenChange, onConfirm, }: ResetPasswordDialogsProps) { const [copying, setCopying] = useState(false) const showingResult = password.trim().length > 0 async function handleCopy() { if (!password || copying) { return } setCopying(true) try { await navigator.clipboard.writeText(password) toast.success("密码已复制") } catch { toast.error("复制失败,请手动复制") } finally { setCopying(false) } } return ( <> 确认重置密码 确认后将为 {item?.username || "-"} 生成新的随机密码,并使该用户当前登录会话失效。 重置密码成功 {item?.username || "-"} 的新密码已生成,请及时复制并安全传达。
新密码
{password}
) }