chat email message fix api
This commit is contained in:
parent
2daea21ef4
commit
ca0a4c6968
|
|
@ -115,7 +115,7 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
|
||||||
|
|
||||||
// Fetch sender's expanded details for the email
|
// Fetch sender's expanded details for the email
|
||||||
const [senderDetails] = await pool.query<RowDataPacket[]>(
|
const [senderDetails] = await pool.query<RowDataPacket[]>(
|
||||||
`SELECT full_name, email, mobile, personnummer FROM users WHERE id = ?`,
|
`SELECT full_name, email, mobile, personnummer, address, zip_code, city FROM users WHERE id = ?`,
|
||||||
[user.userId]
|
[user.userId]
|
||||||
);
|
);
|
||||||
const sender = senderDetails[0];
|
const sender = senderDetails[0];
|
||||||
|
|
@ -144,9 +144,13 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
|
||||||
process.env.SMTP_FROM || 'info@nordicstorium.se',
|
process.env.SMTP_FROM || 'info@nordicstorium.se',
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
content,
|
content,
|
||||||
`${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/messages`,
|
`${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/messages`,
|
||||||
'Se konversation'
|
'Se konversation',
|
||||||
|
false // Admin is sender, not customer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -160,9 +164,13 @@ export async function POST(request: NextRequest, { params }: RouteParams) {
|
||||||
sender.email,
|
sender.email,
|
||||||
sender.mobile,
|
sender.mobile,
|
||||||
sender.personnummer,
|
sender.personnummer,
|
||||||
|
sender.address,
|
||||||
|
sender.zip_code,
|
||||||
|
sender.city,
|
||||||
content,
|
content,
|
||||||
`${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/admin/messages`,
|
`${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/admin/messages`,
|
||||||
'Svara i Adminpanelen'
|
'Svara i Adminpanelen',
|
||||||
|
true // Customer is sender
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,16 +256,28 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send resolution email to customer
|
// Send resolution email to customer
|
||||||
|
const resolveContent = `
|
||||||
|
<div style="font-family: 'Inter', -apple-system, sans-serif; max-width: 600px; margin: 40px auto; border: 1px solid #000000; color: #000000; background: #ffffff; overflow: hidden;">
|
||||||
|
<div style="background: linear-gradient(135deg, #0a192f 0%, #020c1b 100%); padding: 40px; text-align: center; border-bottom: 1px solid #000000;">
|
||||||
|
<h1 style="font-size: 16px; font-weight: 900; text-transform: uppercase; letter-spacing: 4px; margin: 0; color: #ffffff;">Nordic Storium</h1>
|
||||||
|
</div>
|
||||||
|
<div style="padding: 50px 40px;">
|
||||||
|
<h2 style="font-size: 16px; font-weight: 800; text-transform: uppercase; margin-bottom: 25px; letter-spacing: 1px;">Ärende Avslutat</h2>
|
||||||
|
<p style="font-size: 14px; line-height: 1.7; color: #444444; margin-bottom: 20px;">Hej ${conversation.user_name || 'kund'},</p>
|
||||||
|
<p style="font-size: 14px; line-height: 1.7; color: #444444; margin-bottom: 20px;">Vi har markerat ditt ärende "<strong>${conversation.subject}</strong>" som löst.</p>
|
||||||
|
<p style="font-size: 14px; line-height: 1.7; color: #444444; margin-bottom: 30px;">Om du fortfarande har frågor eller känner att ärendet inte är helt löst, tveka inte att kontakta oss igen.</p>
|
||||||
|
<a href="${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/messages" 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;">Öppna Mina Meddelanden</a>
|
||||||
|
<p style="font-size: 14px; line-height: 1.7; color: #666666; margin-top: 30px;">Med vänliga hälsningar,<br><strong>Nordic Storium Support</strong></p>
|
||||||
|
</div>
|
||||||
|
<div style="background: linear-gradient(135deg, #0a192f 0%, #020c1b 100%); padding: 40px; border-top: 1px solid #000000; text-align: center;">
|
||||||
|
<div style="font-size: 10px; color: #ffffff; text-transform: uppercase; letter-spacing: 2px; font-weight: 900;">© ${new Date().getFullYear()} Nordic Storium — Stockholm, Sweden.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
await sendEmail(
|
await sendEmail(
|
||||||
conversation.user_email,
|
conversation.user_email,
|
||||||
`Ärende löst: ${conversation.subject}`,
|
`Ärende löst: ${conversation.subject}`,
|
||||||
`
|
resolveContent
|
||||||
<h2>Ditt ärende har markerats som löst</h2>
|
|
||||||
<p>Hej ${conversation.user_name || 'kund'},</p>
|
|
||||||
<p>Vi har markerat ditt ärende "<strong>${conversation.subject}</strong>" som löst.</p>
|
|
||||||
<p>Om du fortfarande har frågor eller känner att ärendet inte är helt löst, tveka inte att kontakta oss igen.</p>
|
|
||||||
<p>Med vänliga hälsningar,<br/>Nordic Storium Support</p>
|
|
||||||
`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: 'Conversation resolved' });
|
return NextResponse.json({ success: true, message: 'Conversation resolved' });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue