complite b2b b2c registration
This commit is contained in:
@@ -146,9 +146,7 @@ export async function registration(
|
||||
state: FormState | undefined,
|
||||
formData: FormData,
|
||||
): Promise<FormState> {
|
||||
const accountType = formData.get('accountType') as string || '';
|
||||
|
||||
console.log(accountType);
|
||||
const accountType = formData.get('accountType') as 'b2b' | 'b2c';
|
||||
|
||||
const fullName = formData.get('fullName') as string || '';
|
||||
const email = formData.get('email') as string || '';
|
||||
@@ -158,7 +156,7 @@ export async function registration(
|
||||
const companyName = formData.get('companyName') as string || '';
|
||||
const agree = formData.get('agree') as string || '';
|
||||
|
||||
const SignupFormSchema = await getSignupFormSchema();
|
||||
const SignupFormSchema = await getSignupFormSchema(accountType);
|
||||
|
||||
const dataToValidate = {
|
||||
fullName,
|
||||
@@ -167,7 +165,7 @@ export async function registration(
|
||||
password,
|
||||
confirm_password,
|
||||
agree,
|
||||
...(accountType === 'btb' && { companyName })
|
||||
...(accountType === 'b2b' && { companyName })
|
||||
};
|
||||
|
||||
const validatedFields = SignupFormSchema.safeParse(dataToValidate);
|
||||
@@ -193,7 +191,7 @@ export async function registration(
|
||||
confirm_password,
|
||||
phone,
|
||||
agree,
|
||||
...(accountType === 'btb' && { companyName })
|
||||
...(accountType === 'b2b' && { companyName })
|
||||
},
|
||||
error: errors
|
||||
};
|
||||
@@ -212,7 +210,7 @@ export async function registration(
|
||||
phone: phone,
|
||||
password,
|
||||
accountType,
|
||||
...(accountType === 'btb' && { companyName: companyName })
|
||||
...(accountType === 'b2b' && { companyName: companyName })
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
@@ -227,7 +225,7 @@ export async function registration(
|
||||
message_body: { token: string },
|
||||
message_code: string
|
||||
};
|
||||
console.log(parsed);
|
||||
|
||||
if (parsed.message_desc === 'Operation successful') {
|
||||
await createSession(parsed.message_body.token, email as string);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user