diff --git a/serverless/functions/minglaradmin.yml b/serverless/functions/minglaradmin.yml index 273ae25..c660469 100644 --- a/serverless/functions/minglaradmin.yml +++ b/serverless/functions/minglaradmin.yml @@ -324,7 +324,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: @@ -340,7 +340,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/host/services/host.service.ts b/src/modules/host/services/host.service.ts index c8a0281..01fe64d 100644 --- a/src/modules/host/services/host.service.ts +++ b/src/modules/host/services/host.service.ts @@ -377,6 +377,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, }); 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'); diff --git a/src/modules/minglaradmin/services/minglar.service.ts b/src/modules/minglaradmin/services/minglar.service.ts index c4e190b..8ce3c93 100644 --- a/src/modules/minglaradmin/services/minglar.service.ts +++ b/src/modules/minglaradmin/services/minglar.service.ts @@ -261,6 +261,7 @@ export class MinglarService { const whereClause: any = { isActive: true, activityInternalStatus: { notIn: [ACTIVITY_INTERNAL_STATUS.DRAFT_PQ] }, + activityInternalStatus: { notIn: [ACTIVITY_INTERNAL_STATUS.DRAFT_PQ] }, ...(hostXid ? { hostXid } : {}), }; @@ -601,6 +602,7 @@ export class MinglarService { mobileNumber: true, dateOfBirth: true, profileImage: true, + roleXid: true, userAddressDetails: { where: { isActive: true }, take: 1, @@ -629,51 +631,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 > 75) { await tx.user.update({ where: { id: userId }, data: { isProfileUpdated: true }, }); - // } console.log('Transaction completed successfully'); @@ -685,6 +646,7 @@ export class MinglarService { mobileNumber: updatedUser.mobileNumber, dateOfBirth: updatedUser.dateOfBirth, profileImage: updatedUser.profileImage, + roleXid: updatedUser.roleXid, }, address: updatedUser.userAddressDetails[0] || null, documents: updatedUser.userDocuments,