CentralBackend/services/CompanyProfileService.js
2025-09-07 12:44:01 +02:00

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;