Add email notifications via Resend
- src/lib/email.ts: HTML templates for 4 email types (Second Brain design) - Welcome email on user registration (Better Auth databaseHooks) - Course access email when admin grants enrollment - Homework submitted email to all admins/curators (first submission only) - Feedback received email to student with feedback text and lesson link - Update TECHNICAL.md: Resend domain, from-address, email vars, Stage 3 summary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { headers } from "next/headers";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
import { sendCourseAccessEmail } from "@/lib/email";
|
||||
|
||||
async function requireAdmin() {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
@@ -70,6 +71,16 @@ export async function grantAccess(
|
||||
note: note || null,
|
||||
},
|
||||
});
|
||||
|
||||
// Send email notification
|
||||
const [user, course] = await Promise.all([
|
||||
prisma.user.findUnique({ where: { id: userId }, select: { email: true, name: true } }),
|
||||
prisma.course.findUnique({ where: { id: courseId }, select: { title: true } }),
|
||||
]);
|
||||
if (user && course) {
|
||||
await sendCourseAccessEmail(user.email, user.name, course.title);
|
||||
}
|
||||
|
||||
revalidatePath(`/admin/courses/${courseId}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user