36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
'use client'
|
|||
|
|
|
||
|
|
import styles from '@/app/styles/login.module.scss'
|
||
|
|
import { useActionState } from 'react';
|
||
|
|
import { authenticate } from '@/app/api/action';
|
||
|
|
|
||
|
|
export default function LoginForm() {
|
||
|
|
const [errorMessage, formAction, isPending] = useActionState(
|
||
|
|
authenticate,
|
||
|
|
undefined,
|
||
|
|
);
|
||
|
|
|
||
|
|
return (
|
||
|
|
<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" />
|
||
|
|
</div>
|
||
|
|
<div className={`${styles['form-group']}`}>
|
||
|
|
<label className={`${styles['form-label']}`}>Пароль</label>
|
||
|
|
<input type="password" id="password" name="password" className={`${styles['form-input']}`} placeholder="Введите пароль" />
|
||
|
|
</div>
|
||
|
|
{errorMessage && (
|
||
|
|
<p className="text-sm text-red-500">{errorMessage}</p>
|
||
|
|
)}
|
||
|
|
<div className={`${styles['form-options']}`}>
|
||
|
|
<div className={`${styles['form-checkbox']}`}>
|
||
|
|
<input type="checkbox" id="remember" name="remember" />
|
||
|
|
<label>Запомнить меня</label>
|
||
|
|
</div>
|
||
|
|
<a href="forgot-password" className={`${styles['forgot-password']}`} >Забыли пароль?</a>
|
||
|
|
</div>
|
||
|
|
<button type="submit" className={`${styles['btn']}`}>Войти в систему</button>
|
||
|
|
</form>
|
||
|
|
)
|
||
|
|
}
|