Add styled notification emails and round-attached notifications
- Add 15+ styled email templates matching existing invite email design - Wire up notification triggers in all routers (assignment, round, project, mentor, application, onboarding) - Add test email button for each notification type in admin settings - Add round-attached notifications: admins can configure which notification to send when projects enter a round - Fall back to status-based notifications when round has no configured notification Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,11 @@ import {
|
||||
getAIMentorSuggestions,
|
||||
getRoundRobinMentor,
|
||||
} from '../services/mentor-matching'
|
||||
import {
|
||||
createNotification,
|
||||
notifyProjectTeam,
|
||||
NotificationTypes,
|
||||
} from '../services/in-app-notification'
|
||||
|
||||
export const mentorRouter = router({
|
||||
/**
|
||||
@@ -160,6 +165,42 @@ export const mentorRouter = router({
|
||||
},
|
||||
})
|
||||
|
||||
// Get team lead info for mentor notification
|
||||
const teamLead = await ctx.prisma.teamMember.findFirst({
|
||||
where: { projectId: input.projectId, role: 'LEAD' },
|
||||
include: { user: { select: { name: true, email: true } } },
|
||||
})
|
||||
|
||||
// Notify mentor of new mentee
|
||||
await createNotification({
|
||||
userId: input.mentorId,
|
||||
type: NotificationTypes.MENTEE_ASSIGNED,
|
||||
title: 'New Mentee Assigned',
|
||||
message: `You have been assigned to mentor "${assignment.project.title}".`,
|
||||
linkUrl: `/mentor/projects/${input.projectId}`,
|
||||
linkLabel: 'View Project',
|
||||
priority: 'high',
|
||||
metadata: {
|
||||
projectName: assignment.project.title,
|
||||
teamLeadName: teamLead?.user?.name || 'Team Lead',
|
||||
teamLeadEmail: teamLead?.user?.email,
|
||||
},
|
||||
})
|
||||
|
||||
// Notify project team of mentor assignment
|
||||
await notifyProjectTeam(input.projectId, {
|
||||
type: NotificationTypes.MENTOR_ASSIGNED,
|
||||
title: 'Mentor Assigned',
|
||||
message: `${assignment.mentor.name || 'A mentor'} has been assigned to support your project.`,
|
||||
linkUrl: `/team/projects/${input.projectId}`,
|
||||
linkLabel: 'View Project',
|
||||
priority: 'high',
|
||||
metadata: {
|
||||
projectName: assignment.project.title,
|
||||
mentorName: assignment.mentor.name,
|
||||
},
|
||||
})
|
||||
|
||||
return assignment
|
||||
}),
|
||||
|
||||
@@ -269,6 +310,42 @@ export const mentorRouter = router({
|
||||
},
|
||||
})
|
||||
|
||||
// Get team lead info for mentor notification
|
||||
const teamLead = await ctx.prisma.teamMember.findFirst({
|
||||
where: { projectId: input.projectId, role: 'LEAD' },
|
||||
include: { user: { select: { name: true, email: true } } },
|
||||
})
|
||||
|
||||
// Notify mentor of new mentee
|
||||
await createNotification({
|
||||
userId: mentorId,
|
||||
type: NotificationTypes.MENTEE_ASSIGNED,
|
||||
title: 'New Mentee Assigned',
|
||||
message: `You have been assigned to mentor "${assignment.project.title}".`,
|
||||
linkUrl: `/mentor/projects/${input.projectId}`,
|
||||
linkLabel: 'View Project',
|
||||
priority: 'high',
|
||||
metadata: {
|
||||
projectName: assignment.project.title,
|
||||
teamLeadName: teamLead?.user?.name || 'Team Lead',
|
||||
teamLeadEmail: teamLead?.user?.email,
|
||||
},
|
||||
})
|
||||
|
||||
// Notify project team of mentor assignment
|
||||
await notifyProjectTeam(input.projectId, {
|
||||
type: NotificationTypes.MENTOR_ASSIGNED,
|
||||
title: 'Mentor Assigned',
|
||||
message: `${assignment.mentor.name || 'A mentor'} has been assigned to support your project.`,
|
||||
linkUrl: `/team/projects/${input.projectId}`,
|
||||
linkLabel: 'View Project',
|
||||
priority: 'high',
|
||||
metadata: {
|
||||
projectName: assignment.project.title,
|
||||
mentorName: assignment.mentor.name,
|
||||
},
|
||||
})
|
||||
|
||||
return assignment
|
||||
}),
|
||||
|
||||
@@ -378,7 +455,7 @@ export const mentorRouter = router({
|
||||
}
|
||||
|
||||
if (mentorId) {
|
||||
await ctx.prisma.mentorAssignment.create({
|
||||
const assignment = await ctx.prisma.mentorAssignment.create({
|
||||
data: {
|
||||
projectId: project.id,
|
||||
mentorId,
|
||||
@@ -388,7 +465,48 @@ export const mentorRouter = router({
|
||||
expertiseMatchScore,
|
||||
aiReasoning,
|
||||
},
|
||||
include: {
|
||||
mentor: { select: { name: true } },
|
||||
project: { select: { title: true } },
|
||||
},
|
||||
})
|
||||
|
||||
// Get team lead info
|
||||
const teamLead = await ctx.prisma.teamMember.findFirst({
|
||||
where: { projectId: project.id, role: 'LEAD' },
|
||||
include: { user: { select: { name: true, email: true } } },
|
||||
})
|
||||
|
||||
// Notify mentor
|
||||
await createNotification({
|
||||
userId: mentorId,
|
||||
type: NotificationTypes.MENTEE_ASSIGNED,
|
||||
title: 'New Mentee Assigned',
|
||||
message: `You have been assigned to mentor "${assignment.project.title}".`,
|
||||
linkUrl: `/mentor/projects/${project.id}`,
|
||||
linkLabel: 'View Project',
|
||||
priority: 'high',
|
||||
metadata: {
|
||||
projectName: assignment.project.title,
|
||||
teamLeadName: teamLead?.user?.name || 'Team Lead',
|
||||
teamLeadEmail: teamLead?.user?.email,
|
||||
},
|
||||
})
|
||||
|
||||
// Notify project team
|
||||
await notifyProjectTeam(project.id, {
|
||||
type: NotificationTypes.MENTOR_ASSIGNED,
|
||||
title: 'Mentor Assigned',
|
||||
message: `${assignment.mentor.name || 'A mentor'} has been assigned to support your project.`,
|
||||
linkUrl: `/team/projects/${project.id}`,
|
||||
linkLabel: 'View Project',
|
||||
priority: 'high',
|
||||
metadata: {
|
||||
projectName: assignment.project.title,
|
||||
mentorName: assignment.mentor.name,
|
||||
},
|
||||
})
|
||||
|
||||
assigned++
|
||||
} else {
|
||||
failed++
|
||||
|
||||
Reference in New Issue
Block a user