'use client'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { useI18n } from '@/lib/i18n'; import * as React from 'react'; interface PasswordDialogProps { isOpen: boolean; onOpenChange: (isOpen: boolean) => void; onSave: (password: string) => void; title?: string; description?: string; } export function PasswordDialog({ isOpen, onOpenChange, onSave, title, description }: PasswordDialogProps) { const { t } = useI18n(); const [currentPassword, setCurrentPassword] = React.useState(''); const inputRef = React.useRef(null); const handleSave = () => { inputRef.current?.blur(); onSave(currentPassword); setCurrentPassword(''); onOpenChange(false); }; const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); if (!currentPassword.trim()) return; handleSave(); }; const handleDialogClose = (open: boolean) => { if (!open) { setCurrentPassword(''); } onOpenChange(open); }; return ( {title ?? t('password.configure')} {description && {description}}
setCurrentPassword(e.target.value)} className='col-span-1' />
); }