({});
+ const validate = useCallback(
+ (fields: ActionField[], values: FormValues): FormErrors => {
+ const errors: FormErrors = {};
+
+ for (const field of fields) {
+ const value = values[field.key];
+ if (value === null || value === "" || value === undefined) {
+ errors[field.key] = t("required_field");
+ }
+ }
+
+ return errors;
+ },
+ [t]
+ );
+
useEffect(() => {
const validationErrors = validate(fields, formValues);
setErrors(validationErrors);
- }, [formValues, fields]);
+ }, [formValues, fields, validate]);
const handleBlur = useCallback((key: string) => {
setTouched(prev => ({ ...prev, [key]: true }));
diff --git a/src/components/widgets/ToastContainer/ToastContainer.tsx b/src/components/widgets/ToastContainer/ToastContainer.tsx
index 0072ce5..9a4c2c6 100644
--- a/src/components/widgets/ToastContainer/ToastContainer.tsx
+++ b/src/components/widgets/ToastContainer/ToastContainer.tsx
@@ -88,12 +88,6 @@ const ToastContainer = memo(() => {
))}
-
- {/* {toasts.length > maxVisible && (
-
- +{toasts.length - maxVisible} в очереди
-
- )} */}
);
});
diff --git a/src/entities/generations/actions.ts b/src/entities/generations/actions.ts
index d73d821..4a5cff6 100644
--- a/src/entities/generations/actions.ts
+++ b/src/entities/generations/actions.ts
@@ -28,7 +28,7 @@ export async function startGeneration(
} catch (error) {
console.error("Failed to start generation:", error);
const errorMessage =
- error instanceof Error ? error.message : "Произошла неизвестная ошибка.";
+ error instanceof Error ? error.message : "Something went wrong.";
return { data: null, error: errorMessage };
}
}
@@ -48,7 +48,7 @@ export async function fetchGenerationStatus(
} catch (error) {
console.error("Failed to fetch generation status:", error);
const errorMessage =
- error instanceof Error ? error.message : "Произошла неизвестная ошибка.";
+ error instanceof Error ? error.message : "Something went wrong.";
return { data: null, error: errorMessage };
}
}
diff --git a/src/entities/subscriptions/actions.ts b/src/entities/subscriptions/actions.ts
index 54c60ef..af958e1 100644
--- a/src/entities/subscriptions/actions.ts
+++ b/src/entities/subscriptions/actions.ts
@@ -28,7 +28,7 @@ export async function performUserSubscriptionAction(
// eslint-disable-next-line no-console
console.error("Failed to perform user subscription action:", error);
const errorMessage =
- error instanceof Error ? error.message : "Произошла неизвестная ошибка.";
+ error instanceof Error ? error.message : "Something went wrong.";
return { data: null, error: errorMessage };
}
}
diff --git a/src/hooks/generation/useGenerationPolling.ts b/src/hooks/generation/useGenerationPolling.ts
index c35aae4..d920514 100644
--- a/src/hooks/generation/useGenerationPolling.ts
+++ b/src/hooks/generation/useGenerationPolling.ts
@@ -14,7 +14,7 @@ export function useGenerationPolling(id: string, interval = 3000) {
useEffect(() => {
if (!id) {
- setError("ID генерации не найден.");
+ setError("ID of generation not found.");
setIsLoading(false);
return;
}