NCFRONT-81 #5
@@ -146,9 +146,9 @@ export async function registration(
|
||||
state: FormState | undefined,
|
||||
formData: FormData,
|
||||
): Promise<FormState> {
|
||||
const registrationType = formData.get('accoutType') as string || '';
|
||||
const accountType = formData.get('accountType') as string || '';
|
||||
|
||||
console.log(registrationType);
|
||||
console.log(accountType);
|
||||
|
||||
const fullName = formData.get('fullName') as string || '';
|
||||
const email = formData.get('email') as string || '';
|
||||
@@ -167,7 +167,7 @@ export async function registration(
|
||||
password,
|
||||
confirm_password,
|
||||
agree,
|
||||
...(registrationType === 'btb' && { companyName })
|
||||
...(accountType === 'btb' && { companyName })
|
||||
};
|
||||
|
||||
const validatedFields = SignupFormSchema.safeParse(dataToValidate);
|
||||
@@ -193,7 +193,7 @@ export async function registration(
|
||||
confirm_password,
|
||||
phone,
|
||||
agree,
|
||||
...(registrationType === 'btb' && { companyName })
|
||||
...(accountType === 'btb' && { companyName })
|
||||
},
|
||||
error: errors
|
||||
};
|
||||
@@ -211,7 +211,8 @@ export async function registration(
|
||||
email,
|
||||
phone: phone,
|
||||
password,
|
||||
...(registrationType === 'btb' && { companyName: companyName })
|
||||
accountType,
|
||||
...(accountType === 'btb' && { companyName: companyName })
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function RegisterForm() {
|
||||
const [formState, setFormState] = useState<FormState | undefined>(undefined);
|
||||
const [showMailConfirmWindow, setShowMailConfirmWindow] = useState(false);
|
||||
const passwordRef = useRef<HTMLInputElement>(null);
|
||||
const [accountType, setAccountType] = useState<'btc' | 'btb'>('btc');
|
||||
const [accountType, setAccountType] = useState<'b2c' | 'b2b'>('b2c');
|
||||
|
||||
useEffect(() => {
|
||||
setFormState(state);
|
||||
@@ -114,10 +114,10 @@ export default function RegisterForm() {
|
||||
}
|
||||
}
|
||||
|
||||
function switchRegistrationTypeHandler(e: React.MouseEvent<HTMLButtonElement>, type: 'btc' | 'btb') {
|
||||
function switchRegistrationTypeHandler(e: React.MouseEvent<HTMLButtonElement>, type: 'b2c' | 'b2b') {
|
||||
e.preventDefault();
|
||||
setAccountType(type);
|
||||
if (formState && type === 'btc') {
|
||||
if (formState && type === 'b2c') {
|
||||
setFormState({
|
||||
...formState,
|
||||
previousState: {
|
||||
@@ -184,25 +184,25 @@ export default function RegisterForm() {
|
||||
}}>
|
||||
<div className={`${styles['form-switcher']}`}>
|
||||
<button
|
||||
className={`${styles['form-switcher-button']} ${accountType === 'btc' ? styles['active'] : ''}`}
|
||||
className={`${styles['form-switcher-button']} ${accountType === 'b2c' ? styles['active'] : ''}`}
|
||||
onClick={(e) => {
|
||||
switchRegistrationTypeHandler(e, 'btc');
|
||||
switchRegistrationTypeHandler(e, 'b2c');
|
||||
}}
|
||||
>
|
||||
{t('personal')}
|
||||
</button>
|
||||
<button
|
||||
className={`${styles['form-switcher-button']} ${accountType === 'btb' ? styles['active'] : ''}`}
|
||||
className={`${styles['form-switcher-button']} ${accountType === 'b2b' ? styles['active'] : ''}`}
|
||||
onClick={(e) => {
|
||||
switchRegistrationTypeHandler(e, 'btb');
|
||||
switchRegistrationTypeHandler(e, 'b2b');
|
||||
}}
|
||||
>
|
||||
{t('company')}
|
||||
</button>
|
||||
<input
|
||||
type="hiden"
|
||||
id="accoutType"
|
||||
name="accoutType"
|
||||
id="accountType"
|
||||
name="accountType"
|
||||
className={`${styles['form-input-hidden']}`}
|
||||
defaultValue={accountType}
|
||||
/>
|
||||
@@ -239,7 +239,7 @@ export default function RegisterForm() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{accountType === 'btb' && (
|
||||
{accountType === 'b2b' && (
|
||||
<div className={`${styles['form-group']}`}>
|
||||
<label
|
||||
className={`${styles['form-label']} ${styles['required']}`}
|
||||
|
||||
Reference in New Issue
Block a user