diff --git a/app/c8f2x9/k7m3/page.tsx b/app/c8f2x9/k7m3/page.tsx index e62c5f4..1dc7159 100644 --- a/app/c8f2x9/k7m3/page.tsx +++ b/app/c8f2x9/k7m3/page.tsx @@ -1,718 +1,25 @@ -"use client"; - -import { - Ban, - Bot, - CalendarDays, - CalendarPlus, - Check, - CheckCircle2, - Copy, - Crown, - Loader2, - LogOut, - Search, - ShieldCheck, - Trash2, - UserPlus, - XCircle, -} from "lucide-react"; -import { FormEvent, useCallback, useEffect, useState } from "react"; -import Link from "next/link"; -import { useRouter } from "next/navigation"; -import { readJsonResponse } from "@/lib/http"; -import { consumeSSEStream } from "@/lib/ai/sse"; - -type AdminUser = { uid: string; - display_name: string; - email: string; - last_seen_at: string; - isAdmin: boolean; - entitlement: { - status: string; - plan_id?: string; - source?: string; - expires_at?: string | null; - }; - referral: { - code: string; - status: string; - link: string | null; - } | null; -}; - -const ONE_DAY_MS = 24 * 60 * 60 * 1000; - -/** Derives expiry details from an ISO date string. */ -function getExpiry(expiresAt?: string | null) { - if (!expiresAt) return null; - const target = new Date(expiresAt); - if (Number.isNaN(target.getTime())) return null; - const diffDays = Math.ceil((target.getTime() - Date.now()) / 86400000); - return { target, diffDays, lapsed: diffDays <= 0 }; -} - -/** Formats an expiry date for display. */ -function formatExpiryDate(target: Date) { - return target.toLocaleDateString(undefined, { day: "numeric", month: "short", year: "numeric" }); -} - -/** Renders an expiry badge showing remaining or lapsed pass time. */ -function ExpiryNote({ expiresAt }: { expiresAt?: string | null }) { - const expiry = getExpiry(expiresAt); - if (!expiry) return null; - - const dateLabel = formatExpiryDate(expiry.target); - - if (expiry.lapsed) { - return ( - - - ); - } - - const expiresSoon = expiry.diffDays <= 7; - return ( - - - ); -} - -/** Private admin dashboard for users, passes, and AI testing. */ -export default function AdminDashboardPage() { - const router = useRouter(); - const [users, setUsers] = useState([]); - const [loading, setLoading] = useState(true); - const [search, setSearch] = useState(""); - const [statusMessage, setStatusMessage] = useState(""); - const [actionBusy, setActionBusy] = useState(""); - const [aiPrompt, setAiPrompt] = useState(""); - const [aiOutput, setAiOutput] = useState(""); - const [aiStreaming, setAiStreaming] = useState(false); - const [aiMode, setAiMode] = useState<"quick" | "thorough" | "max">("thorough"); - const [copiedReferralUid, setCopiedReferralUid] = useState(null); - const [customGrant, setCustomGrant] = useState<{ - uid: string; - label: string; - date: string; - min: string; - currentExpiry: string | null; - } | null>(null); - - /** Fetches the admin user registry from the API. */ - const fetchUsers = useCallback(async () => { - try { - const res = await fetch("/api/c8f2x9/users"); - if (res.status === 401) { - router.push("/c8f2x9"); - return; - } - const data = (await readJsonResponse<{ users?: AdminUser[]; error?: string }>(res)) ?? {}; - if (!res.ok) throw new Error(data.error || "Could not load users."); - setUsers(data.users || []); - } catch (error) { - setUsers([]); - setStatusMessage(error instanceof Error ? error.message : "Could not load users."); - } finally { - setLoading(false); - } - }, [router]); - - useEffect(() => { - void fetchUsers(); - }, [fetchUsers]); - - // Re-render the expiry notes on a slow tick so a pass that lapses while this - // tab is open flips to "Expired" without needing a manual refresh. - const [, setExpiryTick] = useState(0); - useEffect(() => { - const timer = window.setInterval(() => { setExpiryTick((value) => value + 1); }, 60_000); - return () => { window.clearInterval(timer); }; - }, []); - - useEffect(() => { - if (!customGrant) return; - - /** Closes the custom pass dialog on Escape. */ - const handleKey = (event: KeyboardEvent) => { - if (event.key === "Escape") setCustomGrant(null); - }; - - window.addEventListener("keydown", handleKey); - return () => { window.removeEventListener("keydown", handleKey); }; - }, [customGrant]); - - /** Approves or revokes administrator access for the given user. */ - async function mutateAdmin(uid: string, action: "approve" | "revoke") { - if (actionBusy) return; - setActionBusy(`${action}:${uid}`); - setStatusMessage(""); - try { - const response = await fetch(`/api/c8f2x9/${action}`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ uid }), - }); - const data = (await readJsonResponse<{ error?: string; message?: string }>(response)) ?? {}; - if (!response.ok) throw new Error(data.error || `Could not ${action} user.`); - setStatusMessage(data.message || `User ${action}d.`); - await fetchUsers(); - } catch (error) { - setStatusMessage(error instanceof Error ? error.message : `Could not ${action} user.`); - } finally { - setActionBusy(""); - } - } - - /** Signs out of the admin session and returns to the login gate. */ - async function handleLogout() { - await fetch("/api/c8f2x9/login", { method: "DELETE" }); - router.push("/c8f2x9"); - } - - /** Grants a weekly or monthly pass to the given user. */ - async function grantSubscription(uid: string, planId: "weekly-pass" | "monthly-pass") { - if (actionBusy) return; - setActionBusy(`grant:${planId}:${uid}`); - setStatusMessage(""); - try { - const response = await fetch("/api/c8f2x9/grant-subscription", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ uid, planId }), - }); - const data = (await readJsonResponse<{ error?: string; message?: string }>(response)) ?? {}; - if (!response.ok) throw new Error(data.error || "Could not grant the subscription."); - setStatusMessage(data.message || "Subscription granted."); - await fetchUsers(); - } catch (error) { - setStatusMessage(error instanceof Error ? error.message : "Could not grant the subscription."); - } finally { - setActionBusy(""); - } - } - - /** Grants a custom pass ending on the dialog's chosen date. */ - async function grantCustomExpiry() { - if (!customGrant || actionBusy) return; - if (!customGrant.date) { - setStatusMessage("Pick an expiry date for the custom pass."); - return; - } - - const uid = customGrant.uid; - setActionBusy(`grant-custom:${uid}`); - setStatusMessage(""); - try { - const response = await fetch("/api/c8f2x9/grant-subscription", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ uid, expiresAt: customGrant.date }), - }); - const data = (await readJsonResponse<{ error?: string; message?: string }>(response)) ?? {}; - if (!response.ok) throw new Error(data.error || "Could not grant the custom pass."); - setStatusMessage(data.message || "Custom pass granted."); - setCustomGrant(null); - await fetchUsers(); - } catch (error) { - setStatusMessage(error instanceof Error ? error.message : "Could not grant the custom pass."); - } finally { - setActionBusy(""); - } - } - - /** Revokes a manually granted subscription after confirmation. */ - async function revokeSubscription(uid: string) { - if (actionBusy) return; - if (!window.confirm("Revoke the manually granted subscription for this user? Paid subscriptions are never affected.")) return; - setActionBusy(`revoke-pass:${uid}`); - setStatusMessage(""); - try { - const response = await fetch("/api/c8f2x9/revoke-subscription", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ uid }), - }); - const data = (await readJsonResponse<{ error?: string; message?: string }>(response)) ?? {}; - if (!response.ok) throw new Error(data.error || "Could not revoke the subscription."); - setStatusMessage(data.message || "Subscription revoked."); - await fetchUsers(); - } catch (error) { - setStatusMessage(error instanceof Error ? error.message : "Could not revoke the subscription."); - } finally { - setActionBusy(""); - } - } - - /** Copies the partner referral link for the given user. */ - async function copyReferralLink(user: AdminUser) { - const link = user.referral?.link; - if (!link) return; - - try { - await navigator.clipboard.writeText(link); - setCopiedReferralUid(user.uid); - window.setTimeout(() => { setCopiedReferralUid((current) => current === user.uid ? null : current); }, 1800); - } catch { - setStatusMessage("Could not copy the referral link. Please open it and copy the URL manually."); - } - } - - /** Runs an internal AI research test from the admin prompt. */ - async function handleAiTest(e: FormEvent) { - e.preventDefault(); - if (!aiPrompt.trim() || aiStreaming) return; - - setAiStreaming(true); - setAiOutput(""); - - const maxTokens = aiMode === "max" ? 8000 : aiMode === "thorough" ? 4000 : 1000; - const temperature = aiMode === "max" ? 1.0 : aiMode === "thorough" ? 0.85 : 0.7; - - try { - const res = await fetch("/api/ai/research", { - method: "POST", - credentials: "include", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - committee: "General", - agenda: aiPrompt.length < 5 ? `${aiPrompt} — respond naturally` : aiPrompt, - country: "Any", - experienceLevel: "intermediate", - provider: "nvidia", - maxTokens, - temperature, - }), - }); - - const contentType = res.headers.get("Content-Type") || ""; - - if (contentType.includes("text/event-stream") && res.body) { - let fullContent = ""; - await consumeSSEStream(res.body, (data) => { - const parsed = data as { content?: string }; - if (parsed.content) { - fullContent += parsed.content; - setAiOutput(fullContent); - } - }); - } else { - const data = (await readJsonResponse<{ error?: string; content?: string }>(res)) ?? {}; - if (!res.ok) throw new Error(data.error || "The AI request failed."); - setAiOutput(data.content || "No response"); - } - } catch (error) { - setAiOutput(error instanceof Error ? error.message : "Request failed."); - } finally { - setAiStreaming(false); - } - } - - const filtered = users.filter( - (u) => - u.email.toLowerCase().includes(search.toLowerCase()) || - u.display_name.toLowerCase().includes(search.toLowerCase()) || - u.uid.toLowerCase().includes(search.toLowerCase()) - ); - - return ( -
-
-
-
-
-
-
-

MUN Prep · private control room

-

Administrator dashboard

-
-
- -
-
- -
-
-
-
- - {statusMessage ? ( -

- {statusMessage} -

- ) : null} - -
-
-
-
-
-
-

Provider check

-

Test the debate assistant

-

Internal testing uses the protected MiniMax M3 route.

-
-
- - Internal only - -
- -
-
- {(["quick", "thorough", "max"] as const).map((m) => ( - - ))} -
- -
- - { setAiPrompt(e.target.value); }} - placeholder="Ask a concise MUN research question..." - className="input-field flex-1" - /> - -
-
- - {aiOutput ? ( -
-
-

Assistant response

- {aiStreaming ? Streaming : null} -
-
- {aiOutput} - {aiStreaming ? : null} -
-
- ) : null} -
- -
-
-
-

