diff --git a/app/(main)/admin/_tabs/vncdirectory.tsx b/app/(main)/admin/_tabs/vncdirectory.tsx index 911c167d..3cde5fd4 100644 --- a/app/(main)/admin/_tabs/vncdirectory.tsx +++ b/app/(main)/admin/_tabs/vncdirectory.tsx @@ -1,8 +1,10 @@ 'use client'; import { useEffect, useState } from 'react'; +import { useTranslations } from 'next-intl'; import { Save, Loader2, Plus, X } from 'lucide-react'; import { apiFetch } from '@/lib/browser-navigation'; +import { toast } from '@/stores/toast-store'; interface VncDirectoryFormData { enabled: boolean; @@ -49,6 +51,7 @@ const BLANK_FORM: VncDirectoryFormData = { }; export function VncDirectoryTab() { + const t = useTranslations('admin.vncdirectory'); const [config, setConfig] = useState({ ...BLANK_FORM }); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); @@ -105,19 +108,25 @@ export function VncDirectoryTab() { setSaving(true); setMessage(null); - const res = await apiFetch('/api/admin/vncdirectory', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(config), - }); + try { + const res = await apiFetch('/api/admin/vncdirectory', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(config), + }); - if (res.ok) { - setMessage({ type: 'success', text: 'VNCdirectory configuration saved.' }); - setDirty(false); - await fetchConfig(); - } else { - const data = await res.json(); - setMessage({ type: 'error', text: data.error || 'Failed to save' }); + if (res.ok) { + setMessage({ type: 'success', text: t('saved') }); + setDirty(false); + await fetchConfig(); + } else { + const data = await res.json(); + setMessage({ type: 'error', text: data.error || t('save_error') }); + } + } catch (err) { + const msg = err instanceof Error ? err.message : t('save_error'); + setMessage({ type: 'error', text: msg }); + toast.error(msg); } setSaving(false); } @@ -125,7 +134,7 @@ export function VncDirectoryTab() { if (loading) { return (
- Loading... + {t('loading')}
); } @@ -136,9 +145,9 @@ export function VncDirectoryTab() {
-

VNCdirectory

+

{t('title')}

- Centralized identity and directory integration (SAML, LDAP, 2FA) + {t('description')}

{dirty && ( @@ -148,7 +157,7 @@ export function VncDirectoryTab() { className="inline-flex items-center gap-2 h-9 px-4 rounded-md bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 disabled:opacity-50 transition-all shadow-sm" > {saving ? : } - Save configuration + {t('save')} )}
@@ -165,12 +174,12 @@ export function VncDirectoryTab() {
)} -
+
- Enabled + {t('enabled')}

- Turn on VNCdirectory integration for identity management, SSO, and directory services + {t('enabled_description')}