checking the activity title should not be same
This commit is contained in:
@@ -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
|
||||
* -------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user