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:
@@ -192,7 +192,9 @@ export interface CreateAccountPayload {
|
|||||||
imap_port: number;
|
imap_port: number;
|
||||||
smtp_host: string;
|
smtp_host: string;
|
||||||
smtp_port: number;
|
smtp_port: number;
|
||||||
|
username?: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
is_shared?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateAccountPayload {
|
export interface UpdateAccountPayload {
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ export function MailSettingsPage() {
|
|||||||
imap_port: 993,
|
imap_port: 993,
|
||||||
smtp_host: '',
|
smtp_host: '',
|
||||||
smtp_port: 587,
|
smtp_port: 587,
|
||||||
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
|
is_shared: false,
|
||||||
});
|
});
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [testing, setTesting] = useState<string | null>(null);
|
const [testing, setTesting] = useState<string | null>(null);
|
||||||
@@ -78,7 +80,9 @@ export function MailSettingsPage() {
|
|||||||
imap_port: 993,
|
imap_port: 993,
|
||||||
smtp_host: '',
|
smtp_host: '',
|
||||||
smtp_port: 587,
|
smtp_port: 587,
|
||||||
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
|
is_shared: false,
|
||||||
});
|
});
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
toast.error(err?.message || err?.detail || 'Save failed');
|
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 }))}
|
onChange={(e) => setNewAccount((prev) => ({ ...prev, display_name: e.target.value }))}
|
||||||
placeholder="John Doe"
|
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">
|
<div className="grid grid-cols-2 gap-3">
|
||||||
<Input
|
<Input
|
||||||
label={t('mail.imapHost')}
|
label={t('mail.imapHost')}
|
||||||
@@ -196,6 +206,15 @@ export function MailSettingsPage() {
|
|||||||
onChange={(e) => setNewAccount((prev) => ({ ...prev, password: e.target.value }))}
|
onChange={(e) => setNewAccount((prev) => ({ ...prev, password: e.target.value }))}
|
||||||
required
|
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">
|
<div className="flex gap-2">
|
||||||
<Button onClick={handleCreateAccount} isLoading={saving} size="sm">{t('common.save')}</Button>
|
<Button onClick={handleCreateAccount} isLoading={saving} size="sm">{t('common.save')}</Button>
|
||||||
<Button variant="secondary" size="sm" onClick={() => setShowAddAccount(false)}>{t('common.cancel')}</Button>
|
<Button variant="secondary" size="sm" onClick={() => setShowAddAccount(false)}>{t('common.cancel')}</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user