Access registry

-
-

Users

- {users.length} -
-

Approve or revoke administrator access deliberately.

-
-
-
-
- - {loading ? ( -
- -
- ) : filtered.length === 0 ? ( -

No users found.

- ) : ( -
- - - - - - - - - - - - - - {filtered.map((user) => ( - - - - - - - - - ))} - -
MUN Prep user access registry
UserUIDStatusReferral linkLast seenActions
-

{user.display_name || "Unnamed"}

-

{user.email}

-
- {user.uid.slice(0, 12)}... - - {user.isAdmin ? ( - - - ) : getExpiry(user.entitlement.expires_at)?.lapsed ? ( - - - ) : user.entitlement.status === "active" ? ( - - - ) : ( - - - )} - {user.entitlement.expires_at && (user.entitlement.status === "active" || getExpiry(user.entitlement.expires_at)?.lapsed) ? ( -
- -
- ) : null} -
- {user.referral?.link ? ( -
- - /login/referral-{user.referral.code} - - -
- ) : ( - - {user.referral?.status ? `Partner ${user.referral.status}` : "Not a partner"} - - )} -
- {user.last_seen_at ? new Date(user.last_seen_at).toLocaleDateString() : "Never"} - -
- {!user.isAdmin ? ( - - ) : null} - {!user.isAdmin ? ( - - ) : null} - {!user.isAdmin ? ( - - ) : null} - {user.entitlement.status === "active" && user.entitlement.source === "admin_manual" ? ( - - ) : null} - {!user.isAdmin ? ( - - ) : ( - - )} -
-
-
- )} -
-
- - {customGrant ? ( -
- - -
-
- - ) : null} - - - ); +import { redirect } from "next/navigation"; +import { AdminDashboard } from "@/components/admin-dashboard"; +import { privateMetadata } from "@/lib/seo"; +import { requireAdmin } from "@/lib/server/admin-auth"; + +export const dynamic = "force-dynamic"; +export const metadata = privateMetadata("Administrator dashboard"); + +/** + * Private administrator dashboard. + * + * Access is decided on the server before any client code is sent: without a + * valid, signed admin session cookie this redirects to the admin login gate. + * The dashboard UI (including the MiroFish-inspired Swarm Lab) is rendered by + * the client component, but it is never reachable without passing this check. + */ +export default async function AdminDashboardPage() { + try { + await requireAdmin(); + } catch { + redirect("/c8f2x9"); + } + + return ; } - diff --git a/app/mirofish/page.tsx b/app/mirofish/page.tsx deleted file mode 100644 index 25ba4cb..0000000 --- a/app/mirofish/page.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { MirofishConsole } from "@/components/mirofish-console"; -import { ProtectedAppShell } from "@/components/protected-app-shell"; -import { privateMetadata } from "@/lib/seo"; - -export const metadata = privateMetadata("Swarm Intelligence Lab"); - -/** Authenticated, five-stage MiroFish-inspired scenario console. */ -export default function MirofishPage() { - return ( - - - - ); -} diff --git a/components/admin-dashboard.tsx b/components/admin-dashboard.tsx new file mode 100644 index 0000000..fffd006 --- /dev/null +++ b/components/admin-dashboard.tsx @@ -0,0 +1,781 @@ +"use client"; + +import { + Ban, + Bot, + CalendarDays, + CalendarPlus, + Check, + CheckCircle2, + Copy, + Crown, + Loader2, + LogOut, + Network, + Search, + ShieldCheck, + Trash2, + UserPlus, + XCircle, +} from "lucide-react"; +import { FormEvent, useCallback, useEffect, useState } from "react"; +import Link from "next/link"; +import { useRouter } from "next/navigation"; +import { MirofishConsole } from "@/components/mirofish-console"; +import { readJsonResponse } from "@/lib/http"; +import { consumeSSEStream } from "@/lib/ai/sse"; +import { cn } from "@/lib/utils"; + +type AdminUser = { uid: string; + display_name: string; + email: string; + last_seen_at: string; + isAdmin: boolean; + entitlement: { + status: string; + plan_id?: string; + source?: string; + expires_at?: string | null; + }; + referral: { + code: string; + status: string; + link: string | null; + } | null; +}; + +const ONE_DAY_MS = 24 * 60 * 60 * 1000; + +/** + * Sections of the private dashboard. "swarm-lab" is the MiroFish-inspired + * scenario simulator; it lives here rather than in the delegate workspace so + * that only server-authenticated administrators can reach it. + */ +type AdminView = "overview" | "swarm-lab"; + +const adminViews: Array<{ id: AdminView; label: string; icon: typeof Network }> = [ + { id: "overview", label: "Overview", icon: Crown }, + { id: "swarm-lab", label: "Swarm Lab", icon: Network }, +]; + +/** Derives expiry details from an ISO date string. */ +function getExpiry(expiresAt?: string | null) { + if (!expiresAt) return null; + const target = new Date(expiresAt); + if (Number.isNaN(target.getTime())) return null; + const diffDays = Math.ceil((target.getTime() - Date.now()) / 86400000); + return { target, diffDays, lapsed: diffDays <= 0 }; +} + +/** Formats an expiry date for display. */ +function formatExpiryDate(target: Date) { + return target.toLocaleDateString(undefined, { day: "numeric", month: "short", year: "numeric" }); +} + +/** Renders an expiry badge showing remaining or lapsed pass time. */ +function ExpiryNote({ expiresAt }: { expiresAt?: string | null }) { + const expiry = getExpiry(expiresAt); + if (!expiry) return null; + + const dateLabel = formatExpiryDate(expiry.target); + + if (expiry.lapsed) { + return ( + + + ); + } + + const expiresSoon = expiry.diffDays <= 7; + return ( + + + ); +} + +/** Private admin dashboard for users, passes, AI testing, and the Swarm Lab. */ +export function AdminDashboard() { + const router = useRouter(); + const [view, setView] = useState("overview"); + const [users, setUsers] = useState([]); + const [loading, setLoading] = useState(true); + const [search, setSearch] = useState(""); + const [statusMessage, setStatusMessage] = useState(""); + const [actionBusy, setActionBusy] = useState(""); + const [aiPrompt, setAiPrompt] = useState(""); + const [aiOutput, setAiOutput] = useState(""); + const [aiStreaming, setAiStreaming] = useState(false); + const [aiMode, setAiMode] = useState<"quick" | "thorough" | "max">("thorough"); + const [copiedReferralUid, setCopiedReferralUid] = useState(null); + const [customGrant, setCustomGrant] = useState<{ + uid: string; + label: string; + date: string; + min: string; + currentExpiry: string | null; + } | null>(null); + + /** Fetches the admin user registry from the API. */ + const fetchUsers = useCallback(async () => { + try { + const res = await fetch("/api/c8f2x9/users"); + if (res.status === 401) { + router.push("/c8f2x9"); + return; + } + const data = (await readJsonResponse<{ users?: AdminUser[]; error?: string }>(res)) ?? {}; + if (!res.ok) throw new Error(data.error || "Could not load users."); + setUsers(data.users || []); + } catch (error) { + setUsers([]); + setStatusMessage(error instanceof Error ? error.message : "Could not load users."); + } finally { + setLoading(false); + } + }, [router]); + + useEffect(() => { + void fetchUsers(); + }, [fetchUsers]); + + // Re-render the expiry notes on a slow tick so a pass that lapses while this + // tab is open flips to "Expired" without needing a manual refresh. + const [, setExpiryTick] = useState(0); + useEffect(() => { + const timer = window.setInterval(() => { setExpiryTick((value) => value + 1); }, 60_000); + return () => { window.clearInterval(timer); }; + }, []); + + useEffect(() => { + if (!customGrant) return; + + /** Closes the custom pass dialog on Escape. */ + const handleKey = (event: KeyboardEvent) => { + if (event.key === "Escape") setCustomGrant(null); + }; + + window.addEventListener("keydown", handleKey); + return () => { window.removeEventListener("keydown", handleKey); }; + }, [customGrant]); + + /** Approves or revokes administrator access for the given user. */ + async function mutateAdmin(uid: string, action: "approve" | "revoke") { + if (actionBusy) return; + setActionBusy(`${action}:${uid}`); + setStatusMessage(""); + try { + const response = await fetch(`/api/c8f2x9/${action}`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ uid }), + }); + const data = (await readJsonResponse<{ error?: string; message?: string }>(response)) ?? {}; + if (!response.ok) throw new Error(data.error || `Could not ${action} user.`); + setStatusMessage(data.message || `User ${action}d.`); + await fetchUsers(); + } catch (error) { + setStatusMessage(error instanceof Error ? error.message : `Could not ${action} user.`); + } finally { + setActionBusy(""); + } + } + + /** Signs out of the admin session and returns to the login gate. */ + async function handleLogout() { + await fetch("/api/c8f2x9/login", { method: "DELETE" }); + router.push("/c8f2x9"); + } + + /** Grants a weekly or monthly pass to the given user. */ + async function grantSubscription(uid: string, planId: "weekly-pass" | "monthly-pass") { + if (actionBusy) return; + setActionBusy(`grant:${planId}:${uid}`); + setStatusMessage(""); + try { + const response = await fetch("/api/c8f2x9/grant-subscription", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ uid, planId }), + }); + const data = (await readJsonResponse<{ error?: string; message?: string }>(response)) ?? {}; + if (!response.ok) throw new Error(data.error || "Could not grant the subscription."); + setStatusMessage(data.message || "Subscription granted."); + await fetchUsers(); + } catch (error) { + setStatusMessage(error instanceof Error ? error.message : "Could not grant the subscription."); + } finally { + setActionBusy(""); + } + } + + /** Grants a custom pass ending on the dialog's chosen date. */ + async function grantCustomExpiry() { + if (!customGrant || actionBusy) return; + if (!customGrant.date) { + setStatusMessage("Pick an expiry date for the custom pass."); + return; + } + + const uid = customGrant.uid; + setActionBusy(`grant-custom:${uid}`); + setStatusMessage(""); + try { + const response = await fetch("/api/c8f2x9/grant-subscription", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ uid, expiresAt: customGrant.date }), + }); + const data = (await readJsonResponse<{ error?: string; message?: string }>(response)) ?? {}; + if (!response.ok) throw new Error(data.error || "Could not grant the custom pass."); + setStatusMessage(data.message || "Custom pass granted."); + setCustomGrant(null); + await fetchUsers(); + } catch (error) { + setStatusMessage(error instanceof Error ? error.message : "Could not grant the custom pass."); + } finally { + setActionBusy(""); + } + } + + /** Revokes a manually granted subscription after confirmation. */ + async function revokeSubscription(uid: string) { + if (actionBusy) return; + if (!window.confirm("Revoke the manually granted subscription for this user? Paid subscriptions are never affected.")) return; + setActionBusy(`revoke-pass:${uid}`); + setStatusMessage(""); + try { + const response = await fetch("/api/c8f2x9/revoke-subscription", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ uid }), + }); + const data = (await readJsonResponse<{ error?: string; message?: string }>(response)) ?? {}; + if (!response.ok) throw new Error(data.error || "Could not revoke the subscription."); + setStatusMessage(data.message || "Subscription revoked."); + await fetchUsers(); + } catch (error) { + setStatusMessage(error instanceof Error ? error.message : "Could not revoke the subscription."); + } finally { + setActionBusy(""); + } + } + + /** Copies the partner referral link for the given user. */ + async function copyReferralLink(user: AdminUser) { + const link = user.referral?.link; + if (!link) return; + + try { + await navigator.clipboard.writeText(link); + setCopiedReferralUid(user.uid); + window.setTimeout(() => { setCopiedReferralUid((current) => current === user.uid ? null : current); }, 1800); + } catch { + setStatusMessage("Could not copy the referral link. Please open it and copy the URL manually."); + } + } + + /** Runs an internal AI research test from the admin prompt. */ + async function handleAiTest(e: FormEvent) { + e.preventDefault(); + if (!aiPrompt.trim() || aiStreaming) return; + + setAiStreaming(true); + setAiOutput(""); + + const maxTokens = aiMode === "max" ? 8000 : aiMode === "thorough" ? 4000 : 1000; + const temperature = aiMode === "max" ? 1.0 : aiMode === "thorough" ? 0.85 : 0.7; + + try { + const res = await fetch("/api/ai/research", { + method: "POST", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + committee: "General", + agenda: aiPrompt.length < 5 ? `${aiPrompt} — respond naturally` : aiPrompt, + country: "Any", + experienceLevel: "intermediate", + provider: "nvidia", + maxTokens, + temperature, + }), + }); + + const contentType = res.headers.get("Content-Type") || ""; + + if (contentType.includes("text/event-stream") && res.body) { + let fullContent = ""; + await consumeSSEStream(res.body, (data) => { + const parsed = data as { content?: string }; + if (parsed.content) { + fullContent += parsed.content; + setAiOutput(fullContent); + } + }); + } else { + const data = (await readJsonResponse<{ error?: string; content?: string }>(res)) ?? {}; + if (!res.ok) throw new Error(data.error || "The AI request failed."); + setAiOutput(data.content || "No response"); + } + } catch (error) { + setAiOutput(error instanceof Error ? error.message : "Request failed."); + } finally { + setAiStreaming(false); + } + } + + const filtered = users.filter( + (u) => + u.email.toLowerCase().includes(search.toLowerCase()) || + u.display_name.toLowerCase().includes(search.toLowerCase()) || + u.uid.toLowerCase().includes(search.toLowerCase()) + ); + + return ( +
+
+
+
+
+
+
+

MUN Prep · private control room

+

Administrator dashboard

+
+
+ +
+
+
+
+ {adminViews.map((item) => { + const Icon = item.icon; + const active = view === item.id; + + return ( + + ); + })} +
+
+
+
+ +
+ +
+ ) : null} + + + + + + ); +} + diff --git a/components/mirofish-console.tsx b/components/mirofish-console.tsx index 6ded444..0c967b2 100644 --- a/components/mirofish-console.tsx +++ b/components/mirofish-console.tsx @@ -440,8 +440,18 @@ function getSurveyBarColor(stance: string) { return stanceColors[stance] || "#8ad1bd"; } +type MirofishConsoleProps = { + /** + * Render inside a normal document-flow page (the administrator dashboard) + * instead of the workspace shell's fixed-height flex column, which owns its + * own scroll container. Embedded mode drops the inner scroll box so the page + * scrolls as one document. + */ + embedded?: boolean; +}; + /** Five-stage, browser-local MiroFish-inspired simulation console. */ -export function MirofishConsole() { +export function MirofishConsole({ embedded = false }: MirofishConsoleProps = {}) { const [activeStep, setActiveStep] = useState(0); const [highestStep, setHighestStep] = useState(0); const [graphSearch, setGraphSearch] = useState(""); @@ -966,8 +976,14 @@ export function MirofishConsole() { } return ( -
-
+
+
-
{renderActiveStage()}
+ {/* A plain container, not
: the console is embedded inside the + administrator dashboard's own
landmark. */} +
{renderActiveStage()}