From 2daea21ef4a41e6e933ad30e1db42489afd4c609 Mon Sep 17 00:00:00 2001 From: ismail Date: Mon, 2 Feb 2026 20:13:45 +0100 Subject: [PATCH] fix chat email message --- src/lib/email.ts | 66 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/lib/email.ts b/src/lib/email.ts index 5c2429b..45b596e 100644 --- a/src/lib/email.ts +++ b/src/lib/email.ts @@ -179,36 +179,74 @@ export const sendMessageNotification = async ( senderEmail: string, senderPhone: string | null, senderPersonnummer: string | null, + senderAddress: string | null, + senderZipCode: string | null, + senderCity: string | null, messageContent: string, actionLink: string, - actionText: string + actionText: string, + isCustomerSender: boolean = true ) => { - // Determine labels and values even if null to show clarity + // Format display values with fallbacks const phoneDisplay = senderPhone || 'Ej angivet'; const personnummerDisplay = senderPersonnummer || 'Ej angivet'; + const addressDisplay = senderAddress || 'Ej angivet'; + const zipCodeDisplay = senderZipCode || ''; + const cityDisplay = senderCity || ''; + const fullAddressDisplay = [addressDisplay, zipCodeDisplay, cityDisplay].filter(Boolean).join(', '); - const content = ` -

Nytt Meddelande

+ // Build customer details section only if sender is a customer + const customerDetailsSection = isCustomerSender ? ` +
+

Avsändarinformation

+ + + + + + + + + + + + + + + + + + + + + +
Namn:${senderName}
E-post:${senderEmail}
Telefon:${phoneDisplay}
Personnummer:${personnummerDisplay}
Adress:${fullAddressDisplay}
+
+ ` : `

Från: ${senderName}

-

Email: ${senderEmail}

-

Telefon: ${phoneDisplay}

-

Personnummer: ${personnummerDisplay}

+

Email: ${senderEmail}

+ `; + + const content = ` +

Nytt Meddelande

-
-

Meddelande:

-
- ${messageContent} -
+ ${customerDetailsSection} + +
+

Meddelande

+
+ ${messageContent.replace(/\n/g, '
')} +
- + ${actionText}
-

+

Klicka på knappen ovan för att svara direkt i portalen.