Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update AuthSettings.tsx (#1006)

Leendert de Borst0b7cdbce02c4
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/AuthSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/AuthSettings.tsx
index 657e943c9..3b83d3748 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/AuthSettings.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/AuthSettings.tsx
@@ -21,10 +21,13 @@ const DEFAULT_OPTIONS: ApiOption[] = [
];
// Validation schema for URLs
-const urlSchema = Yup.object().shape({
+/**
+ * Creates a URL validation schema with localized error messages.
+ */
+const createUrlSchema = (t: (key: string) => string): Yup.ObjectSchema<{apiUrl: string; clientUrl: string}> => Yup.object().shape({
apiUrl: Yup.string()
- .required('API URL is required')
- .test('is-valid-api-url', 'Please enter a valid API URL', (value: string | undefined) => {
+ .required(t('validation.apiUrlRequired'))
+ .test('is-valid-api-url', t('validation.apiUrlInvalid'), (value: string | undefined) => {
if (!value) {
return true; // Allow empty for non-custom option
}
@@ -36,8 +39,8 @@ const urlSchema = Yup.object().shape({
}
}),
clientUrl: Yup.string()
- .required('Client URL is required')
- .test('is-valid-client-url', 'Please enter a valid client URL', (value: string | undefined) => {
+ .required(t('validation.clientUrlRequired'))
+ .test('is-valid-client-url', t('validation.clientUrlInvalid'), (value: string | undefined) => {
if (!value) {
return true; // Allow empty for non-custom option
}
@@ -61,6 +64,8 @@ const AuthSettings: React.FC = () => {
const [isGloballyEnabled, setIsGloballyEnabled] = useState<boolean>(true);
const [errors, setErrors] = useState<{ apiUrl?: string; clientUrl?: string }>({});
const { setIsInitialLoading } = useLoading();
+
+ const urlSchema = createUrlSchema(t);
useEffect(() => {
/**
diff --git a/apps/browser-extension/src/locales/en/settings.json b/apps/browser-extension/src/locales/en/settings.json
index f24432f80..7510c4c85 100644
--- a/apps/browser-extension/src/locales/en/settings.json
+++ b/apps/browser-extension/src/locales/en/settings.json
@@ -29,5 +29,11 @@
"keyboardShortcuts": "Keyboard Shortcuts",
"configureKeyboardShortcuts": "Configure keyboard shortcuts",
"configure": "Configure",
- "versionPrefix": "Version "
+ "versionPrefix": "Version ",
+ "validation": {
+ "apiUrlRequired": "API URL is required",
+ "apiUrlInvalid": "Please enter a valid API URL",
+ "clientUrlRequired": "Client URL is required",
+ "clientUrlInvalid": "Please enter a valid client URL"
+ }
}
\ No newline at end of file
diff --git a/apps/browser-extension/src/locales/nl/settings.json b/apps/browser-extension/src/locales/nl/settings.json
index b85e786b8..1f538ce79 100644
--- a/apps/browser-extension/src/locales/nl/settings.json
+++ b/apps/browser-extension/src/locales/nl/settings.json
@@ -29,5 +29,11 @@
"keyboardShortcuts": "Snelkoppelingen",
"configureKeyboardShortcuts": "Snelkoppelingen configureren",
"configure": "Configureren",
- "versionPrefix": "Versie "
+ "versionPrefix": "Versie ",
+ "validation": {
+ "apiUrlRequired": "API URL is vereist",
+ "apiUrlInvalid": "Voer een geldige API URL in",
+ "clientUrlRequired": "Client URL is vereist",
+ "clientUrlInvalid": "Voer een geldige client URL in"
+ }
}
\ No newline at end of file