Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ NEXT_PUBLIC_DATA_MODE=demo
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=
# Never put a service-role key in this app.
# Optional, server-only (never NEXT_PUBLIC_*): automatic waitlist invitation mails.
# Without these values the admin area offers "Mail schreiben" (own mail client) and "Link kopieren".
# Enter real credentials only on the server, never in the repository.
SITE_URL=https://humans-only.de
SMTP_HOST=
SMTP_PORT=587
SMTP_USER=
SMTP_PASSWORD=
SMTP_FROM=Humans Only <noreply@vibecoding-germany.de>
SMTP_REPLY_TO=
9 changes: 9 additions & 0 deletions app/app/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Metadata } from "next";
import { AdminPage } from "@/components/waitlist";
export const metadata: Metadata = {
title: "Admin · Warteliste",
robots: { index: false, follow: false },
};
export default function Page() {
return <AdminPage />;
}
124 changes: 124 additions & 0 deletions app/app/api/admin/waitlist/invite/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { NextResponse } from "next/server";
import { config } from "@/lib/config";
import { buildInviteMail, readMailConfig } from "@/lib/mail";
import { serverClient } from "@/lib/supabase/server";

export const runtime = "nodejs";
export const dynamic = "force-dynamic";

const noStore = { "Cache-Control": "private, no-store" };
const messages: Record<string, string> = {
ADMIN_REQUIRED: "Dafür brauchst du Admin-Rechte.",
WAITLIST_NOT_FOUND: "Dieser Eintrag existiert nicht mehr.",
WAITLIST_NOT_APPROVED: "Dieser Eintrag ist noch nicht freigegeben.",
SPACE_FORBIDDEN: "Der Raum Vibecoding Germany vergibt gerade keine Tickets.",
};
function fail(status: number, error: string) {
return NextResponse.json({ error }, { status, headers: noStore });
}
function mailConfig() {
const env = process.env;
return readMailConfig({
SMTP_HOST: env.SMTP_HOST,
SMTP_PORT: env.SMTP_PORT,
SMTP_USER: env.SMTP_USER,
SMTP_PASSWORD: env.SMTP_PASSWORD,
SMTP_FROM: env.SMTP_FROM,
SMTP_REPLY_TO: env.SMTP_REPLY_TO,
SITE_URL: env.SITE_URL,
});
}

export async function GET() {
const mail = config.mode === "supabase" ? mailConfig() : null;
return NextResponse.json(
{ enabled: Boolean(mail?.enabled) },
{ headers: noStore },
);
}

