89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
import { brevoService } from "../../../common/email/brevoApi";
|
|
import ApiError from "../../../common/utils/helper/ApiError";
|
|
import config from "../../../config/config";
|
|
|
|
export async function sendOtpEmailForHost(
|
|
emailAddress: string,
|
|
otp: string | number
|
|
): Promise<{
|
|
sent: boolean;
|
|
// messageId: string
|
|
}> {
|
|
|
|
const subject = "Your Minglar Verification Code";
|
|
|
|
const htmlContent = `
|
|
<p>Hi there,</p>
|
|
<p>Here's your verification code to get started:</p>
|
|
<p><strong>${otp}</strong></p>
|
|
<p>This code is valid for the next 5 minutes.</p>
|
|
<p>Once verified, you can continue setting up your Minglar account. If you didn't request this, you can safely ignore this email.</p>
|
|
<p>Need help? Reach out to us at info@minglargroup.com.</p>
|
|
<p>Warm regards,<br/>Team Minglar</p>
|
|
`;
|
|
|
|
try {
|
|
const result = await brevoService.sendEmail({
|
|
recipients: [{ email: emailAddress }],
|
|
subject,
|
|
htmlContent,
|
|
});
|
|
|
|
// console.log("📧 Email sent successfully:", result);
|
|
|
|
return {
|
|
sent: true,
|
|
// messageId: result.messageId
|
|
};
|
|
} catch (err) {
|
|
console.error("Brevo email send failed:", err);
|
|
throw new ApiError(500, "Failed to send OTP to host via email.");
|
|
}
|
|
}
|
|
|
|
export async function sendWelcomeEmailToHost(
|
|
emailAddress: string,
|
|
): Promise<{
|
|
sent: boolean;
|
|
// messageId: string
|
|
}> {
|
|
|
|
const subject = "Get Started as a Minglar Host";
|
|
|
|
const htmlContent = `
|
|
<p>Hi ${emailAddress},</p>
|
|
<p>We're excited to have you join Minglar as a host. Welcome aboard!</p>
|
|
<p>To get started and bring your activities live, here's what comes next:</p>
|
|
<p><strong>Your next steps:</strong></p>
|
|
<p>1. Complete your host profile</p>
|
|
<p>2. Complete the pre-qualification process for all your activities</p>
|
|
<p>3. Submit your activity details for review</p>
|
|
<p>4. Go live and start receiving bookings</p>
|
|
<p><strong>Access your Host Portal:</strong><br/>
|
|
<a href="${config.HOST_LINK}" target="_blank">${config.HOST_LINK}</a>
|
|
</p>
|
|
<p>If you need any support along the way, our team is always here to help. You can reach us anytime at info@minglargroup.com.</p>
|
|
<p>We're looking forward to seeing your experiences come to life on Minglar.</p>
|
|
<p>Warm regards,<br/>Team Minglar</p>
|
|
`;
|
|
|
|
try {
|
|
const result = await brevoService.sendEmail({
|
|
recipients: [{ email: emailAddress }],
|
|
subject,
|
|
htmlContent,
|
|
});
|
|
|
|
// console.log("📧 Email sent successfully:", result);
|
|
|
|
return {
|
|
sent: true,
|
|
// messageId: result.messageId
|
|
};
|
|
} catch (err) {
|
|
console.error("Brevo email send failed:", err);
|
|
throw new ApiError(500, "Failed to send OTP to host via email.");
|
|
}
|
|
}
|
|
|