improve: user friendly interactions
This commit is contained in:
@@ -58,6 +58,7 @@ function AuthIndex({ }: Props) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (step === AUTH_STEP.ENTER_OTP) {
|
if (step === AUTH_STEP.ENTER_OTP) {
|
||||||
|
setOtp('');
|
||||||
console.log("REQUEST OTP")
|
console.log("REQUEST OTP")
|
||||||
runOtpRequest(number);
|
runOtpRequest(number);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ type Props = {} & React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|||||||
function Button({ children, className, disabled, ...rest }: Props) {
|
function Button({ children, className, disabled, ...rest }: Props) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<button className={`${className} ${disabled ? 'bg-disabled text-disabled-text' : 'bg-primary text-white'} transition-all duration-200 cursor-pointer w-full rounded-normal p-3 font-normal text-sm`} {...rest}>
|
<button disabled={disabled} className={`${className} ${disabled ? 'bg-disabled text-disabled-text' : 'bg-primary text-white'} transition-all duration-200 cursor-pointer w-full rounded-normal p-3 font-normal text-sm`} {...rest}>
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ function OTPInputField({ onChange, maxLength = 6, htmlFor, labelText, className,
|
|||||||
if (val.length >= maxLength && index < maxLength) {
|
if (val.length >= maxLength && index < maxLength) {
|
||||||
i = maxLength - 1;
|
i = maxLength - 1;
|
||||||
}
|
}
|
||||||
|
inputRefs.current[i]?.current?.setSelectionRange(1, 1)
|
||||||
inputRefs.current[i]?.current?.focus();
|
inputRefs.current[i]?.current?.focus();
|
||||||
setPrevLength(() => i)
|
setPrevLength(() => i)
|
||||||
} else {
|
} else {
|
||||||
@@ -63,6 +64,7 @@ function OTPInputField({ onChange, maxLength = 6, htmlFor, labelText, className,
|
|||||||
key={i}
|
key={i}
|
||||||
onKeyDown={keyDown}
|
onKeyDown={keyDown}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
onFocus={() => ref.current?.setSelectionRange(ref.current.value.length, ref.current.value.length)}
|
||||||
name={`${htmlFor}-data-${i}`}
|
name={`${htmlFor}-data-${i}`}
|
||||||
readOnly={i != maxLength - 1 && Math.max(0, values?.length) != i && prevLength != i}
|
readOnly={i != maxLength - 1 && Math.max(0, values?.length) != i && prevLength != i}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function StepEnterOtp({ onChange, onClick, disabled = false, value, phoneNumber,
|
|||||||
<OTPInputField
|
<OTPInputField
|
||||||
autoFocus
|
autoFocus
|
||||||
autoComplete='one-time-code'
|
autoComplete='one-time-code'
|
||||||
type='number'
|
type='text'
|
||||||
inputMode='numeric'
|
inputMode='numeric'
|
||||||
className='mt-10 min-h-14 max-w-[304px]'
|
className='mt-10 min-h-14 max-w-[304px]'
|
||||||
maxLength={6}
|
maxLength={6}
|
||||||
@@ -67,7 +67,7 @@ function StepEnterOtp({ onChange, onClick, disabled = false, value, phoneNumber,
|
|||||||
<div>
|
<div>
|
||||||
کد را دریافت نکردید؟
|
کد را دریافت نکردید؟
|
||||||
<span className='text-primary px-1'>
|
<span className='text-primary px-1'>
|
||||||
<button id={AUTH_PAGE_ELEMENTS.RESEND_OTP} className='' onClick={onClick}>
|
<button type='button' id={AUTH_PAGE_ELEMENTS.RESEND_OTP} className='cursor-pointer' onClick={onClick}>
|
||||||
دوباره امتحان کنید
|
دوباره امتحان کنید
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user