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