Refactor hostCompanyDetails validation schema to make address and location fields optional; update login handler to remove password comparison logic; enhance host service to include user status check and return specific user fields; clean up profile completion logic in MinglarService.
This commit is contained in:
@@ -629,50 +629,50 @@ export class MinglarService {
|
||||
}
|
||||
|
||||
// 5. Calculate profile completion percentage
|
||||
let percentage = 0;
|
||||
// let percentage = 0;
|
||||
|
||||
// Profile Image: 15%
|
||||
if (updatedUser.profileImage) percentage += 15;
|
||||
// // Profile Image: 15%
|
||||
// if (updatedUser.profileImage) percentage += 15;
|
||||
|
||||
// Name and Phone Number: 15%
|
||||
if (
|
||||
updatedUser.firstName &&
|
||||
updatedUser.lastName &&
|
||||
updatedUser.mobileNumber
|
||||
) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
// // 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;
|
||||
}
|
||||
// // Documents: 45%
|
||||
// if (updatedUser.userDocuments.length >= 2) {
|
||||
// percentage += 45;
|
||||
// } else if (updatedUser.userDocuments.length === 1) {
|
||||
// percentage += 22.5;
|
||||
// }
|
||||
|
||||
const profilePercentage = Math.min(percentage, 100);
|
||||
// const profilePercentage = Math.min(percentage, 100);
|
||||
|
||||
// Update profile completion status
|
||||
if (profilePercentage > 80) {
|
||||
await tx.user.update({
|
||||
where: { id: userId },
|
||||
data: { isProfileUpdated: true },
|
||||
});
|
||||
}
|
||||
// if (profilePercentage > 75) {
|
||||
await tx.user.update({
|
||||
where: { id: userId },
|
||||
data: { isProfileUpdated: true },
|
||||
});
|
||||
// }
|
||||
|
||||
console.log('Transaction completed successfully');
|
||||
|
||||
@@ -687,7 +687,6 @@ export class MinglarService {
|
||||
},
|
||||
address: updatedUser.userAddressDetails[0] || null,
|
||||
documents: updatedUser.userDocuments,
|
||||
profileCompletionPercentage: profilePercentage,
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -1222,6 +1221,18 @@ export class MinglarService {
|
||||
hostCountMap[uid] = g._count.id;
|
||||
});
|
||||
|
||||
for (const user of users) {
|
||||
const am = user.profileImage;
|
||||
|
||||
if (user?.profileImage) {
|
||||
const key = user.profileImage.startsWith('http')
|
||||
? user.profileImage.split('.com/')[1]
|
||||
: user.profileImage;
|
||||
|
||||
user.profileImage = await getPresignedUrl(bucket, key);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Attach host counts to each user
|
||||
return users.map((user) => ({
|
||||
...user,
|
||||
|
||||
Reference in New Issue
Block a user