const PersonalUserRepository = require('../../../repositories/user/personal/PersonalUserRepository'); const { logger } = require('../../../middleware/logger'); class PersonalProfileService { static async completeProfile(userId, profileData, unitOfWork) { logger.info('PersonalProfileService.completeProfile:start', { userId }); try { const repo = new PersonalUserRepository(unitOfWork); await repo.updateProfileAndMarkCompleted(userId, profileData); logger.info('PersonalProfileService.completeProfile:profile_completed', { userId }); // Check if all steps are complete and set status to 'pending' if so const UserStatusService = require('../../status/UserStatusService'); await UserStatusService.checkAndSetPendingIfComplete(userId, unitOfWork); logger.info('PersonalProfileService.completeProfile:pending_check_complete', { userId }); logger.info('PersonalProfileService.completeProfile:success', { userId }); return true; } catch (error) { logger.error('PersonalProfileService.completeProfile:error', { userId, error: error.message }); throw error; } } static async updateBasic(userId, payload, unitOfWork) { logger.info('PersonalProfileService.updateBasic:start', { userId }); const repo = new PersonalUserRepository(unitOfWork); const updated = await repo.updateBasicInfo(userId, payload); const UserStatusService = require('../../status/UserStatusService'); await UserStatusService.checkAndSetPendingIfComplete(userId, unitOfWork); logger.info('PersonalProfileService.updateBasic:success', { userId }); return updated; } static async updateBank(userId, payload, unitOfWork) { logger.info('PersonalProfileService.updateBank:start', { userId }); const repo = new PersonalUserRepository(unitOfWork); const updated = await repo.updateBankInfo(userId, payload); const UserStatusService = require('../../status/UserStatusService'); await UserStatusService.checkAndSetPendingIfComplete(userId, unitOfWork); logger.info('PersonalProfileService.updateBank:success', { userId }); return updated; } } module.exports = PersonalProfileService;