27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
const CompanyUserRepository = require('../repositories/CompanyUserRepository');
|
|
const { logger } = require('../middleware/logger');
|
|
|
|
class CompanyProfileService {
|
|
static async completeProfile(userId, profileData, unitOfWork) {
|
|
logger.info('CompanyProfileService.completeProfile:start', { userId });
|
|
try {
|
|
// Pass all profileData including country to repository
|
|
const repo = new CompanyUserRepository(unitOfWork);
|
|
await repo.updateProfileAndMarkCompleted(userId, profileData);
|
|
logger.info('CompanyProfileService.completeProfile:profile_completed', { userId });
|
|
|
|
// Check if all steps are complete and set status to 'pending' if so
|
|
const UserStatusService = require('./UserStatusService');
|
|
await UserStatusService.checkAndSetPendingIfComplete(userId, unitOfWork);
|
|
logger.info('CompanyProfileService.completeProfile:pending_check_complete', { userId });
|
|
logger.info('CompanyProfileService.completeProfile:success', { userId });
|
|
return true;
|
|
} catch (error) {
|
|
logger.error('CompanyProfileService.completeProfile:error', { userId, error: error.message });
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = CompanyProfileService;
|