sending welcome email to host and changed the email template for sending otp

This commit is contained in:
2026-04-04 19:12:28 +05:30
parent 6703dc784d
commit ea461b6056
3 changed files with 61 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import { prismaClient } from '../../../../../common/database/prisma.lambda.servi
import { HostService } from '../../../services/host.service';
import ApiError from '../../../../../common/utils/helper/ApiError';
import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost';
import { sendWelcomeEmailToHost } from '../../../services/sendOTPEmail.service';
const hostService = new HostService(prismaClient);
@@ -46,7 +47,8 @@ export const handler = safeHandler(async (
throw new ApiError(400, 'Password must be at least 8 characters long');
}
await hostService.createPassword(user_xid, password);
const result = await hostService.createPassword(user_xid, password);
await sendWelcomeEmailToHost(result.emailAddress);
return {
statusCode: 200,

View File

@@ -879,10 +879,10 @@ export class HostService {
return newUser;
}
async createPassword(user_xid: number, password: string): Promise<boolean> {
async createPassword(user_xid: number, password: string): Promise<Partial<User>> {
// Find user by id
const user = await this.prisma.user.findUnique({
where: { id: user_xid },
where: { id: user_xid, isActive: true },
select: { id: true, emailAddress: true, userPassword: true },
});
@@ -912,7 +912,7 @@ export class HostService {
},
});
return true;
return user;
}
async getBankBranchById(bankBranchXid: number) {

View File

@@ -1,5 +1,6 @@
import { brevoService } from "@/common/email/brevoApi";
import ApiError from "@/common/utils/helper/ApiError";
import { brevoService } from "../../../common/email/brevoApi";
import ApiError from "../../../common/utils/helper/ApiError";
import config from "../../../config/config";
export async function sendOtpEmailForHost(
emailAddress: string,
@@ -9,14 +10,60 @@ export async function sendOtpEmailForHost(
// messageId: string
}> {
const subject = "OTP for Host Registration";
const subject = "Your Minglar Verification Code";
const htmlContent = `
<p>Dear Host,</p>
<p>Youre almost all set! 🎉</p>
<p>Enter <strong>${otp}</strong> to wrap your registration.</p>
<p>This code will be valid for the next 5 minutes.</p>
<p>Warm regards,<br/>Minglar Team</p>
<p>Hi there 👋</p>
<p>Heres 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 didnt 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><br/><br/>
<p>Were excited to have you join Minglar as a host. Welcome aboard! 🌟</p><br/><br/>
<p>To get started and bring your activities live, heres what comes next:</p><br/><br/>
<p><strong>Your next steps:</strong></p><br/>
<p>1. Complete your host profile</p><br/>
<p>2. Complete the pre-qualification process for all your activities</p><br/>
<p>3. Submit your activity details for review</p><br/>
<p>4. Go live and start receiving bookings</p><br/><br/>
<p><strong>👉 Access your Host Portal:</strong></p><br/>
<p>${config.HOST_LINK}</p><br/><br/><br/>
<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><br/><br/>
<p>Were looking forward to seeing your experiences come to life on Minglar.</p><br/><br/>
<p>Warm regards,<br/>Team Minglar</p>
`;
try {