'use client'; import { useState } from 'react'; import { InputField } from '@/components/ui/inputfield'; import { Button } from '@/components/ui/button'; import { Separator } from '@/components/ui/separator'; import { changePassword } from '@/lib/api/ChangePassword'; export const ChangePasswordField = () => { const [currentPassword, setCurrentPassword] = useState(''); const [newPassword, setNewPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleSubmit = async () => { setError(null); if (newPassword !== confirmPassword) { setError('Пароли не совпадают'); return; } if (newPassword.length < 8) { setError('Пароль должен быть минимум 8 символов'); return; } setLoading(true); const res = await changePassword( currentPassword, newPassword, confirmPassword, ); setLoading(false); if (res.error) { setError(res.error.general); return; } setCurrentPassword(''); setNewPassword(''); setConfirmPassword(''); }; return ( <>

СМЕНА ПАРОЛЯ

setCurrentPassword(e.target.value) } /> setNewPassword(e.target.value)} /> setConfirmPassword(e.target.value) } />
{error &&

{error}

}
); };