2025-11-27 13:48:24 +07:00
|
|
|
|
'use client'
|
|
|
|
|
|
|
2025-12-27 12:10:13 +07:00
|
|
|
|
import styles from '@/app/styles/module/login.module.scss';
|
2026-02-17 18:20:50 +07:00
|
|
|
|
import { ChangeEvent, useActionState, useEffect, useRef, useState } from 'react';
|
2026-01-23 18:06:08 +07:00
|
|
|
|
import { registration, FormState } from '@/app/actions/auth';
|
2026-02-17 18:20:50 +07:00
|
|
|
|
|
|
|
|
|
|
|
2025-12-08 13:57:26 +07:00
|
|
|
|
import PhoneInput from '@/app/ui/inputs/phone-input';
|
2025-12-10 11:42:52 +07:00
|
|
|
|
import Link from 'next/link';
|
2025-12-10 16:39:13 +07:00
|
|
|
|
import { useTranslations } from 'next-intl';
|
2025-12-15 12:22:42 +07:00
|
|
|
|
import { IconEye } from '@/app/ui/icons/icons';
|
2026-02-13 19:17:10 +07:00
|
|
|
|
import { getSignupFormSchema } from '@/app/actions/definitions';
|
2026-02-06 13:13:29 +07:00
|
|
|
|
import { useSearchParams } from 'next/navigation';
|
2025-12-22 13:02:39 +07:00
|
|
|
|
import * as z from 'zod'
|
2026-01-23 18:06:08 +07:00
|
|
|
|
import ConfirmMailModalWindow from '@/app/ui/forms/confirm-mail-modal-window';
|
2026-02-13 19:17:10 +07:00
|
|
|
|
import { fetchINN } from '@/app/actions/action';
|
|
|
|
|
|
import { useDebouncedCallback } from 'use-debounce';
|
2025-11-27 13:48:24 +07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function RegisterForm() {
|
2026-02-06 13:13:29 +07:00
|
|
|
|
const searchParams = useSearchParams();
|
2026-02-06 13:40:30 +07:00
|
|
|
|
const referralCode = searchParams.get('ref');
|
2026-02-06 13:13:29 +07:00
|
|
|
|
|
2025-12-07 12:53:56 +07:00
|
|
|
|
const [state, formAction, isPending] = useActionState(
|
2025-11-27 13:48:24 +07:00
|
|
|
|
registration,
|
|
|
|
|
|
undefined,
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2025-12-22 13:02:39 +07:00
|
|
|
|
const t = useTranslations('Login-register-form');
|
2025-12-15 12:22:42 +07:00
|
|
|
|
const [showPassword, setShowPassword] = useState(false);
|
2025-12-16 10:11:39 +07:00
|
|
|
|
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
2025-12-22 13:02:39 +07:00
|
|
|
|
const [formState, setFormState] = useState<FormState | undefined>(undefined);
|
2026-01-14 18:15:52 +07:00
|
|
|
|
const [showMailConfirmWindow, setShowMailConfirmWindow] = useState(false);
|
2025-12-22 13:02:39 +07:00
|
|
|
|
const passwordRef = useRef<HTMLInputElement>(null);
|
2026-01-29 17:01:00 +07:00
|
|
|
|
const [accountType, setAccountType] = useState<'b2c' | 'b2b'>('b2c');
|
2025-12-22 13:02:39 +07:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
setFormState(state);
|
2026-01-14 18:15:52 +07:00
|
|
|
|
if (state?.mailConfirm) {
|
|
|
|
|
|
setShowMailConfirmWindow(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-13 19:17:10 +07:00
|
|
|
|
}, [state]);
|
|
|
|
|
|
|
|
|
|
|
|
const debouncedFetchINN = useDebouncedCallback(
|
|
|
|
|
|
async (value) => {
|
|
|
|
|
|
const response = await fetchINN(value);
|
|
|
|
|
|
|
|
|
|
|
|
if (response.companyName) {
|
|
|
|
|
|
setFormState({
|
|
|
|
|
|
...formState,
|
|
|
|
|
|
previousState: {
|
|
|
|
|
|
...formState?.previousState,
|
|
|
|
|
|
companyName: response.companyName
|
|
|
|
|
|
},
|
|
|
|
|
|
error: {
|
|
|
|
|
|
...formState?.error,
|
|
|
|
|
|
companyName: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setFormState({
|
|
|
|
|
|
...formState,
|
|
|
|
|
|
previousState: {
|
|
|
|
|
|
companyName: response.companyName
|
|
|
|
|
|
},
|
|
|
|
|
|
error: {
|
|
|
|
|
|
...formState?.error,
|
|
|
|
|
|
companyName: '',
|
|
|
|
|
|
inn: 'inn-invalid'
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
500
|
|
|
|
|
|
);
|
2025-12-15 12:22:42 +07:00
|
|
|
|
|
2025-12-22 14:30:25 +07:00
|
|
|
|
function showPassowrd(target: 'password' | 'confirm-password') {
|
2025-12-16 10:11:39 +07:00
|
|
|
|
if (target === 'password') {
|
2025-12-22 14:30:25 +07:00
|
|
|
|
setShowPassword(!showPassword);
|
2025-12-16 10:11:39 +07:00
|
|
|
|
} else {
|
2025-12-22 14:30:25 +07:00
|
|
|
|
setShowConfirmPassword(!showConfirmPassword);
|
2025-12-16 10:11:39 +07:00
|
|
|
|
}
|
2025-12-15 12:22:42 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-13 19:17:10 +07:00
|
|
|
|
type SignupFormSchema = Awaited<ReturnType<typeof getSignupFormSchema>>;
|
|
|
|
|
|
const [signupFormSchema, setSignupFormSchema] = useState<SignupFormSchema | null>(null);;
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
let isMounted = true;
|
|
|
|
|
|
|
|
|
|
|
|
const loadSchema = async () => {
|
|
|
|
|
|
const result = await getSignupFormSchema(accountType);
|
|
|
|
|
|
if (isMounted) {
|
|
|
|
|
|
setSignupFormSchema(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
loadSchema();
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
|
isMounted = false;
|
|
|
|
|
|
};
|
|
|
|
|
|
}, [accountType]);
|
|
|
|
|
|
|
|
|
|
|
|
async function validateField(
|
2025-12-22 13:02:39 +07:00
|
|
|
|
fieldName: string,
|
|
|
|
|
|
value: string,
|
|
|
|
|
|
) {
|
|
|
|
|
|
switch (fieldName) {
|
|
|
|
|
|
case 'confirm_password':
|
2026-02-13 19:17:10 +07:00
|
|
|
|
const baseSchema = signupFormSchema?.shape.confirm_password;
|
|
|
|
|
|
|
|
|
|
|
|
if (!baseSchema) {
|
|
|
|
|
|
return { success: true, data: value };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 13:02:39 +07:00
|
|
|
|
const baseResult = baseSchema.safeParse(value);
|
|
|
|
|
|
|
|
|
|
|
|
if (!baseResult.success) {
|
|
|
|
|
|
return baseResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const currentPassword = passwordRef.current?.value || '';
|
|
|
|
|
|
if (value !== currentPassword) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
success: false,
|
|
|
|
|
|
error: new z.ZodError([
|
|
|
|
|
|
{
|
|
|
|
|
|
code: z.ZodIssueCode.custom,
|
|
|
|
|
|
message: 'repeat-password',
|
|
|
|
|
|
path: ['confirm_password']
|
|
|
|
|
|
}
|
|
|
|
|
|
])
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return { success: true, data: value };
|
|
|
|
|
|
|
|
|
|
|
|
case 'email':
|
|
|
|
|
|
case 'fullName':
|
|
|
|
|
|
case 'phone':
|
2026-02-06 13:13:29 +07:00
|
|
|
|
case 'referralCode':
|
2025-12-22 13:02:39 +07:00
|
|
|
|
case 'password':
|
2026-01-09 19:46:59 +07:00
|
|
|
|
case 'companyName':
|
2025-12-22 13:02:39 +07:00
|
|
|
|
case 'agree':
|
2026-02-13 19:17:10 +07:00
|
|
|
|
case 'inn':
|
|
|
|
|
|
const schema = signupFormSchema?.shape[fieldName];
|
|
|
|
|
|
if (!schema) {
|
|
|
|
|
|
return { success: true, data: value };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 13:02:39 +07:00
|
|
|
|
if (fieldName === 'phone') {
|
|
|
|
|
|
return schema.safeParse(value.replace(/[-\(\)\s]/g, ''));
|
|
|
|
|
|
}
|
2026-02-03 17:36:09 +07:00
|
|
|
|
if (fieldName === 'companyName' && accountType === 'b2c') {
|
2026-01-29 21:34:02 +07:00
|
|
|
|
return { success: true, data: value };
|
|
|
|
|
|
}
|
2026-02-06 13:13:29 +07:00
|
|
|
|
if (fieldName === 'referralCode') {
|
|
|
|
|
|
return { success: true, data: value };
|
|
|
|
|
|
}
|
2025-12-22 13:02:39 +07:00
|
|
|
|
return schema.safeParse(value);
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
throw new Error(`Unknown field: ${fieldName}`);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-13 19:17:10 +07:00
|
|
|
|
async function onChangeHandler(e: ChangeEvent<HTMLInputElement>): Promise<void> {
|
2025-12-22 13:02:39 +07:00
|
|
|
|
const fieldName = e.target.name;
|
2026-01-09 19:46:59 +07:00
|
|
|
|
if (fieldName !== 'phone') {
|
2026-02-23 12:07:42 +07:00
|
|
|
|
e.target.value = e.target.value
|
|
|
|
|
|
.replace(/([^a-zA-Zа-яёА-ЯЁ0-9@.!#$%&"'*+/=?^_{|}~\-\s])/g, '')
|
|
|
|
|
|
.replace(/\s+/g, ' ');
|
2026-01-09 19:46:59 +07:00
|
|
|
|
}
|
2026-02-13 19:17:10 +07:00
|
|
|
|
|
|
|
|
|
|
if (fieldName === 'inn') {
|
|
|
|
|
|
const currentValue = e.target.value;
|
|
|
|
|
|
|
|
|
|
|
|
const cleanedValue = currentValue.replace(/([^0-9])/g, '');
|
|
|
|
|
|
|
|
|
|
|
|
if (cleanedValue.length > 10) {
|
|
|
|
|
|
e.target.value = cleanedValue.slice(0, 10);
|
|
|
|
|
|
debouncedFetchINN(e.target.value);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
e.target.value = cleanedValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (cleanedValue.length === 10) {
|
|
|
|
|
|
debouncedFetchINN(cleanedValue);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (formState) {
|
|
|
|
|
|
setFormState({
|
|
|
|
|
|
...formState,
|
|
|
|
|
|
previousState: {
|
|
|
|
|
|
...formState?.previousState,
|
|
|
|
|
|
companyName: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
error: {
|
|
|
|
|
|
...formState?.error,
|
|
|
|
|
|
companyName: '',
|
|
|
|
|
|
inn: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const validatedField = await validateField(fieldName, e.target.value);
|
2025-12-22 13:02:39 +07:00
|
|
|
|
|
|
|
|
|
|
if (validatedField.success) {
|
|
|
|
|
|
setFormState(prevState => {
|
|
|
|
|
|
if (!prevState?.error || !prevState?.error[fieldName]) {
|
|
|
|
|
|
return prevState;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { [fieldName]: _, ...newError } = prevState.error;
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
...prevState,
|
|
|
|
|
|
error: newError
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-29 17:01:00 +07:00
|
|
|
|
function switchRegistrationTypeHandler(e: React.MouseEvent<HTMLButtonElement>, type: 'b2c' | 'b2b') {
|
2026-01-29 14:34:04 +07:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
setAccountType(type);
|
2026-02-13 19:17:10 +07:00
|
|
|
|
if (formState?.previousState) {
|
2026-01-29 14:34:04 +07:00
|
|
|
|
setFormState({
|
|
|
|
|
|
...formState,
|
|
|
|
|
|
previousState: {
|
|
|
|
|
|
...formState.previousState,
|
2026-02-13 19:17:10 +07:00
|
|
|
|
companyName: '',
|
|
|
|
|
|
inn: ''
|
2026-01-29 14:34:04 +07:00
|
|
|
|
},
|
|
|
|
|
|
error: {
|
|
|
|
|
|
...formState.error,
|
2026-02-13 19:17:10 +07:00
|
|
|
|
companyName: '',
|
|
|
|
|
|
inn: ''
|
2026-01-29 14:34:04 +07:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-27 13:48:24 +07:00
|
|
|
|
return (
|
2026-01-14 18:15:52 +07:00
|
|
|
|
<>
|
|
|
|
|
|
{showMailConfirmWindow && (
|
2025-12-22 14:30:25 +07:00
|
|
|
|
<div
|
2026-01-14 18:15:52 +07:00
|
|
|
|
className="modal-wrapper"
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
setShowMailConfirmWindow(false);
|
|
|
|
|
|
}}
|
2025-12-22 14:30:25 +07:00
|
|
|
|
>
|
2026-01-26 13:04:13 +07:00
|
|
|
|
<ConfirmMailModalWindow userId={state?.userId} email={formState?.previousState?.email} />
|
2026-01-14 18:15:52 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<form action={(e) => {
|
|
|
|
|
|
formAction(e);
|
|
|
|
|
|
}}>
|
2026-01-29 14:34:04 +07:00
|
|
|
|
<div className={`${styles['form-switcher']}`}>
|
|
|
|
|
|
<button
|
2026-01-29 17:01:00 +07:00
|
|
|
|
className={`${styles['form-switcher-button']} ${accountType === 'b2c' ? styles['active'] : ''}`}
|
2026-01-29 14:34:04 +07:00
|
|
|
|
onClick={(e) => {
|
2026-01-29 17:01:00 +07:00
|
|
|
|
switchRegistrationTypeHandler(e, 'b2c');
|
2026-01-29 14:34:04 +07:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
2026-01-29 14:48:54 +07:00
|
|
|
|
{t('personal')}
|
2026-01-29 14:34:04 +07:00
|
|
|
|
</button>
|
|
|
|
|
|
<button
|
2026-01-29 17:01:00 +07:00
|
|
|
|
className={`${styles['form-switcher-button']} ${accountType === 'b2b' ? styles['active'] : ''}`}
|
2026-01-29 14:34:04 +07:00
|
|
|
|
onClick={(e) => {
|
2026-01-29 17:01:00 +07:00
|
|
|
|
switchRegistrationTypeHandler(e, 'b2b');
|
2026-01-29 14:34:04 +07:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
2026-01-29 14:48:54 +07:00
|
|
|
|
{t('company')}
|
2026-01-29 14:34:04 +07:00
|
|
|
|
</button>
|
|
|
|
|
|
<input
|
2026-02-05 11:55:02 +07:00
|
|
|
|
type="hidden"
|
2026-01-29 17:01:00 +07:00
|
|
|
|
id="accountType"
|
|
|
|
|
|
name="accountType"
|
2026-01-29 14:34:04 +07:00
|
|
|
|
className={`${styles['form-input-hidden']}`}
|
2026-02-05 11:55:02 +07:00
|
|
|
|
value={accountType}
|
2026-01-29 14:34:04 +07:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-01-14 18:15:52 +07:00
|
|
|
|
<div className={`${styles['form-group']}`}>
|
|
|
|
|
|
<label
|
|
|
|
|
|
className={`${styles['form-label']} ${styles['required']}`}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('full-name')}
|
|
|
|
|
|
</label>
|
2025-12-22 14:30:25 +07:00
|
|
|
|
<input
|
2026-01-14 18:15:52 +07:00
|
|
|
|
type="text"
|
|
|
|
|
|
id="fullName"
|
|
|
|
|
|
name="fullName"
|
|
|
|
|
|
className={`${styles['form-input']}`}
|
|
|
|
|
|
placeholder={t('name-placeholder')}
|
|
|
|
|
|
defaultValue={formState?.previousState?.fullName ? formState?.previousState?.fullName : ''}
|
2025-12-22 14:30:25 +07:00
|
|
|
|
onChange={onChangeHandler}
|
|
|
|
|
|
/>
|
2026-01-14 18:15:52 +07:00
|
|
|
|
{formState?.error?.fullName && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{
|
|
|
|
|
|
formState?.error?.fullName.split('&').map((e, index) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span key={index}>
|
|
|
|
|
|
{t(e)}
|
|
|
|
|
|
<br />
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
2025-11-27 13:48:24 +07:00
|
|
|
|
</div>
|
2025-12-22 14:30:25 +07:00
|
|
|
|
|
2026-02-06 13:13:29 +07:00
|
|
|
|
{accountType === 'b2b' ? (
|
2026-02-13 19:17:10 +07:00
|
|
|
|
<>
|
|
|
|
|
|
<div className={`${styles['form-group']}`}>
|
|
|
|
|
|
<label
|
|
|
|
|
|
className={`${styles['form-label']} ${styles['required']}`}
|
|
|
|
|
|
>
|
2026-02-17 11:27:57 +07:00
|
|
|
|
{t('INN')}
|
2026-02-13 19:17:10 +07:00
|
|
|
|
</label>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
id="inn"
|
|
|
|
|
|
name="inn"
|
|
|
|
|
|
className={`${styles['form-input']}`}
|
2026-02-17 11:27:57 +07:00
|
|
|
|
placeholder={t('inn-placeholder')}
|
2026-02-13 19:17:10 +07:00
|
|
|
|
defaultValue={formState?.previousState?.inn ? formState?.previousState?.inn : ''}
|
|
|
|
|
|
onChange={onChangeHandler}
|
|
|
|
|
|
/>
|
|
|
|
|
|
{formState?.error?.inn && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{
|
|
|
|
|
|
formState?.error?.inn.split('&').map((e, index) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span key={index}>
|
|
|
|
|
|
{t(e)}
|
|
|
|
|
|
<br />
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className={`${styles['form-group']}`}>
|
|
|
|
|
|
<label
|
|
|
|
|
|
className={`${styles['form-label']}`}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('company')}
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
id="companyName"
|
|
|
|
|
|
name="companyName"
|
|
|
|
|
|
className={`${styles['form-input']}`}
|
|
|
|
|
|
placeholder={t('field-filled-automatically')}
|
|
|
|
|
|
value={formState?.previousState?.companyName ?? ''}
|
|
|
|
|
|
readOnly={true}
|
|
|
|
|
|
/* defaultValue={formState?.previousState?.companyName ? formState?.previousState?.companyName : ''} */
|
|
|
|
|
|
onChange={onChangeHandler}
|
|
|
|
|
|
/>
|
|
|
|
|
|
{formState?.error?.companyName && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{
|
|
|
|
|
|
formState?.error?.companyName.split('&').map((e, index) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span key={index}>
|
|
|
|
|
|
{t(e)}
|
|
|
|
|
|
<br />
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</>
|
2026-02-06 13:13:29 +07:00
|
|
|
|
) : (
|
|
|
|
|
|
<div className={`${styles['form-group']}`}>
|
|
|
|
|
|
<label className={`${styles['form-label']}`}>
|
|
|
|
|
|
{t('referal-code')}
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
id="referralCode"
|
|
|
|
|
|
name="referralCode"
|
|
|
|
|
|
className={`${styles['form-input']}`}
|
|
|
|
|
|
placeholder={t('referal-code')}
|
2026-02-19 18:37:49 +07:00
|
|
|
|
defaultValue={referralCode ? referralCode : formState?.previousState?.referralCode ?? ''}
|
2026-02-06 13:13:29 +07:00
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
e.target.value = e.target.value.toLocaleLowerCase();
|
|
|
|
|
|
onChangeHandler(e)
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
{formState?.error?.referralCode && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{
|
|
|
|
|
|
formState?.error?.referralCode.split('&').map((e, index) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span key={index}>
|
|
|
|
|
|
{t(e)}
|
|
|
|
|
|
<br />
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2026-01-29 14:34:04 +07:00
|
|
|
|
|
2026-01-14 18:15:52 +07:00
|
|
|
|
<div className={`${styles['form-group']}`}>
|
|
|
|
|
|
<label className={`${styles['form-label']} ${styles['required']}`}>
|
|
|
|
|
|
{t('email-adress')}
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
id="email"
|
|
|
|
|
|
name="email"
|
|
|
|
|
|
className={`${styles['form-input']}`}
|
|
|
|
|
|
placeholder="ivan@example.com"
|
|
|
|
|
|
defaultValue={formState?.previousState?.email ? formState?.previousState?.email : ''}
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
e.target.value = e.target.value.toLocaleLowerCase();
|
|
|
|
|
|
onChangeHandler(e)
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
{formState?.error?.email && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{
|
|
|
|
|
|
formState?.error?.email.split('&').map((e, index) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span key={index}>
|
|
|
|
|
|
{t(e)}
|
|
|
|
|
|
<br />
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2026-02-06 13:13:29 +07:00
|
|
|
|
|
2026-01-14 18:15:52 +07:00
|
|
|
|
<div className={`${styles['form-group']}`}>
|
|
|
|
|
|
<label className={`${styles['form-label']} ${styles['required']}`}>
|
|
|
|
|
|
{t('phone')}
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<PhoneInput phoneState={formState?.previousState?.phone} validateHandler={onChangeHandler} />
|
|
|
|
|
|
{formState?.error?.phone && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{
|
|
|
|
|
|
formState?.error?.phone.split('&').map((e, index) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span key={index}>
|
|
|
|
|
|
{t(e)}
|
|
|
|
|
|
<br />
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className={`${styles['form-group']}`}>
|
|
|
|
|
|
<label className={`${styles['form-label']} ${styles['required']}`}>
|
|
|
|
|
|
{t('password')}
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<div
|
|
|
|
|
|
className={`${styles['password-wrapper']}`}
|
2025-12-12 11:43:28 +07:00
|
|
|
|
>
|
2026-01-14 18:15:52 +07:00
|
|
|
|
<input
|
|
|
|
|
|
ref={passwordRef}
|
|
|
|
|
|
type={showPassword ? "text" : "password"}
|
|
|
|
|
|
id="password"
|
|
|
|
|
|
name="password"
|
|
|
|
|
|
className={`${styles['form-input']} ${styles['password']}`}
|
|
|
|
|
|
placeholder={t('password-placeholder')}
|
|
|
|
|
|
defaultValue={formState?.previousState?.password ? formState?.previousState?.password : ''}
|
|
|
|
|
|
onChange={onChangeHandler}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<button
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
showPassowrd('password')
|
|
|
|
|
|
}}
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
className={`show-password-button ${showPassword ? 'show' : ''}`}
|
|
|
|
|
|
>
|
|
|
|
|
|
<IconEye />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{formState?.error?.password && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{
|
|
|
|
|
|
formState?.error?.password.split('&').map((e, index) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<span key={index}>
|
|
|
|
|
|
{t(e)}
|
|
|
|
|
|
<br />
|
|
|
|
|
|
</span>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2026-02-06 13:13:29 +07:00
|
|
|
|
|
2026-01-14 18:15:52 +07:00
|
|
|
|
<div className={`${styles['form-group']}`}>
|
|
|
|
|
|
<label className={`${styles['form-label']} ${styles['required']}`}>
|
|
|
|
|
|
{t('confirm-password')}
|
|
|
|
|
|
</label>
|
|
|
|
|
|
<div className={`${styles['password-wrapper']}`}>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type={showConfirmPassword ? "text" : "password"}
|
|
|
|
|
|
id="confirm_password"
|
|
|
|
|
|
name="confirm_password"
|
|
|
|
|
|
className={`${styles['form-input']} ${styles['password']}`}
|
|
|
|
|
|
placeholder={t('repeat-password')}
|
|
|
|
|
|
defaultValue={formState?.previousState?.confirm_password ? formState?.previousState?.confirm_password : ''}
|
|
|
|
|
|
onChange={onChangeHandler}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<button
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
showPassowrd('confirm-password');
|
|
|
|
|
|
}}
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
className={`show-password-button ${showConfirmPassword ? 'show' : ''}`}
|
|
|
|
|
|
>
|
|
|
|
|
|
<IconEye />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{formState?.error?.confirm_password && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{t(formState?.error?.confirm_password)}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className={`${styles['form-checkbox']}`}>
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="checkbox"
|
|
|
|
|
|
id="agree"
|
|
|
|
|
|
name="agree"
|
|
|
|
|
|
defaultChecked={formState?.previousState?.agree ? true : false}
|
|
|
|
|
|
onChange={onChangeHandler}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<label htmlFor="agree">
|
|
|
|
|
|
{t('i-agree-to')} <Link
|
|
|
|
|
|
href="/terms-of-use"
|
|
|
|
|
|
target="_blank"
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('terms-of-use')}
|
|
|
|
|
|
</Link> {t('and')} <Link
|
|
|
|
|
|
href="/privacy-policy"
|
|
|
|
|
|
target="_blank"
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('privacy-policy')}
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
</label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{formState?.error?.agree && (
|
|
|
|
|
|
<p className="text-sm text-red-500">
|
|
|
|
|
|
{t(formState?.error?.agree)}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{formState?.error?.server && (
|
|
|
|
|
|
<p className="text-sm text-red-500 mt-4">
|
|
|
|
|
|
{t(formState?.error?.server)}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
)}
|
2026-02-06 11:13:13 +07:00
|
|
|
|
<button
|
|
|
|
|
|
type="submit"
|
|
|
|
|
|
className={`${styles['btn']}`}
|
|
|
|
|
|
disabled={isPending}
|
|
|
|
|
|
>
|
|
|
|
|
|
{isPending ? (
|
|
|
|
|
|
<div className="loading-animation">
|
|
|
|
|
|
<div className="global-spinner"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
t("create-an-account")
|
|
|
|
|
|
)}
|
2026-01-14 18:15:52 +07:00
|
|
|
|
</button>
|
|
|
|
|
|
</form >
|
|
|
|
|
|
</>
|
2025-11-27 13:48:24 +07:00
|
|
|
|
)
|
|
|
|
|
|
}
|