@@ -2,6 +2,7 @@ import { DEFAULT_EVENT_TYPES } from "@/ee/event-types/constants/constants";
2
2
import { EventTypesRepository } from "@/ee/event-types/event-types.repository" ;
3
3
import { CreateEventTypeInput } from "@/ee/event-types/inputs/create-event-type.input" ;
4
4
import { UpdateEventTypeInput } from "@/ee/event-types/inputs/update-event-type.input" ;
5
+ import { EventTypeOutput } from "@/ee/event-types/outputs/event-type.output" ;
5
6
import { MembershipsRepository } from "@/modules/memberships/memberships.repository" ;
6
7
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service" ;
7
8
import { SelectedCalendarsRepository } from "@/modules/selected-calendars/selected-calendars.repository" ;
@@ -22,7 +23,7 @@ export class EventTypesService {
22
23
private readonly dbWrite : PrismaWriteService
23
24
) { }
24
25
25
- async createUserEventType ( user : UserWithProfile , body : CreateEventTypeInput ) {
26
+ async createUserEventType ( user : UserWithProfile , body : CreateEventTypeInput ) : Promise < EventTypeOutput > {
26
27
await this . checkCanCreateEventType ( user . id , body ) ;
27
28
const eventTypeUser = await this . getUserToCreateEvent ( user ) ;
28
29
const { eventType } = await createEventType ( {
@@ -34,7 +35,7 @@ export class EventTypesService {
34
35
prisma : this . dbWrite . prisma ,
35
36
} ,
36
37
} ) ;
37
- return eventType ;
38
+ return eventType as EventTypeOutput ;
38
39
}
39
40
40
41
async checkCanCreateEventType ( userId : number , body : CreateEventTypeInput ) {
@@ -88,7 +89,7 @@ export class EventTypesService {
88
89
}
89
90
90
91
this . checkUserOwnsEventType ( user . id , eventType . eventType ) ;
91
- return eventType ;
92
+ return eventType as { eventType : EventTypeOutput } ;
92
93
}
93
94
94
95
async getEventTypesPublicByUsername ( username : string ) : Promise < EventTypesPublic > {
@@ -126,9 +127,13 @@ export class EventTypesService {
126
127
} ,
127
128
} ) ;
128
129
129
- const { eventType } = await this . getUserEventTypeForAtom ( user , eventTypeId ) ;
130
+ const eventType = await this . getUserEventTypeForAtom ( user , eventTypeId ) ;
130
131
131
- return eventType ;
132
+ if ( ! eventType ) {
133
+ throw new NotFoundException ( `Event type with id ${ eventTypeId } not found` ) ;
134
+ }
135
+
136
+ return eventType . eventType ;
132
137
}
133
138
134
139
async checkCanUpdateEventType ( userId : number , eventTypeId : number ) {
0 commit comments