Remove profile completion percentage calculation from user update in MinglarService
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user