chore: fix notification on service creation
This commit is contained in:
@@ -388,10 +388,13 @@ export class ServiceSchema extends PothosSchema {
|
||||
commission: commission ?? 0,
|
||||
},
|
||||
})
|
||||
// mail to all mentor or center owner for the center
|
||||
// mail to all mentor and center owner for the center
|
||||
const center = await prisma.center.findUnique({
|
||||
where: { id: service.centerId },
|
||||
})
|
||||
if (!center) {
|
||||
throw new Error('Center not found')
|
||||
}
|
||||
if (!center?.centerOwnerId) {
|
||||
throw new Error('Center owner not found')
|
||||
}
|
||||
@@ -415,8 +418,8 @@ export class ServiceSchema extends PothosSchema {
|
||||
SERVICE_NAME: service.name,
|
||||
CENTER_NAME: center.name,
|
||||
})
|
||||
// get user ids from mentorIds
|
||||
const userIds = mentorIds.map((id) => id)
|
||||
// get user ids from centerMentorIds
|
||||
const userIds = [center.centerOwnerId, ...mentorIds]
|
||||
// send notification to user using context
|
||||
userIds.forEach(async (id) => {
|
||||
// add message to database
|
||||
@@ -443,7 +446,7 @@ export class ServiceSchema extends PothosSchema {
|
||||
})
|
||||
// send notification to user using context
|
||||
// get user ids from mentorIds
|
||||
const userIds = mentorIds.map((id) => id)
|
||||
const userIds = [center.centerOwnerId, ...mentorIds]
|
||||
userIds.forEach(async (id) => {
|
||||
// add message to database
|
||||
const message = await this.prisma.message.create({
|
||||
|
||||
Reference in New Issue
Block a user