"use client" import { useState } from "react" import { CopyIcon } from "lucide-react" import { toast } from "sonner" import { type AdminUser } from "@/lib/api/admin" import { useI18n } from "@/i18n/provider" 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 t = useI18n() 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(t("user.copied")) } catch { toast.error(t("user.copyFailed")) } finally { setCopying(false) } } return ( <> {t("user.confirmResetTitle")} {t("user.confirmResetDescription", { username: item?.username || "-" })} {t("user.resetSuccessTitle")} {t("user.resetSuccessDescription", { username: item?.username || "-" })}
{t("user.newPassword")}
{password}
) }