refactor: use single form wrapper for auth forms
This commit is contained in:
@@ -6,7 +6,6 @@ import Image from 'next/image';
|
||||
import React from 'react'
|
||||
|
||||
type Props = {
|
||||
onSubmit: React.FormEventHandler<HTMLFormElement> | undefined;
|
||||
onChange: ((e: React.ChangeEvent<HTMLInputElement>) => void) & React.ChangeEventHandler<HTMLInputElement>;
|
||||
onClick: React.MouseEventHandler<HTMLButtonElement> | undefined;
|
||||
value: string;
|
||||
@@ -16,59 +15,56 @@ type Props = {
|
||||
repeatPasswordVisible: boolean;
|
||||
}
|
||||
|
||||
function StepNewPassword({ reset = false, onSubmit, onChange, onClick, value, repeatValue, passwordVisible, repeatPasswordVisible }: Props) {
|
||||
function StepNewPassword({ reset = false, onChange, onClick, value, repeatValue, passwordVisible, repeatPasswordVisible }: Props) {
|
||||
return (
|
||||
<form autoComplete='off' onSubmit={onSubmit} className='p-6 lg:py-[75px] w-full flex items-center justify-center py-4 lg:items-center lg:px-10 px-4 drop-shadow-black h-full'>
|
||||
<div className='h-full w-full px-4 sm:px-6 lg:p-0 flex flex-col max-h-[812px] max-w-[1200px] bg-container rounded-container overflow-clip lg:flex-row justify-between'>
|
||||
<Image
|
||||
className='object-cover w-full h-full max-h-1/2 lg:max-h-full lg:w-1/2'
|
||||
src={'/assets/images/login-banner.png'}
|
||||
alt='login banner'
|
||||
width={100}
|
||||
height={100}
|
||||
unoptimized={true}
|
||||
/>
|
||||
<div className='w-full min-w-1/2 lg:max-w-1/2 h-full lg:px-9 py-7 flex flex-col justify-between lg:justify-center lg:gap-10'>
|
||||
<div className='w-full'>
|
||||
<div className='pt-4' dir='rtl'>
|
||||
<h6 className='text-lg font-bold'>
|
||||
{reset ? "تغییر کلمه عبور" : "انتخاب کلمه عبور"}
|
||||
</h6>
|
||||
<p className='mt-3 text-[13px]'>کلمه عبور جدید باید ترکیبی از حروف بزرگ و کوچک و نشانه ها باشد مثل A126bdz@</p>
|
||||
</div>
|
||||
<InputField
|
||||
autoComplete='new-password'
|
||||
className='mt-10'
|
||||
htmlFor={AUTH_PAGE_ELEMENT.INPUT_PASSWORD}
|
||||
labelText='کلمه عبور'
|
||||
value={value}
|
||||
placeholder=''
|
||||
onChange={onChange}
|
||||
type={passwordVisible ? 'text' : 'password'}>
|
||||
<button className='ps-3' id={AUTH_PAGE_ELEMENT.TOGGLE_PASSWORD} type='button' onClick={onClick}>
|
||||
<EyeToggleIcon slash={passwordVisible} className="pointer-events-none" />
|
||||
</button>
|
||||
</InputField>
|
||||
<InputField
|
||||
autoComplete='new-password'
|
||||
valid={value === repeatValue}
|
||||
className='mt-6'
|
||||
htmlFor={AUTH_PAGE_ELEMENT.INPUT_PASSWORD_REPEAT}
|
||||
labelText='تکرار کلمه عبور'
|
||||
value={repeatValue}
|
||||
placeholder=''
|
||||
onChange={onChange}
|
||||
type={repeatPasswordVisible ? 'text' : 'password'}>
|
||||
<button className='ps-3' id={AUTH_PAGE_ELEMENT.TOGGLE_REPEAT_PASSWORD} type='button' onClick={onClick}>
|
||||
<EyeToggleIcon slash={repeatPasswordVisible} className="pointer-events-none" />
|
||||
</button>
|
||||
</InputField>
|
||||
<>
|
||||
<Image
|
||||
className='object-cover w-full h-full max-h-1/2 lg:max-h-full lg:w-1/2'
|
||||
src={'/assets/images/login-banner.png'}
|
||||
alt='login banner'
|
||||
width={100}
|
||||
height={100}
|
||||
unoptimized={true}
|
||||
/>
|
||||
<div className='w-full min-w-1/2 lg:max-w-1/2 h-full lg:px-9 py-7 flex flex-col justify-between lg:justify-center lg:gap-10'>
|
||||
<div className='w-full'>
|
||||
<div className='pt-4' dir='rtl'>
|
||||
<h6 className='text-lg font-bold'>
|
||||
{reset ? "تغییر کلمه عبور" : "انتخاب کلمه عبور"}
|
||||
</h6>
|
||||
<p className='mt-3 text-[13px]'>کلمه عبور جدید باید ترکیبی از حروف بزرگ و کوچک و نشانه ها باشد مثل A126bdz@</p>
|
||||
</div>
|
||||
<Button type='submit'>ورود</Button>
|
||||
<InputField
|
||||
autoComplete='new-password'
|
||||
className='mt-10'
|
||||
htmlFor={AUTH_PAGE_ELEMENT.INPUT_PASSWORD}
|
||||
labelText='کلمه عبور'
|
||||
value={value}
|
||||
placeholder=''
|
||||
onChange={onChange}
|
||||
type={passwordVisible ? 'text' : 'password'}>
|
||||
<button className='ps-3' id={AUTH_PAGE_ELEMENT.TOGGLE_PASSWORD} type='button' onClick={onClick}>
|
||||
<EyeToggleIcon slash={passwordVisible} className="pointer-events-none" />
|
||||
</button>
|
||||
</InputField>
|
||||
<InputField
|
||||
autoComplete='new-password'
|
||||
valid={value === repeatValue}
|
||||
className='mt-6'
|
||||
htmlFor={AUTH_PAGE_ELEMENT.INPUT_PASSWORD_REPEAT}
|
||||
labelText='تکرار کلمه عبور'
|
||||
value={repeatValue}
|
||||
placeholder=''
|
||||
onChange={onChange}
|
||||
type={repeatPasswordVisible ? 'text' : 'password'}>
|
||||
<button className='ps-3' id={AUTH_PAGE_ELEMENT.TOGGLE_REPEAT_PASSWORD} type='button' onClick={onClick}>
|
||||
<EyeToggleIcon slash={repeatPasswordVisible} className="pointer-events-none" />
|
||||
</button>
|
||||
</InputField>
|
||||
</div>
|
||||
|
||||
<Button type='submit'>ورود</Button>
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user