Files
MinglarBackendNestJS/src/modules/minglaradmin/services/rejectionMailtoHost.service.ts

166 lines
5.7 KiB
TypeScript

import { brevoService } from "../../../common/email/brevoApi";
import ApiError from "../../../common/utils/helper/ApiError";
import config from "../../../config/config";
export async function sendEmailToHostForRejectedApplication(
emailAddress: string,
firstName: string
): Promise<{
sent: boolean;
// messageId: string
}> {
const subject = "Action Needed: Host Onboarding Application";
const htmlContent = `
<p>Hi ${firstName},</p>
<p>After reviewing your submission, we're unable to proceed at this stage, as some details require further updates. We encourage you to log in to your Host portal to review the feedback provided and make the necessary changes.</p>
<p><strong>Host portal login:</strong><br/>
<a href="${config.HOST_LINK}" target="_blank">${config.HOST_LINK}</a>
</p>
<p>We appreciate your interest in Minglar and look forward to reviewing your updated application.</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 minglar admin via email.");
}
}
export async function sendAMRejectionMailtoHost(
emailAddress: string,
name: string,
link: string
): Promise<{
sent: boolean;
// messageId: string
}> {
const subject = "Action Needed: Host Onboarding Application";
const htmlContent = `
<p>Hi ${name},</p>
<p>After reviewing your submission, we're unable to proceed at this stage, as some details require further updates. We encourage you to log in to your Host portal to review the feedback provided and make the necessary changes.</p>
<p><a href="${link}" target="_blank">${link}</a></p>
<p>We appreciate your interest in Minglar and look forward to reviewing your updated application.</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 minglar admin via email.");
}
}
export async function sendAMPQQRejectionMailtoHost(
emailAddress: string,
name: string
): Promise<{
sent: boolean;
// messageId: string
}> {
const subject = "Action Needed: Activity Pre-qualification";
const htmlContent = `
<p>Hi ${name},</p>
<p>Thank you for taking the time to submit your activity pre-qualification details on the Minglar platform.</p>
<p>After reviewing your submission, we're unable to approve the application at this stage. However, we encourage you to make the suggested updates and refinements, as many applications are successfully approved after revision.</p>
<p>You can log in to the Host portal to review the feedback and continue updating your application:</p>
<p><a href="${config.HOST_LINK_PQ}" target="_blank">${config.HOST_LINK_PQ}</a></p>
<p>If you need any guidance, feel free to reach out to us at info@minglargroup.com.</p>
<p>We appreciate your interest in partnering with Minglar and look forward to reviewing your updated submission.</p>
<p>Thank you,<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 sendActivityRejectionMailtoHost(
emailAddress: string,
name: string
): Promise<{
sent: boolean;
// messageId: string
}> {
const subject = "Action Needed: Activity Onboarding";
const htmlContent = `
<p>Hi ${name},</p>
<p>Thank you for submitting your activity for review.</p>
<p>After evaluating the details provided, we're unable to approve the listing at this stage. A few updates are required before we can proceed.</p>
<p>Please log in to your Host Portal to review the feedback and make the necessary revisions.</p>
<p><strong>Access your Host Portal:</strong><br/>
<a href="${config.HOST_LINK}" target="_blank">${config.HOST_LINK}</a>
</p>
<p>Once the updates have been submitted, our team will re-evaluate your activity promptly.</p>
<p>If you have any questions or need clarification on the feedback, feel free to reach out to us at info@minglargroup.com. We're happy to assist.</p>
<p>Warm regards,<br/>The 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.");
}
}