@@ -53,9 +53,8 @@ const buildBaseWhereCondition = async ({
5353 isEmptyResponse ?: boolean ;
5454} > => {
5555 let whereCondition : Prisma . BookingTimeStatusWhereInput = { } ;
56- const ANDConditions : Prisma . BookingTimeStatusWhereInput [ ] = [ ] ;
5756 // EventType Filter
58- if ( eventTypeId ) ANDConditions . push ( { OR : [ { eventTypeId } , { eventParentId : eventTypeId } ] } ) ;
57+ if ( eventTypeId ) whereCondition . OR = [ { eventTypeId } , { eventParentId : eventTypeId } ] ;
5958 // User/Member filter
6059 if ( memberUserId ) whereCondition . userId = memberUserId ;
6160 if ( userId ) {
@@ -77,9 +76,13 @@ const buildBaseWhereCondition = async ({
7776 return {
7877 whereCondition : {
7978 ...whereCondition ,
80- teamId : ctx . userOrganizationId ,
81- isTeamBooking : true ,
82- ...( ANDConditions . length > 0 ? { AND : [ ...ANDConditions ] } : { } ) ,
79+ OR : [
80+ ...( whereCondition . OR ?? [ ] ) ,
81+ {
82+ teamId : ctx . userOrganizationId ,
83+ isTeamBooking : true ,
84+ } ,
85+ ] ,
8386 } ,
8487 isEmptyResponse : true ,
8588 } ;
@@ -102,23 +105,18 @@ const buildBaseWhereCondition = async ({
102105 const userIdsFromOrg = usersFromOrg . map ( ( u ) => u . userId ) ;
103106 whereCondition = {
104107 ...whereCondition ,
105- AND : [
106- ...ANDConditions ,
108+ OR : [
107109 {
108- OR : [
109- {
110- teamId : {
111- in : [ ctx . userOrganizationId , ...teamsFromOrg . map ( ( t ) => t . id ) ] ,
112- } ,
113- isTeamBooking : true ,
114- } ,
115- {
116- userId : {
117- in : userIdsFromOrg ,
118- } ,
119- isTeamBooking : false ,
120- } ,
121- ] ,
110+ teamId : {
111+ in : [ ctx . userOrganizationId , ...teamsFromOrg . map ( ( t ) => t . id ) ] ,
112+ } ,
113+ isTeamBooking : true ,
114+ } ,
115+ {
116+ userId : {
117+ in : userIdsFromOrg ,
118+ } ,
119+ isTeamBooking : false ,
122120 } ,
123121 ] ,
124122 } ;
@@ -137,21 +135,16 @@ const buildBaseWhereCondition = async ({
137135 const userIdsFromTeam = usersFromTeam . map ( ( u ) => u . userId ) ;
138136 whereCondition = {
139137 ...whereCondition ,
140- AND : [
141- ...ANDConditions ,
138+ OR : [
142139 {
143- OR : [
144- {
145- teamId,
146- isTeamBooking : true ,
147- } ,
148- {
149- userId : {
150- in : userIdsFromTeam ,
151- } ,
152- isTeamBooking : false ,
153- } ,
154- ] ,
140+ teamId,
141+ isTeamBooking : true ,
142+ } ,
143+ {
144+ userId : {
145+ in : userIdsFromTeam ,
146+ } ,
147+ isTeamBooking : false ,
155148 } ,
156149 ] ,
157150 } ;
0 commit comments