export async function POST(request: Request) {
if (config.mode !== "supabase")
return fail(404, "Mailversand gibt es nur im Live-Betrieb.");
// CSRF-Schutz: Fremde Seiten können diesen Header nicht ohne CORS-Preflight setzen.
if (
request.headers.get("x-humans-only") !== "admin" ||
!request.headers.get("content-type")?.startsWith("application/json")
)
return fail(403, "Ungültige Anfrage.");
const mail = mailConfig();
if (!mail.enabled)
return fail(503, "Mailversand ist auf dem Server nicht eingerichtet.");
let entryId = "";
try {
const body = (await request.json()) as { entryId?: unknown };
if (typeof body.entryId === "string") entryId = body.entryId;
} catch {}
if (!/^[0-9a-f-]{36}$/i.test(entryId)) return fail(400, "Ungültiger Eintrag.");

const client = await serverClient();
const { data: auth } = await client.auth.getUser();
if (!auth.user) return fail(401, "Bitte melde dich zuerst an.");

// Rechte prüft die Datenbank (ADMIN_REQUIRED); die Route handelt als angemeldete Person.
const approved = await client.rpc("approve_waitlist_entry", {
p_entry_id: entryId,
});
if (approved.error)
return fail(
approved.error.code === "42501" ? 403 : 400,
messages[approved.error.message] || "Die Freigabe hat nicht geklappt.",
);
const ticket = approved.data!;
if (ticket.redeemed_at)
return fail(409, "Das Ticket wurde schon eingelöst. Keine neue Mail nötig.");
const [entry, inviter] = await Promise.all([
client.from("waitlist_entries").select("*").eq("id", entryId).single(),
client
.from("profiles")
.select("display_name")
.eq("id", auth.user.id)
.single(),
]);
if (entry.error || !entry.data) return fail(404, messages.WAITLIST_NOT_FOUND);

const message = buildInviteMail({
name: entry.data.name,
code: ticket.code,
expiresAt: ticket.expires_at,
inviterName: inviter.data?.display_name || "Dein Humans-Only-Team",
siteUrl: mail.siteUrl,
canReply: Boolean(mail.replyTo),
});
try {
const { createTransport } = await import("nodemailer");
const transport = createTransport({
host: mail.host,
port: mail.port,
secure: mail.secure,
requireTLS: !mail.secure && mail.host !== "localhost" && mail.host !== "127.0.0.1",
auth: mail.user ? { user: mail.user, pass: mail.password } : undefined,
});
await transport.sendMail({
from: mail.from,
to: entry.data.email,
replyTo: mail.replyTo || undefined,
subject: message.subject,
text: message.text,
html: message.html,
});
} catch (err) {
// Keine SMTP-Details an den Browser; im Server-Log steht der Grund.
console.error("waitlist invite mail failed", entryId, err);
return fail(
502,
"Freigegeben, aber die Mail konnte nicht verschickt werden. Versuch es gleich noch einmal oder kopiere den Link.",
);
}
const marked = await client.rpc("mark_waitlist_invited", {
p_entry_id: entryId,
});
if (marked.error)
console.error("waitlist invite mark failed", entryId, marked.error.message);
return NextResponse.json({ ok: true }, { headers: noStore });
}
212 changes: 212 additions & 0 deletions app/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3167,3 +3167,215 @@ textarea::placeholder {
@media (max-width: 760px) {
.hero-scribble { display: none; }
}
/* Warteliste und Admin-Freigabe. */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.waitlist-trap {
position: absolute;
left: -10000px;
width: 1px;
height: 1px;
overflow: hidden;
}
label.consent {
display: flex;
gap: 10px;
align-items: flex-start;
font-weight: 400;
font-size: 11px;
line-height: 1.55;
color: var(--ink-muted);
margin: 18px 0 4px;
cursor: pointer;
}
label.consent input[type="checkbox"] {
width: 18px;
height: 18px;
flex: none;
margin-top: 1px;
accent-color: var(--blue);
}
.waitlist-hint {
font-size: 12px;
margin: 16px 0 0;
color: var(--ink-muted);
}
.waitlist-hint a {
font-weight: 700;
color: var(--ink);
text-decoration: underline;
text-underline-offset: 4px;
}
.waitlist-done p {
font-size: 13px;
line-height: 1.65;
color: var(--ink-muted);
margin-bottom: 20px;
overflow-wrap: anywhere;
}
.waitlist-done p strong {
color: var(--ink);
}
.welcome-actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
justify-content: center;
}
.admin-page {
max-width: 900px;
}
.admin-toolbar {
display: flex;
flex-wrap: wrap;
gap: 12px;
align-items: center;
justify-content: space-between;
margin: 28px 0 18px;
}
.admin-filters {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.admin-filters button {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 7px 12px;
border: 1.5px solid var(--line);
border-radius: 999px;
font-size: 12px;
font-weight: 700;
background: var(--surface-raised);
}
.admin-filters button .nav-count {
font-size: 13px;
width: 20px;
height: 20px;
line-height: 17px;
}
.admin-filters button.active {
background: var(--mango);
color: var(--on-mango);
border-color: var(--on-mango);
box-shadow: 2px 2px 0 var(--on-mango);
}
.admin-filters button.active .nav-count {
border-color: var(--on-mango);
}
.admin-search {
display: flex;
align-items: center;
gap: 8px;
margin: 0;
flex: 1 1 220px;
max-width: 320px;
}
.admin-search input:not([type="range"]):not([type="file"]) {
padding: 9px 11px;
font-size: 13px;
}
.admin-list {
list-style: none;
padding: 0;
margin: 0;
display: grid;
gap: 10px;
}
.admin-row {
display: flex;
flex-wrap: wrap;
gap: 14px;
align-items: center;
justify-content: space-between;
background: var(--surface-raised);
border: 2px solid var(--line);
border-radius: 8px;
padding: 14px 16px;
box-shadow: 3px 3px 0 var(--line);
}
.admin-row.status-rejected {
opacity: 0.7;
box-shadow: none;
}
.admin-person {
display: grid;
gap: 2px;
min-width: 0;
flex: 1 1 240px;
}
.admin-person strong {
font-size: 15px;
}
.admin-person a {
font-size: 13px;
text-decoration: underline;
text-underline-offset: 3px;
overflow-wrap: anywhere;
}
.admin-person small {
font-size: 11px;
color: var(--ink-muted);
}
.admin-actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
}
.admin-actions .button {
font-size: 12px;
padding: 8px 12px;
}
.admin-confirm {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12px;
font-weight: 700;
}
.admin-empty {
padding: 40px 10px;
text-align: center;
color: var(--ink-muted);
font-size: 14px;
border: 1.5px dashed var(--ink-muted);
border-radius: 8px;
}
.admin-note {
margin-top: 22px;
}
@media (max-width: 760px) {
.admin-search {
max-width: none;
}
.admin-actions {
width: 100%;
}
.admin-page .wallet-heading > .mascot {
display: none;
}
}
.admin-bulk {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
margin: 0 0 16px;
font-size: 13px;
font-weight: 700;
}
.admin-bulk .button {
font-size: 12px;
padding: 8px 12px;
}
10 changes: 10 additions & 0 deletions app/app/warteliste/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Metadata } from "next";
import { WaitlistPage } from "@/components/waitlist";
export const metadata: Metadata = {
title: "Warteliste",
description:
"Noch kein Goldenes Ticket? Trag dich auf die Warteliste von Humans Only ein.",
};
export default function Page() {
return <WaitlistPage />;
}
13 changes: 9 additions & 4 deletions app/components/clubhouse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ export function Clubhouse() {
Ein Clubhaus für Menschen mit eigenen Gedanken. Dein Goldenes Ticket
macht die Tür auf.
</p>
<Link className="button button-mango" href="/invite">
Mit Ticket eintreten
<ArrowRight size={18} />
</Link>
<div className="welcome-actions">
<Link className="button button-mango" href="/invite">
Mit Ticket eintreten
<ArrowRight size={18} />
</Link>
<Link className="button button-ink" href="/warteliste">
Auf die Warteliste
</Link>
</div>
</section>
);
return (
Expand Down
Loading
Loading