diff --git a/src/modules/host/services/host.service.ts b/src/modules/host/services/host.service.ts index 44b566c..6e3dbac 100644 --- a/src/modules/host/services/host.service.ts +++ b/src/modules/host/services/host.service.ts @@ -3337,6 +3337,34 @@ export class HostService { throw new ApiError(404, 'Activity not found'); } + const normalizedActivityTitle = + typeof payload.activityTitle === 'string' + ? payload.activityTitle.trim() + : ''; + + if (normalizedActivityTitle) { + payload.activityTitle = normalizedActivityTitle; + + const duplicateActivity = await tx.activities.findFirst({ + where: { + id: { not: existingActivity.id }, + isActive: true, + activityTitle: { + equals: normalizedActivityTitle, + mode: 'insensitive', + }, + }, + select: { id: true }, + }); + + if (duplicateActivity) { + throw new ApiError( + 400, + 'Same activity name already exists. Please choose a different name.', + ); + } + } + /* -------------------------------- * 3️⃣ STATUS DECISION * -------------------------------- */