edit validation messages, saving formData
This commit is contained in:
@@ -5,7 +5,7 @@ import { useActionState } from 'react';
|
||||
import { authorization } from '@/app/actions/auth';
|
||||
|
||||
export default function LoginForm() {
|
||||
const [errorMessage, formAction, isPending] = useActionState(
|
||||
const [state, formAction, isPending] = useActionState(
|
||||
authorization,
|
||||
undefined,
|
||||
);
|
||||
@@ -14,14 +14,33 @@ export default function LoginForm() {
|
||||
<form action={formAction}>
|
||||
<div className={`${styles['form-group']}`}>
|
||||
<label className={`${styles['form-label']}`}>Email адрес</label>
|
||||
<input type="readOnly" id="email" name="email" className={`${styles['form-input']}`} placeholder="Введите ваш email" />
|
||||
<input
|
||||
type="readOnly"
|
||||
id="email"
|
||||
name="email"
|
||||
className={`${styles['form-input']}`}
|
||||
placeholder="Введите ваш email"
|
||||
defaultValue={state?.previousState?.email ? state?.previousState?.email : ''}
|
||||
/>
|
||||
{state?.error?.email && (
|
||||
<p className="text-sm text-red-500">{state?.error?.email}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className={`${styles['form-group']}`}>
|
||||
<label className={`${styles['form-label']}`}>Пароль</label>
|
||||
<input type="password" id="password" name="password" className={`${styles['form-input']}`} placeholder="Введите пароль" />
|
||||
<input
|
||||
type="password"
|
||||
id="password"
|
||||
name="password"
|
||||
className={`${styles['form-input']}`}
|
||||
placeholder="Введите пароль"
|
||||
/>
|
||||
{state?.error?.password && (
|
||||
<p className="text-sm text-red-500">{state?.error?.password}</p>
|
||||
)}
|
||||
</div>
|
||||
{errorMessage && (
|
||||
<p className="text-sm text-red-500">{errorMessage}</p>
|
||||
{state?.error.server && (
|
||||
<p className="text-sm text-red-500">{state?.error.server}</p>
|
||||
)}
|
||||
<div className={`${styles['form-options']}`}>
|
||||
<div className={`${styles['form-checkbox']}`}>
|
||||
|
||||
Reference in New Issue
Block a user