do refCode save after register form validation

This commit is contained in:
smanylov
2026-02-19 18:37:49 +07:00
parent 22bc8fdcbe
commit b5d53e0831
2 changed files with 24 additions and 19 deletions
+8 -3
View File
@@ -152,6 +152,7 @@ export async function registration(
): Promise<FormState> {
const accountType = formData.get('accountType') as 'b2b' | 'b2c';
const mail_verified = true;
const fullName = formData.get('fullName') as string || '';
const email = formData.get('email') 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 companyName = formData.get('companyName') 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 SignupFormSchema = await getSignupFormSchema(accountType);
@@ -215,6 +216,7 @@ export async function registration(
confirm_password,
phone,
agree,
...(referralCode !== '' && { referralCode }),
...(accountType === 'b2b' && { companyName, inn })
},
error: errors
@@ -234,7 +236,7 @@ export async function registration(
phone: phone,
password,
accountType,
mail_verified: true,
mail_verified: mail_verified,
...(accountType === 'b2b' && { companyName: companyName, inn: inn }),
...(referralCode !== '' && { referralLink: referralCode })
}
@@ -273,8 +275,8 @@ export async function registration(
...(referralCode !== '' && { referralLink: referralCode }),
...(accountType === 'b2b' && { companyName: companyName, inn: inn })
});
/* await createSession(parsed.message_body.token, email as string); */
if (mail_verified) {
return {
previousState: {
fullName,
@@ -290,6 +292,9 @@ export async function registration(
userId: parsed.message_body.userId,
error: null
};
} else {
await createSession(parsed.message_body.token, email as string);
}
} else {
console.log(parsed);
+1 -1
View File
@@ -391,7 +391,7 @@ export default function RegisterForm() {
name="referralCode"
className={`${styles['form-input']}`}
placeholder={t('referal-code')}
defaultValue={referralCode ? referralCode : ''}
defaultValue={referralCode ? referralCode : formState?.previousState?.referralCode ?? ''}
onChange={(e) => {
e.target.value = e.target.value.toLocaleLowerCase();
onChangeHandler(e)