summaryrefslogtreecommitdiff
path: root/src-migrate/modules/register/components/Form.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/modules/register/components/Form.tsx')
-rw-r--r--src-migrate/modules/register/components/Form.tsx32
1 files changed, 18 insertions, 14 deletions
diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index b04e763c..55d542f2 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -26,7 +26,7 @@ const Form: React.FC<FormProps> = ({
}) => {
const { form, isCheckedTNC, isValidCaptcha, errors, updateForm, validate } =
useRegisterStore();
-
+ console.log('buttonSubmitClick', buttonSubmitClick);
const isFormValid = useMemo(() => Object.keys(errors).length === 0, [errors]);
const router = useRouter();
@@ -35,7 +35,7 @@ const Form: React.FC<FormProps> = ({
const emailRef = useRef<HTMLInputElement>(null);
const nameRef = useRef<HTMLInputElement>(null);
const passwordRef = useRef<HTMLInputElement>(null);
- const teleponRef = useRef<HTMLDivElement>(null);
+ const phoneRef = useRef<HTMLInputElement>(null);
const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
const { name, value } = event.target;
@@ -51,29 +51,33 @@ const Form: React.FC<FormProps> = ({
const loadIndustries = async () => {
const response = await mutation.mutateAsync(form);
if (!response?.register) {
- // Logic to focus on first invalid input
+ const options: ScrollIntoViewOptions = {
+ behavior: 'smooth',
+ block: 'center',
+ };
+
if (errors.email_partner && emailRef.current) {
- emailRef.current.focus();
+ emailRef.current.scrollIntoView(options);
return;
}
if (errors.name && nameRef.current) {
- nameRef.current.focus();
+ nameRef.current.scrollIntoView(options);
return;
}
if (errors.password && passwordRef.current) {
- passwordRef.current.focus();
+ passwordRef.current.scrollIntoView(options);
return;
}
- if (errors.phone && teleponRef.current) {
- teleponRef.current.scrollIntoView();
+ if (errors.phone && phoneRef.current) {
+ phoneRef.current.scrollIntoView(options);
return;
}
}
};
loadIndustries();
- }, [buttonSubmitClick]);
+ }, [buttonSubmitClick, chekValid]);
const handleSubmit = async (e: ChangeEvent<HTMLFormElement>) => {
e.preventDefault();
@@ -133,7 +137,7 @@ const Form: React.FC<FormProps> = ({
type='text'
id='name'
name='name'
- className='form-input mt-3'
+ className='form-input mt-3 transition-all duration-700'
placeholder='Masukan nama lengkap anda'
value={form.name}
ref={nameRef}
@@ -155,7 +159,7 @@ const Form: React.FC<FormProps> = ({
type='text'
id='email'
name='email'
- className='form-input mt-3'
+ className='form-input mt-3 transition-all duration-500'
placeholder='Masukan alamat email anda'
value={form.email}
ref={emailRef}
@@ -177,7 +181,7 @@ const Form: React.FC<FormProps> = ({
type='password'
name='password'
id='password'
- className='form-input mt-3'
+ className='form-input mt-3 transition-all duration-500'
placeholder='••••••••••••'
value={form.password}
ref={passwordRef}
@@ -200,10 +204,10 @@ const Form: React.FC<FormProps> = ({
type='tel'
id='phone'
name='phone'
- className='form-input mt-3'
- ref={passwordRef}
+ className='form-input mt-3 transition-all duration-500'
placeholder='08xxxxxxxx'
value={form.phone}
+ ref={phoneRef}
onChange={handleInputChange}
aria-invalid={chekValid && !!errors.phone}
/>