revert changes

This commit is contained in:
smanylov
2026-02-03 17:36:09 +07:00
parent 61e3d08136
commit e8c57729be
10 changed files with 145 additions and 181 deletions
+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;
}