From f1b05c56e5f0002be44680dd18a13dd0883cddec Mon Sep 17 00:00:00 2001 From: duffyduck Date: Sun, 21 Jun 2026 16:04:54 +0200 Subject: [PATCH] Kundendaten-Modal: E-Mail-Wahl Stammdaten vs. Absender MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In der "Anrede & Name"-Section neue Radio-Wahl, sobald die Section aktiv ist: - Stammdaten-E-Mail (customer.email) – default wenn vorhanden - Absender-Adresse (Postfach von dem gesendet wird) - Keine E-Mail einfügen Wird in den Customer-Block-Builder durchgereicht und ersetzt die fix verdrahtete customer.email-Zeile. Wenn die Stammdaten-Mail fehlt, ist der Radio "Stammdaten" disabled und der Default springt auf "Absender". Co-Authored-By: Claude Opus 4.7 --- .../components/email/ComposeEmailModal.tsx | 1 + .../email/InsertCustomerDataModal.tsx | 84 ++++++++++++++++++- 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/email/ComposeEmailModal.tsx b/frontend/src/components/email/ComposeEmailModal.tsx index 0caa6558..19440377 100644 --- a/frontend/src/components/email/ComposeEmailModal.tsx +++ b/frontend/src/components/email/ComposeEmailModal.tsx @@ -420,6 +420,7 @@ export default function ComposeEmailModal({ isOpen={showInsertDataModal} onClose={() => setShowInsertDataModal(false)} contractId={contractId} + senderEmail={account.email} currentBody={body} currentAttachments={attachments} onResult={(newBody, addedAtt) => { diff --git a/frontend/src/components/email/InsertCustomerDataModal.tsx b/frontend/src/components/email/InsertCustomerDataModal.tsx index cebdd915..b0ced755 100644 --- a/frontend/src/components/email/InsertCustomerDataModal.tsx +++ b/frontend/src/components/email/InsertCustomerDataModal.tsx @@ -18,11 +18,21 @@ interface Props { isOpen: boolean; onClose: () => void; contractId: number; + /** + * E-Mail-Adresse des Postfachs, von dem die Mail abgeschickt wird. + * Wird in der "Anrede & Name"-Section als Alternative zur Stammdaten- + * E-Mail angeboten – User-Wunsch 2026-06-21: bei Kundendaten wählen, + * ob die Customer-Email oder die Stressfrei-Wechseln-Absender-Adresse + * eingefügt wird. + */ + senderEmail: string; currentBody: string; currentAttachments: EmailAttachment[]; onResult: (newBody: string, addedAttachments: EmailAttachment[]) => void; } +type EmailChoice = 'master' | 'sender' | 'none'; + const MAX_TOTAL_SIZE = 25 * 1024 * 1024; type SectionKey = @@ -37,6 +47,7 @@ export default function InsertCustomerDataModal({ isOpen, onClose, contractId, + senderEmail, currentBody, currentAttachments, onResult, @@ -73,6 +84,11 @@ export default function InsertCustomerDataModal({ }); const [attachBankCard, setAttachBankCard] = useState(false); const [attachIdentity, setAttachIdentity] = useState(false); + // Welche E-Mail-Adresse in der Customer-Section steht: + // - 'master' = Stammdaten-E-Mail (customer.email) + // - 'sender' = Postfach-Adresse, von der die Mail abgeht (Stressfrei) + // - 'none' = E-Mail-Zeile weglassen + const [emailChoice, setEmailChoice] = useState('master'); const [busy, setBusy] = useState(false); // Bei jedem Öffnen sinnvoll vorbelegen (sonst bleiben "checked" stale @@ -89,6 +105,8 @@ export default function InsertCustomerDataModal({ }); setAttachBankCard(false); setAttachIdentity(false); + // Default: Stammdaten-E-Mail wenn vorhanden, sonst Absender-Adresse. + setEmailChoice(customer?.email ? 'master' : 'sender'); } }, [isOpen, contract, customer, deliveryAddress]); @@ -108,7 +126,13 @@ export default function InsertCustomerDataModal({ const blocks: string[] = []; if (checked.customer && customer) { - blocks.push(formatCustomerBlock(customer, contract)); + const chosenEmail = + emailChoice === 'master' + ? customer.email || '' + : emailChoice === 'sender' + ? senderEmail + : ''; + blocks.push(formatCustomerBlock(customer, contract, chosenEmail)); } if (checked.deliveryAddress && deliveryAddress) { blocks.push(formatAddressBlock('Lieferadresse', deliveryAddress)); @@ -214,6 +238,56 @@ export default function InsertCustomerDataModal({ checked={checked.customer} onToggle={() => toggle('customer')} preview={previewCustomer(customer, contract)} + extra={ + checked.customer && ( +
+
+ E-Mail im Text: +
+ + + +
+ ) + } /> )} {deliveryAddress && ( @@ -368,12 +442,16 @@ function fullName( return parts.filter(Boolean).join(' '); } -function formatCustomerBlock(customer: NonNullable, contract: Contract): string { +function formatCustomerBlock( + customer: NonNullable, + contract: Contract, + email: string, +): string { const lines: string[] = ['Kundendaten:']; lines.push(fullName(customer, contract.type)); if (customer.customerNumber) lines.push(`Kundennummer: ${customer.customerNumber}`); if (customer.birthDate) lines.push(`Geburtsdatum: ${formatDate(customer.birthDate)}`); - if (customer.email) lines.push(`E-Mail: ${customer.email}`); + if (email) lines.push(`E-Mail: ${email}`); if (customer.phone) lines.push(`Telefon: ${customer.phone}`); if (customer.mobile) lines.push(`Mobil: ${customer.mobile}`); return lines.join('\n');