skailan-crm
Version:
Servicio de CRM y gestión de ventas para Skailan
26 lines • 1.1 kB
JavaScript
export class UpdateActivity {
activityRepository;
constructor(activityRepository) {
this.activityRepository = activityRepository;
}
async execute(request) {
const { id, organizationId, ...updates } = request;
const existingActivity = await this.activityRepository.findById(id, organizationId);
if (!existingActivity) {
throw new Error('Activity not found.');
}
if (updates.type !== undefined)
existingActivity.type = updates.type;
if (updates.description !== undefined)
existingActivity.description = updates.description;
if (updates.date !== undefined)
existingActivity.date = updates.date;
if (updates.assignedToUserId !== undefined)
existingActivity.assignedToUserId = updates.assignedToUserId;
if (updates.status !== undefined)
existingActivity.status = updates.status;
existingActivity.updatedAt = new Date();
return this.activityRepository.save(existingActivity);
}
}
//# sourceMappingURL=UpdateActivity.js.map