@@ -8,6 +8,7 @@ import { UsersRepository } from "@/modules/users/users.repository";
88import { BadRequestException , Injectable , NotFoundException } from "@nestjs/common" ;
99
1010import { SchedulingType } from "@calcom/platform-libraries" ;
11+ import { slugify } from "@calcom/platform-libraries" ;
1112import { EventTypeMetadata } from "@calcom/platform-libraries/event-types" ;
1213import {
1314 CreateTeamEventTypeInput_2024_06_14 ,
@@ -42,11 +43,13 @@ export class InputOrganizationsEventTypesService {
4243 teamId : number ,
4344 inputEventType : CreateTeamEventTypeInput_2024_06_14
4445 ) {
46+ const slugifiedInputEventType = { ...inputEventType , slug : slugify ( inputEventType . slug ) } ;
47+
4548 await this . validateInputLocations ( teamId , inputEventType . locations ) ;
4649 await this . validateHosts ( teamId , inputEventType . hosts ) ;
47- await this . validateTeamEventTypeSlug ( teamId , inputEventType . slug ) ;
50+ await this . validateTeamEventTypeSlug ( teamId , slugifiedInputEventType . slug ) ;
4851
49- const transformedBody = await this . transformInputCreateTeamEventType ( teamId , inputEventType ) ;
52+ const transformedBody = await this . transformInputCreateTeamEventType ( teamId , slugifiedInputEventType ) ;
5053
5154 await this . inputEventTypesService . validateEventTypeInputs ( {
5255 seatsPerTimeSlot : transformedBody . seatsPerTimeSlot ,
@@ -75,13 +78,21 @@ export class InputOrganizationsEventTypesService {
7578 teamId : number ,
7679 inputEventType : UpdateTeamEventTypeInput_2024_06_14
7780 ) {
81+ const slugifiedInputEventType = inputEventType . slug
82+ ? { ...inputEventType , slug : slugify ( inputEventType . slug ) }
83+ : inputEventType ;
84+
7885 await this . validateInputLocations ( teamId , inputEventType . locations ) ;
7986 await this . validateHosts ( teamId , inputEventType . hosts ) ;
80- if ( inputEventType . slug ) {
81- await this . validateTeamEventTypeSlug ( teamId , inputEventType . slug ) ;
87+ if ( slugifiedInputEventType . slug ) {
88+ await this . validateTeamEventTypeSlug ( teamId , slugifiedInputEventType . slug ) ;
8289 }
8390
84- const transformedBody = await this . transformInputUpdateTeamEventType ( eventTypeId , teamId , inputEventType ) ;
91+ const transformedBody = await this . transformInputUpdateTeamEventType (
92+ eventTypeId ,
93+ teamId ,
94+ slugifiedInputEventType
95+ ) ;
8596
8697 await this . inputEventTypesService . validateEventTypeInputs ( {
8798 eventTypeId : eventTypeId ,
0 commit comments