update validation
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use server'
|
||||
|
||||
import { SignupFormSchema, loginFormSchema, API_BASE_URL } from '@/app/actions/definitions';
|
||||
import { SignupFormSchema, loginFormSchema, API_BASE_URL, getSignupFormSchema } from '@/app/actions/definitions';
|
||||
import { createSession, deleteSession, getSessionData } from '@/app/actions/session';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
@@ -154,7 +154,9 @@ export async function registration(
|
||||
const companyName = formData.get('companyName') as string || '';
|
||||
const agree = formData.get('agree') as string || '';
|
||||
|
||||
const validatedFields = SignupFormSchema.safeParse({
|
||||
const SignupFormSchema = await getSignupFormSchema();
|
||||
|
||||
const dataToValidate = {
|
||||
fullName,
|
||||
email,
|
||||
phone: phone.replace(/[-\(\)\s]/g, ''),
|
||||
@@ -162,7 +164,9 @@ export async function registration(
|
||||
confirm_password,
|
||||
agree,
|
||||
companyName
|
||||
});
|
||||
};
|
||||
|
||||
const validatedFields = SignupFormSchema.safeParse(dataToValidate);
|
||||
|
||||
if (!validatedFields.success) {
|
||||
const errors: Record<string, string> = {}
|
||||
@@ -219,7 +223,7 @@ export async function registration(
|
||||
message_code: string
|
||||
};
|
||||
if (parsed.message_desc === 'Operation successful') {
|
||||
await createSession(parsed.message_body.token, email);
|
||||
await createSession(parsed.message_body.token, email as string);
|
||||
} else {
|
||||
throw parsed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user