reafactor + show password button for confirm password
This commit is contained in:
@@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
|||||||
import styles from '@/app/styles/login.module.scss'
|
import styles from '@/app/styles/login.module.scss'
|
||||||
import LogoIcon from '@/app/ui/logo-icon';
|
import LogoIcon from '@/app/ui/logo-icon';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import LoginForm from '@/app/ui/login-form';
|
import LoginForm from '@/app/ui/forms/login-form';
|
||||||
import LanguageSwitcher from '@/app/components/LanguageSwitcher';
|
import LanguageSwitcher from '@/app/components/LanguageSwitcher';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
import VKLogin from '@/app/components/VKLogin';
|
import VKLogin from '@/app/components/VKLogin';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import LogoIcon from '@/app/ui/logo-icon';
|
import LogoIcon from '@/app/ui/logo-icon';
|
||||||
import styles from '@/app/styles/login.module.scss'
|
import styles from '@/app/styles/login.module.scss'
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import RegisterForm from '@/app/ui/register-form';
|
import RegisterForm from '@/app/ui/forms/register-form';
|
||||||
import LanguageSwitcher from '@/app/components/LanguageSwitcher';
|
import LanguageSwitcher from '@/app/components/LanguageSwitcher';
|
||||||
import {useTranslations} from 'next-intl';
|
import {useTranslations} from 'next-intl';
|
||||||
|
|
||||||
|
|||||||
@@ -16,17 +16,31 @@ export default function RegisterForm() {
|
|||||||
const t = useTranslations('Login-register-form');
|
const t = useTranslations('Login-register-form');
|
||||||
|
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
|
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||||
|
|
||||||
function handleMouseDown() {
|
function handleMouseDown(target: 'password' | 'confirm-password') {
|
||||||
|
if (target === 'password') {
|
||||||
setShowPassword(true);
|
setShowPassword(true);
|
||||||
|
} else {
|
||||||
|
setShowConfirmPassword(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMouseUp() {
|
function handleMouseUp(target: 'password' | 'confirm-password') {
|
||||||
|
if (target === 'password') {
|
||||||
setShowPassword(false);
|
setShowPassword(false);
|
||||||
|
} else {
|
||||||
|
setShowConfirmPassword(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMouseOut() {
|
}
|
||||||
|
|
||||||
|
function handleMouseOut(target: 'password' | 'confirm-password') {
|
||||||
|
if (target === 'password') {
|
||||||
setShowPassword(false);
|
setShowPassword(false);
|
||||||
|
} else {
|
||||||
|
setShowConfirmPassword(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -115,11 +129,17 @@ export default function RegisterForm() {
|
|||||||
defaultValue={state?.previousState?.password ? state?.previousState?.password : ''}
|
defaultValue={state?.previousState?.password ? state?.previousState?.password : ''}
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={() => {
|
||||||
onMouseUp={handleMouseUp}
|
handleMouseDown('password');
|
||||||
onMouseOut={handleMouseOut}
|
}}
|
||||||
|
onMouseUp={() => {
|
||||||
|
handleMouseUp('password');
|
||||||
|
}}
|
||||||
|
onMouseOut={() => {
|
||||||
|
handleMouseOut('password')
|
||||||
|
}}
|
||||||
type="button"
|
type="button"
|
||||||
className={`show-password-button ${showPassword? 'show': ''}`}
|
className={`show-password-button ${showPassword ? 'show' : ''}`}
|
||||||
>
|
>
|
||||||
<IconEye />
|
<IconEye />
|
||||||
</button>
|
</button>
|
||||||
@@ -138,14 +158,31 @@ export default function RegisterForm() {
|
|||||||
<label className={`${styles['form-label']} ${styles['required']}`}>
|
<label className={`${styles['form-label']} ${styles['required']}`}>
|
||||||
{t('confirm-password')}
|
{t('confirm-password')}
|
||||||
</label>
|
</label>
|
||||||
|
<div className={`${styles['password-wrapper']}`}>
|
||||||
<input
|
<input
|
||||||
type="password"
|
type={showConfirmPassword ? "text" : "password"}
|
||||||
id="confirm_password"
|
id="confirm_password"
|
||||||
name="confirm_password"
|
name="confirm_password"
|
||||||
className={`${styles['form-input']}`}
|
className={`${styles['form-input']}`}
|
||||||
placeholder={t('repeat-password')}
|
placeholder={t('repeat-password')}
|
||||||
defaultValue={state?.previousState?.confirm_password ? state?.previousState?.confirm_password : ''}
|
defaultValue={state?.previousState?.confirm_password ? state?.previousState?.confirm_password : ''}
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
onMouseDown={() => {
|
||||||
|
handleMouseDown('confirm-password');
|
||||||
|
}}
|
||||||
|
onMouseUp={() => {
|
||||||
|
handleMouseUp('confirm-password');
|
||||||
|
}}
|
||||||
|
onMouseOut={() => {
|
||||||
|
handleMouseOut('confirm-password')
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
className={`show-password-button ${showPassword ? 'show' : ''}`}
|
||||||
|
>
|
||||||
|
<IconEye />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
{state?.error?.confirm_password && (
|
{state?.error?.confirm_password && (
|
||||||
<p className="text-sm text-red-500">
|
<p className="text-sm text-red-500">
|
||||||
{t(state?.error?.confirm_password)}
|
{t(state?.error?.confirm_password)}
|
||||||
Reference in New Issue
Block a user