115 lines
3.3 KiB
TypeScript
115 lines
3.3 KiB
TypeScript
import { brevoService } from "../../../common/email/brevoApi";
|
|
import ApiError from "../../../common/utils/helper/ApiError";
|
|
import config from "../../../config/config";
|
|
|
|
export async function sendEmailToHostForApprovedApplication(
|
|
emailAddress: string,
|
|
name: string
|
|
): Promise<{
|
|
sent: boolean;
|
|
// messageId: string
|
|
}> {
|
|
|
|
const subject = "Approval for your application";
|
|
|
|
const htmlContent = `
|
|
<p>Dear ${name},</p>
|
|
<p>Congratulations, Your application to minglar admin has been approved.</p>
|
|
<p>You can start onboarding your activities through the host panel.</p>
|
|
<p> You can login to your account using the link below:<br/>
|
|
<strong>Link:</strong> ${config.HOST_LINK} </p>
|
|
<p>Best regards,<br/>Minglar Team</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 minglar admin via email.");
|
|
}
|
|
}
|
|
|
|
export async function sendEmailToHostForMinglarApproval(
|
|
emailAddress: string,
|
|
): Promise<{
|
|
sent: boolean;
|
|
// messageId: string
|
|
}> {
|
|
|
|
const subject = "Approval for your application";
|
|
|
|
const htmlContent = `
|
|
<p>Dear Host,</p>
|
|
<p>Congratulations, Your application to minglar admin has been approved by minglar admin.</p>
|
|
<p>Minglar admin will assign account manager to your application.</p>
|
|
<p>Best regards,<br/>Minglar Team</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 minglar admin via email.");
|
|
}
|
|
}
|
|
|
|
export async function sendAMPQQAcceptanceMailtoHost(
|
|
emailAddress: string,
|
|
name: string
|
|
): Promise<{
|
|
sent: boolean;
|
|
// messageId: string
|
|
}> {
|
|
|
|
const subject = "Approval for your activity onboarding application";
|
|
|
|
const htmlContent = `
|
|
<p>Dear ${name},</p>
|
|
<p>Congratulations, Your activity onboarding application to minglar admin has been approved.</p>
|
|
<p>You can start adding other details of your activity through the host panel.</p>
|
|
<p> You can login to your account using the link below:<br/>
|
|
<strong>Link:</strong> ${config.HOST_LINK} </p>
|
|
<p>Best regards,<br/>Minglar Team</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 minglar admin via email.");
|
|
}
|
|
}
|