From 7b9763c6684bb826440a3d81c4a41a4b5811562d Mon Sep 17 00:00:00 2001 From: Mayank Mishra Date: Fri, 5 Dec 2025 18:51:50 +0530 Subject: [PATCH 1/5] Enhance getAllHostActivityForMinglar method to exclude activities with DRAFT_PQ status --- src/modules/minglaradmin/services/minglar.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/minglaradmin/services/minglar.service.ts b/src/modules/minglaradmin/services/minglar.service.ts index 32080ec..a5192c3 100644 --- a/src/modules/minglaradmin/services/minglar.service.ts +++ b/src/modules/minglaradmin/services/minglar.service.ts @@ -260,6 +260,7 @@ export class MinglarService { async getAllHostActivityForMinglar(search?: string, hostXid?: number, paginationOptions?: { page: number; limit: number; skip: number }) { const whereClause: any = { isActive: true, + activityInternalStatus: { notIn: [ACTIVITY_INTERNAL_STATUS.DRAFT_PQ] }, ...(hostXid ? { hostXid } : {}), }; From 06010ef6e8f4ffe98d2809b761de27631cdf92ac Mon Sep 17 00:00:00 2001 From: Mayank Mishra Date: Fri, 5 Dec 2025 19:21:19 +0530 Subject: [PATCH 2/5] Refactor API paths for acceptPQByAM and rejectPQQByAM to remove activityId from URL and update request body parsing for activityId --- serverless/functions/minglaradmin.yml | 4 ++-- .../handlers/hosthub/hosts/acceptPQByAM.ts | 15 ++++++++++++++- .../handlers/hosthub/hosts/rejectPQQbyAM.ts | 15 ++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/serverless/functions/minglaradmin.yml b/serverless/functions/minglaradmin.yml index d0e5630..3a0e234 100644 --- a/serverless/functions/minglaradmin.yml +++ b/serverless/functions/minglaradmin.yml @@ -340,7 +340,7 @@ RejectPQQByAM: - ${file(./serverless/patterns/base.yml):pattern4} events: - httpApi: - path: /minglaradmin/hosthub/hosts/reject-pq-by-am/{activityId} + path: /minglaradmin/hosthub/hosts/reject-pq-by-am method: patch acceptPQByAM: @@ -356,7 +356,7 @@ acceptPQByAM: - ${file(./serverless/patterns/base.yml):pattern4} events: - httpApi: - path: /minglaradmin/hosthub/hosts/accept-pq-by-am/{activityId} + path: /minglaradmin/hosthub/hosts/accept-pq-by-am method: patch rejectHostApplication: diff --git a/src/modules/minglaradmin/handlers/hosthub/hosts/acceptPQByAM.ts b/src/modules/minglaradmin/handlers/hosthub/hosts/acceptPQByAM.ts index a8af733..13b207c 100644 --- a/src/modules/minglaradmin/handlers/hosthub/hosts/acceptPQByAM.ts +++ b/src/modules/minglaradmin/handlers/hosthub/hosts/acceptPQByAM.ts @@ -8,6 +8,10 @@ import ApiError from '../../../../../common/utils/helper/ApiError'; const prismaService = new PrismaService(); const minglarService = new MinglarService(prismaService); +interface Body { + activityId: number; +} + export const handler = safeHandler(async ( event: APIGatewayProxyEvent, context?: Context @@ -17,7 +21,16 @@ export const handler = safeHandler(async ( const userInfo = await verifyMinglarAdminToken(token); - const activityId = event.pathParameters?.activityId; + // Parse request body + let body: Body; + + try { + body = event.body ? JSON.parse(event.body) : {}; + } catch (error) { + throw new ApiError(400, 'Invalid JSON in request body'); + } + + const { activityId } = body; if (!activityId) { throw new ApiError(400, 'activityId is required'); diff --git a/src/modules/minglaradmin/handlers/hosthub/hosts/rejectPQQbyAM.ts b/src/modules/minglaradmin/handlers/hosthub/hosts/rejectPQQbyAM.ts index acb60af..fec946a 100644 --- a/src/modules/minglaradmin/handlers/hosthub/hosts/rejectPQQbyAM.ts +++ b/src/modules/minglaradmin/handlers/hosthub/hosts/rejectPQQbyAM.ts @@ -8,6 +8,10 @@ import { MinglarService } from '../../../services/minglar.service'; const prismaService = new PrismaService(); const minglarService = new MinglarService(prismaService); +interface Body { + activityId: number; +} + export const handler = safeHandler(async ( event: APIGatewayProxyEvent, context?: Context @@ -17,7 +21,16 @@ export const handler = safeHandler(async ( const userInfo = await verifyMinglarAdminToken(token); - const activityId = event.pathParameters?.activityId; + // Parse request body + let body: Body; + + try { + body = event.body ? JSON.parse(event.body) : {}; + } catch (error) { + throw new ApiError(400, 'Invalid JSON in request body'); + } + + const { activityId } = body; if (!activityId) { throw new ApiError(400, 'activityId is required'); From 51b053310ff06ab6de60b930b32442da115ff8a9 Mon Sep 17 00:00:00 2001 From: Mayank Mishra Date: Sat, 6 Dec 2025 12:06:04 +0530 Subject: [PATCH 3/5] Add validation to prevent duplicate host accounts in addPaymentDetails method --- src/modules/host/services/host.service.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modules/host/services/host.service.ts b/src/modules/host/services/host.service.ts index 6175754..1f8ecda 100644 --- a/src/modules/host/services/host.service.ts +++ b/src/modules/host/services/host.service.ts @@ -368,6 +368,19 @@ export class HostService { async addPaymentDetails(data: AddPaymentDetailsDTO) { return await this.prisma.$transaction(async (tx) => { + const existingAccount = await tx.hostBankDetails.findFirst({ + where: { + accountNumber: data.accountNumber, + isActive: true, + }, + }); + + if (existingAccount) { + throw new ApiError( + 400, + 'Host account with this account number already exists.' + ); + } const addedPaymentDetails = await tx.hostBankDetails.create({ data, }); From d8fb4b242daabccd9c07af9019fc02c38752e19d Mon Sep 17 00:00:00 2001 From: Mayank Mishra Date: Sat, 6 Dec 2025 12:39:21 +0530 Subject: [PATCH 4/5] Add roleXid field to user selection in MinglarService --- src/modules/minglaradmin/services/minglar.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/minglaradmin/services/minglar.service.ts b/src/modules/minglaradmin/services/minglar.service.ts index a5192c3..9eae2b9 100644 --- a/src/modules/minglaradmin/services/minglar.service.ts +++ b/src/modules/minglaradmin/services/minglar.service.ts @@ -591,6 +591,7 @@ export class MinglarService { mobileNumber: true, dateOfBirth: true, profileImage: true, + roleXid: true, userAddressDetails: { where: { isActive: true }, take: 1, From 6a84876518d98f50acaf827be9099de445be26da Mon Sep 17 00:00:00 2001 From: Mayank Mishra Date: Sat, 6 Dec 2025 12:55:07 +0530 Subject: [PATCH 5/5] Remove profile completion percentage calculation from user update in MinglarService --- .../minglaradmin/services/minglar.service.ts | 51 ++----------------- 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/src/modules/minglaradmin/services/minglar.service.ts b/src/modules/minglaradmin/services/minglar.service.ts index 9eae2b9..853a342 100644 --- a/src/modules/minglaradmin/services/minglar.service.ts +++ b/src/modules/minglaradmin/services/minglar.service.ts @@ -620,51 +620,10 @@ export class MinglarService { throw new ApiError(404, 'User not found after update'); } - // 5. Calculate profile completion percentage - let percentage = 0; - - // Profile Image: 15% - if (updatedUser.profileImage) percentage += 15; - - // Name and Phone Number: 15% - if ( - updatedUser.firstName && - updatedUser.lastName && - updatedUser.mobileNumber - ) { - percentage += 15; - } - - // Location Info: 25% - if (updatedUser.userAddressDetails.length > 0) { - const address = updatedUser.userAddressDetails[0]; - if ( - address.address1 && - address.stateXid && - address.countryXid && - address.cityXid && - address.pinCode - ) { - percentage += 25; - } - } - - // Documents: 45% - if (updatedUser.userDocuments.length >= 2) { - percentage += 45; - } else if (updatedUser.userDocuments.length === 1) { - percentage += 22.5; - } - - const profilePercentage = Math.min(percentage, 100); - - // Update profile completion status - if (profilePercentage > 80) { - await tx.user.update({ - where: { id: userId }, - data: { isProfileUpdated: true }, - }); - } + await tx.user.update({ + where: { id: userId }, + data: { isProfileUpdated: true }, + }); console.log('Transaction completed successfully'); @@ -676,10 +635,10 @@ export class MinglarService { mobileNumber: updatedUser.mobileNumber, dateOfBirth: updatedUser.dateOfBirth, profileImage: updatedUser.profileImage, + roleXid: updatedUser.roleXid, }, address: updatedUser.userAddressDetails[0] || null, documents: updatedUser.userDocuments, - profileCompletionPercentage: profilePercentage, }; }); } catch (error) {