This commit is contained in:
2025-12-06 16:11:53 +05:30
5 changed files with 46 additions and 45 deletions

View File

@@ -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');

View File

@@ -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');

View File

@@ -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,