do refCode save after register form validation
This commit is contained in:
@@ -152,6 +152,7 @@ export async function registration(
|
|||||||
): Promise<FormState> {
|
): Promise<FormState> {
|
||||||
const accountType = formData.get('accountType') as 'b2b' | 'b2c';
|
const accountType = formData.get('accountType') as 'b2b' | 'b2c';
|
||||||
|
|
||||||
|
const mail_verified = true;
|
||||||
const fullName = formData.get('fullName') as string || '';
|
const fullName = formData.get('fullName') as string || '';
|
||||||
const email = formData.get('email') as string || '';
|
const email = formData.get('email') as string || '';
|
||||||
const password = formData.get('password') as string || '';
|
const password = formData.get('password') as string || '';
|
||||||
@@ -159,7 +160,7 @@ export async function registration(
|
|||||||
const phone = formData.get('phone') as string || '';
|
const phone = formData.get('phone') as string || '';
|
||||||
const companyName = formData.get('companyName') as string || '';
|
const companyName = formData.get('companyName') as string || '';
|
||||||
const agree = formData.get('agree') as string || '';
|
const agree = formData.get('agree') as string || '';
|
||||||
const referralCode = formData.get('referralCode');
|
const referralCode = formData.get('referralCode') as string || '';
|
||||||
const inn = formData.get('inn') as string || '';
|
const inn = formData.get('inn') as string || '';
|
||||||
|
|
||||||
const SignupFormSchema = await getSignupFormSchema(accountType);
|
const SignupFormSchema = await getSignupFormSchema(accountType);
|
||||||
@@ -215,6 +216,7 @@ export async function registration(
|
|||||||
confirm_password,
|
confirm_password,
|
||||||
phone,
|
phone,
|
||||||
agree,
|
agree,
|
||||||
|
...(referralCode !== '' && { referralCode }),
|
||||||
...(accountType === 'b2b' && { companyName, inn })
|
...(accountType === 'b2b' && { companyName, inn })
|
||||||
},
|
},
|
||||||
error: errors
|
error: errors
|
||||||
@@ -234,7 +236,7 @@ export async function registration(
|
|||||||
phone: phone,
|
phone: phone,
|
||||||
password,
|
password,
|
||||||
accountType,
|
accountType,
|
||||||
mail_verified: true,
|
mail_verified: mail_verified,
|
||||||
...(accountType === 'b2b' && { companyName: companyName, inn: inn }),
|
...(accountType === 'b2b' && { companyName: companyName, inn: inn }),
|
||||||
...(referralCode !== '' && { referralLink: referralCode })
|
...(referralCode !== '' && { referralLink: referralCode })
|
||||||
}
|
}
|
||||||
@@ -273,8 +275,8 @@ export async function registration(
|
|||||||
...(referralCode !== '' && { referralLink: referralCode }),
|
...(referralCode !== '' && { referralLink: referralCode }),
|
||||||
...(accountType === 'b2b' && { companyName: companyName, inn: inn })
|
...(accountType === 'b2b' && { companyName: companyName, inn: inn })
|
||||||
});
|
});
|
||||||
/* await createSession(parsed.message_body.token, email as string); */
|
|
||||||
|
|
||||||
|
if (mail_verified) {
|
||||||
return {
|
return {
|
||||||
previousState: {
|
previousState: {
|
||||||
fullName,
|
fullName,
|
||||||
@@ -290,6 +292,9 @@ export async function registration(
|
|||||||
userId: parsed.message_body.userId,
|
userId: parsed.message_body.userId,
|
||||||
error: null
|
error: null
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
await createSession(parsed.message_body.token, email as string);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log(parsed);
|
console.log(parsed);
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ export default function RegisterForm() {
|
|||||||
name="referralCode"
|
name="referralCode"
|
||||||
className={`${styles['form-input']}`}
|
className={`${styles['form-input']}`}
|
||||||
placeholder={t('referal-code')}
|
placeholder={t('referal-code')}
|
||||||
defaultValue={referralCode ? referralCode : ''}
|
defaultValue={referralCode ? referralCode : formState?.previousState?.referralCode ?? ''}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
e.target.value = e.target.value.toLocaleLowerCase();
|
e.target.value = e.target.value.toLocaleLowerCase();
|
||||||
onChangeHandler(e)
|
onChangeHandler(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user