Implement platform settings (Stage 9)
- Wire settings to actual platform behavior: maintenance mode, registration toggle, notification emails, curator feedback emails, email verification flag - Add logo (logoUrl, showLogo) and social network links (YouTube, VK, Telegram) settings - Show logo + school name dynamically in student layout header - Add footer to student layout with org requisites and social links - Register page: read settings server-side, validate terms checkbox with legal links - Login page: show notice when redirected from closed registration - Settings form: add Logo and Social Networks sections Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { auth } from "@/lib/auth";
|
||||
import { headers } from "next/headers";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { sendHomeworkSubmittedEmail } from "@/lib/email";
|
||||
import { getSettings, parseNotificationEmails, asBool } from "@/lib/settings";
|
||||
|
||||
// ── Lesson Progress ───────────────────────────────────────────────────────────
|
||||
|
||||
@@ -72,20 +73,24 @@ export async function submitHomework(
|
||||
});
|
||||
submissionId = created.id;
|
||||
|
||||
const [lesson, admins] = await Promise.all([
|
||||
const [lesson, settings] = await Promise.all([
|
||||
prisma.homework.findUnique({
|
||||
where: { id: homeworkId },
|
||||
include: { lesson: { select: { title: true } } },
|
||||
}),
|
||||
prisma.user.findMany({
|
||||
where: { role: { in: ["admin", "curator"] } },
|
||||
select: { email: true, name: true },
|
||||
}),
|
||||
getSettings(),
|
||||
]);
|
||||
if (lesson) {
|
||||
if (lesson && asBool(settings.notifyOnHomework)) {
|
||||
const configuredEmails = parseNotificationEmails(settings.notificationEmails);
|
||||
const recipients = configuredEmails.length > 0
|
||||
? configuredEmails.map((email) => ({ email, name: "" }))
|
||||
: await prisma.user.findMany({
|
||||
where: { role: { in: ["admin", "curator"] } },
|
||||
select: { email: true, name: true },
|
||||
});
|
||||
await Promise.all(
|
||||
admins.map((a) =>
|
||||
sendHomeworkSubmittedEmail(a.email, a.name, session.user.name, lesson.lesson.title, submissionId)
|
||||
recipients.map((r) =>
|
||||
sendHomeworkSubmittedEmail(r.email, r.name, session.user.name, lesson.lesson.title, submissionId)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,15 @@ export const SETTINGS_DEFAULTS = {
|
||||
curatorCanAnswerQuestions: "true",
|
||||
curatorCanSeeStudents: "true",
|
||||
|
||||
// Logo
|
||||
logoUrl: "",
|
||||
showLogo: "true",
|
||||
|
||||
// Social networks
|
||||
socialYoutube: "",
|
||||
socialVk: "",
|
||||
socialTelegram: "",
|
||||
|
||||
// Code injection
|
||||
headCode: "",
|
||||
bodyCode: "",
|
||||
|
||||
Reference in New Issue
Block a user