fix(mail): account creation form - add username and is_shared fields

- Add username field to account creation form (defaults to email if empty)
- Add is_shared checkbox toggle for shared mailboxes
- Update CreateAccountPayload type with optional username and is_shared
- The infinite re-render fix (previous commit) resolves the main issue:
  accounts were not shown in settings because loadAccounts was looping,
  flooding the browser with requests and preventing API calls from completing
This commit is contained in:
Agent Zero
2026-07-16 22:41:44 +02:00
parent 68a9415e99
commit 5b3e874cf2
2 changed files with 21 additions and 0 deletions
+19
View File
@@ -40,7 +40,9 @@ export function MailSettingsPage() {
imap_port: 993,
smtp_host: '',
smtp_port: 587,
username: '',
password: '',
is_shared: false,
});
const [saving, setSaving] = useState(false);
const [testing, setTesting] = useState<string | null>(null);
@@ -78,7 +80,9 @@ export function MailSettingsPage() {
imap_port: 993,
smtp_host: '',
smtp_port: 587,
username: '',
password: '',
is_shared: false,
});
} catch (err: any) {
toast.error(err?.message || err?.detail || 'Save failed');
@@ -161,6 +165,12 @@ export function MailSettingsPage() {
onChange={(e) => setNewAccount((prev) => ({ ...prev, display_name: e.target.value }))}
placeholder="John Doe"
/>
<Input
label="Benutzername (IMAP/SMTP)"
value={newAccount.username}
onChange={(e) => setNewAccount((prev) => ({ ...prev, username: e.target.value }))}
placeholder="Leer lassen für E-Mail-Adresse"
/>
<div className="grid grid-cols-2 gap-3">
<Input
label={t('mail.imapHost')}
@@ -196,6 +206,15 @@ export function MailSettingsPage() {
onChange={(e) => setNewAccount((prev) => ({ ...prev, password: e.target.value }))}
required
/>
<label className="flex items-center gap-2 text-sm text-secondary-700">
<input
type="checkbox"
checked={newAccount.is_shared || false}
onChange={(e) => setNewAccount((prev) => ({ ...prev, is_shared: e.target.checked }))}
className="rounded"
/>
Geteiltes Postfach (für alle Tenant-Benutzer sichtbar)
</label>
<div className="flex gap-2">
<Button onClick={handleCreateAccount} isLoading={saving} size="sm">{t('common.save')}</Button>
<Button variant="secondary" size="sm" onClick={() => setShowAddAccount(false)}>{t('common.cancel')}</Button>