fix chat email message
This commit is contained in:
parent
4d21581c97
commit
2daea21ef4
|
|
@ -179,36 +179,74 @@ export const sendMessageNotification = async (
|
||||||
senderEmail: string,
|
senderEmail: string,
|
||||||
senderPhone: string | null,
|
senderPhone: string | null,
|
||||||
senderPersonnummer: string | null,
|
senderPersonnummer: string | null,
|
||||||
|
senderAddress: string | null,
|
||||||
|
senderZipCode: string | null,
|
||||||
|
senderCity: string | null,
|
||||||
messageContent: string,
|
messageContent: string,
|
||||||
actionLink: 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 phoneDisplay = senderPhone || 'Ej angivet';
|
||||||
const personnummerDisplay = senderPersonnummer || '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 = `
|
// Build customer details section only if sender is a customer
|
||||||
<h2 style="font-size: 16px; font-weight: 800; text-transform: uppercase; margin-bottom: 20px; letter-spacing: 1px;">Nytt Meddelande</h2>
|
const customerDetailsSection = isCustomerSender ? `
|
||||||
|
<div style="background: #f7fafc; padding: 25px; border-left: 4px solid #000000; margin-bottom: 30px;">
|
||||||
|
<h3 style="font-size: 12px; font-weight: 800; text-transform: uppercase; margin: 0 0 20px 0; letter-spacing: 2px; color: #666666;">Avsändarinformation</h3>
|
||||||
|
<table style="width: 100%; font-size: 14px; border-collapse: collapse;">
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 8px 0; width: 140px; font-weight: 700; color: #333333;">Namn:</td>
|
||||||
|
<td style="padding: 8px 0; color: #000000;">${senderName}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 8px 0; font-weight: 700; color: #333333;">E-post:</td>
|
||||||
|
<td style="padding: 8px 0;"><a href="mailto:${senderEmail}" style="color: #000000; text-decoration: underline;">${senderEmail}</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 8px 0; font-weight: 700; color: #333333;">Telefon:</td>
|
||||||
|
<td style="padding: 8px 0; color: #000000;">${phoneDisplay}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 8px 0; font-weight: 700; color: #333333;">Personnummer:</td>
|
||||||
|
<td style="padding: 8px 0; color: #000000;">${personnummerDisplay}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 8px 0; font-weight: 700; color: #333333;">Adress:</td>
|
||||||
|
<td style="padding: 8px 0; color: #000000;">${fullAddressDisplay}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
` : `
|
||||||
<div style="background: #f7fafc; padding: 20px; border-left: 4px solid #000000; margin-bottom: 30px;">
|
<div style="background: #f7fafc; padding: 20px; border-left: 4px solid #000000; margin-bottom: 30px;">
|
||||||
<p style="font-size: 14px; margin: 0 0 10px 0;"><strong>Från:</strong> ${senderName}</p>
|
<p style="font-size: 14px; margin: 0 0 10px 0;"><strong>Från:</strong> ${senderName}</p>
|
||||||
<p style="font-size: 14px; margin: 0 0 10px 0;"><strong>Email:</strong> <a href="mailto:${senderEmail}" style="color: #000000;">${senderEmail}</a></p>
|
<p style="font-size: 14px; margin: 0;"><strong>Email:</strong> <a href="mailto:${senderEmail}" style="color: #000000;">${senderEmail}</a></p>
|
||||||
<p style="font-size: 14px; margin: 0 0 10px 0;"><strong>Telefon:</strong> ${phoneDisplay}</p>
|
|
||||||
<p style="font-size: 14px; margin: 0;"><strong>Personnummer:</strong> ${personnummerDisplay}</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const content = `
|
||||||
|
<h2 style="font-size: 16px; font-weight: 800; text-transform: uppercase; margin-bottom: 25px; letter-spacing: 1px;">Nytt Meddelande</h2>
|
||||||
|
|
||||||
<div style="background: #ffffff; padding: 20px; border: 1px solid #e2e8f0; margin-bottom: 30px;">
|
${customerDetailsSection}
|
||||||
<h3 style="font-size: 14px; font-weight: 700; text-transform: uppercase; margin: 0 0 15px 0; letter-spacing: 1px;">Meddelande:</h3>
|
|
||||||
<blockquote style="font-size: 14px; line-height: 1.7; color: #444444; margin: 0; padding-left: 10px; border-left: 3px solid #e2e8f0;">
|
<div style="background: #ffffff; padding: 25px; border: 1px solid #e2e8f0; margin-bottom: 30px;">
|
||||||
${messageContent}
|
<h3 style="font-size: 12px; font-weight: 800; text-transform: uppercase; margin: 0 0 15px 0; letter-spacing: 2px; color: #666666;">Meddelande</h3>
|
||||||
</blockquote>
|
<div style="font-size: 14px; line-height: 1.8; color: #333333; padding: 15px; background: #fafafa; border-radius: 4px;">
|
||||||
|
${messageContent.replace(/\n/g, '<br>')}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="${actionLink}" style="display: block; background: #000000; color: #ffffff; text-align: center; padding: 16px; text-decoration: none; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; border-radius: 4px;">
|
<a href="${actionLink}" style="display: block; background: #000000; color: #ffffff; text-align: center; padding: 18px; text-decoration: none; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 2px; border-radius: 4px;">
|
||||||
${actionText}
|
${actionText}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #e2e8f0;">
|
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #e2e8f0;">
|
||||||
<p style="font-size: 12px; color: #999999;">
|
<p style="font-size: 12px; color: #999999; text-align: center;">
|
||||||
Klicka på knappen ovan för att svara direkt i portalen.
|
Klicka på knappen ovan för att svara direkt i portalen.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue