add tarrifs

This commit is contained in:
smanylov
2026-02-03 17:31:27 +07:00
parent 1e199de7b2
commit e0606c5486
10 changed files with 161 additions and 156 deletions
+1
View File
@@ -1,4 +1,5 @@
'use server'
import { getSessionData, deleteSession } from '@/app/actions/session';
import { testUserData, API_BASE_URL } from '@/app/actions/definitions';
import { redirect } from 'next/navigation';
-16
View File
@@ -170,8 +170,6 @@ export async function registration(
const validatedFields = SignupFormSchema.safeParse(dataToValidate);
console.log(`account-type ${accountType}`)
if (!validatedFields.success) {
const errors: Record<string, string> = {}
JSON.parse(validatedFields.error.message).forEach((obj: {
@@ -199,19 +197,6 @@ export async function registration(
};
}
/*
return {
previousState: {
fullName,
email,
password,
confirm_password,
phone,
agree,
...(accountType === 'b2b' && { companyName })
}
}; */
try {
const { fullName, email, password, phone } = validatedFields.data;
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
@@ -243,7 +228,6 @@ export async function registration(
if (parsed.message_desc === 'Operation successful') {
await createSession(parsed.message_body.token, email as string);
console.log('succes registration');
} else {
throw parsed;
}
+18 -9
View File
@@ -35,6 +35,9 @@ interface ValidationConfig {
const defaultConfig = validationConfig as ValidationConfig;
let cachedSignupSchema: any = null;
let schemaPromise: Promise<any> | null = null;
async function loadConfigFromBackend(accountType?: 'b2b' | 'b2c'): Promise<any> {
try {
const response = await fetch('/api/validation-config');
@@ -48,16 +51,22 @@ async function loadConfigFromBackend(accountType?: 'b2b' | 'b2c'): Promise<any>
}
export async function getSignupFormSchema(schemaType?: 'b2b' | 'b2c' | 'resetPassword') {
let schemaPromise: Promise<any> | null = null;
if (cachedSignupSchema) {
return cachedSignupSchema;
}
schemaPromise = (async () => {
const config = await loadConfigFromBackend();
if (schemaType === 'resetPassword') {
return createValidationSchemaForPssword(config);
} else {
return createValidationSchema(config, schemaType);
}
})();
if (!schemaPromise) {
schemaPromise = (async () => {
const config = await loadConfigFromBackend();
if (schemaType === 'resetPassword') {
cachedSignupSchema = createValidationSchemaForPssword(config);
} else {
cachedSignupSchema = createValidationSchema(config, schemaType);
}
return cachedSignupSchema;
})();
}
return await schemaPromise;
}