Add freemium variant C: archetype persistence, dashboard banner, lesson gate
- User.archetype/utmSource/utmMedium/utmCampaign fields + migration - register flow reads ?archetype/?utm_* and saves them on the User row - dashboard ArchetypeBanner: per-archetype 'твой путь' block - lesson gate after wow-moment lesson (WOW_MOMENT_LESSON_ID=obs-start-l2-006) → tripwire + full-course offer Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,13 +2,20 @@ import { redirect } from "next/navigation";
|
||||
import { getSettings } from "@/lib/settings";
|
||||
import { RegisterForm } from "./register-form";
|
||||
|
||||
export default async function RegisterPage() {
|
||||
export default async function RegisterPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
|
||||
}) {
|
||||
const settings = await getSettings();
|
||||
|
||||
if (settings.registrationEnabled !== "true") {
|
||||
redirect("/login?notice=registration_closed");
|
||||
}
|
||||
|
||||
const sp = await searchParams;
|
||||
const str = (v: string | string[] | undefined) => (Array.isArray(v) ? v[0] : v) ?? "";
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center" style={{ backgroundColor: "var(--background)" }}>
|
||||
<div className="w-full max-w-sm">
|
||||
@@ -26,6 +33,10 @@ export default async function RegisterPage() {
|
||||
privacyPolicyUrl={settings.privacyPolicyUrl}
|
||||
termsUrl={settings.termsUrl}
|
||||
offerUrl={settings.offerUrl}
|
||||
archetype={str(sp.archetype)}
|
||||
utmSource={str(sp.utm_source)}
|
||||
utmMedium={str(sp.utm_medium)}
|
||||
utmCampaign={str(sp.utm_campaign)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -25,9 +25,13 @@ interface Props {
|
||||
privacyPolicyUrl: string;
|
||||
termsUrl: string;
|
||||
offerUrl: string;
|
||||
archetype?: string;
|
||||
utmSource?: string;
|
||||
utmMedium?: string;
|
||||
utmCampaign?: string;
|
||||
}
|
||||
|
||||
export function RegisterForm({ showTermsCheckbox, privacyPolicyUrl, termsUrl, offerUrl }: Props) {
|
||||
export function RegisterForm({ showTermsCheckbox, privacyPolicyUrl, termsUrl, offerUrl, archetype, utmSource, utmMedium, utmCampaign }: Props) {
|
||||
const [name, setName] = useState("");
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
@@ -118,6 +122,10 @@ export function RegisterForm({ showTermsCheckbox, privacyPolicyUrl, termsUrl, of
|
||||
password,
|
||||
website: honeypot,
|
||||
cfTurnstileResponse: turnstileToken,
|
||||
archetype,
|
||||
utmSource,
|
||||
utmMedium,
|
||||
utmCampaign,
|
||||
}),
|
||||
});
|
||||
} catch {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { HomeworkSection } from "@/components/student/homework-section";
|
||||
import { QuizSection } from "@/components/student/quiz-section";
|
||||
import { LessonComments } from "@/components/student/lesson-comments";
|
||||
import { FileFormatBadge } from "@/components/shared/file-format-badge";
|
||||
import { TripwireGateBanner } from "@/components/student/tripwire-gate-banner";
|
||||
|
||||
interface Props {
|
||||
params: Promise<{ slug: string; lessonId: string }>;
|
||||
@@ -90,6 +91,8 @@ export default async function LessonPage({ params }: Props) {
|
||||
if (!lesson || lesson.module.course.slug !== slug) notFound();
|
||||
|
||||
const isCompleted = !!progress;
|
||||
const showTripwireGate =
|
||||
!isAdmin && isCompleted && lessonId === process.env.WOW_MOMENT_LESSON_ID;
|
||||
|
||||
// Build ordered flat list of all lessons for prev/next
|
||||
const allLessons = lesson.module.course.modules.flatMap((m) => m.lessons);
|
||||
@@ -267,6 +270,8 @@ export default async function LessonPage({ params }: Props) {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{showTripwireGate && <TripwireGateBanner />}
|
||||
|
||||
{/* Comments */}
|
||||
{session && (
|
||||
<div
|
||||
|
||||
@@ -3,6 +3,7 @@ import { auth } from "@/lib/auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import Link from "next/link";
|
||||
import { ArchetypeBanner } from "@/components/student/archetype-banner";
|
||||
|
||||
// Продаваемая линейка курсов → лендинг продукта. Курсы из этого списка,
|
||||
// которых нет у студента, показываются на дашборде заблюренными карточками
|
||||
@@ -19,6 +20,11 @@ export default async function StudentDashboard() {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session) redirect("/login");
|
||||
|
||||
const dbUser = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
select: { archetype: true },
|
||||
});
|
||||
|
||||
const enrollments = await prisma.courseEnrollment.findMany({
|
||||
where: { userId: session.user.id },
|
||||
include: {
|
||||
@@ -79,6 +85,8 @@ export default async function StudentDashboard() {
|
||||
{active.length} активных курсов
|
||||
</p>
|
||||
|
||||
{dbUser?.archetype && <ArchetypeBanner archetype={dbUser.archetype} />}
|
||||
|
||||
{active.length === 0 ? (
|
||||
<div className="card-aubade p-12 text-center">
|
||||
<p className="text-4xl mb-3">📚</p>
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function POST(request: NextRequest) {
|
||||
return jsonError("Неверный формат запроса", 400);
|
||||
}
|
||||
|
||||
const { name, email, password, website, cfTurnstileResponse } = body;
|
||||
const { name, email, password, website, cfTurnstileResponse, archetype, utmSource, utmMedium, utmCampaign } = body;
|
||||
|
||||
// Honeypot — bots fill this field, humans don't see it
|
||||
if (website) {
|
||||
@@ -102,6 +102,19 @@ export async function POST(request: NextRequest) {
|
||||
select: { id: true },
|
||||
}),
|
||||
]);
|
||||
// Тип второго мозга из квиза + UTM — сохраняем на юзере для персонализации
|
||||
const VALID_ARCHETYPES = ["architect", "gardener", "librarian", "pragmatist"];
|
||||
if (user && (archetype || utmSource || utmMedium || utmCampaign)) {
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: {
|
||||
archetype: VALID_ARCHETYPES.includes(String(archetype)) ? String(archetype) : null,
|
||||
utmSource: utmSource ? String(utmSource) : null,
|
||||
utmMedium: utmMedium ? String(utmMedium) : null,
|
||||
utmCampaign: utmCampaign ? String(utmCampaign) : null,
|
||||
},
|
||||
});
|
||||
}
|
||||
if (user && course) {
|
||||
await prisma.courseEnrollment.upsert({
|
||||
where: { userId_courseId: { userId: user.id, courseId: course.id } },
|
||||
|
||||
Reference in New Issue
Block a user