diff --git a/app/admin/tracker/[github]/page.tsx b/app/admin/tracker/[github]/page.tsx index a6cd704..7b58b43 100644 --- a/app/admin/tracker/[github]/page.tsx +++ b/app/admin/tracker/[github]/page.tsx @@ -1,14 +1,7 @@ -import { notFound, redirect } from "next/navigation"; -import Link from "next/link"; -import { ChevronRight, ExternalLink } from "lucide-react"; -import { Avatar } from "@/components/ui/avatar"; -import { PRStateBadge } from "@/components/ui/badge"; -import { StatusBadge } from "@/components/tracker/status-badge"; -import { SyncButton } from "@/components/tracker/sync-button"; +import { redirect } from "next/navigation"; import { getMember, getSession } from "@/lib/session"; import { can } from "@/lib/permissions"; -import { loadStudent } from "@/lib/tracker/store"; -import { ageLabel, formatDate } from "@/lib/tracker/format"; +import { StudentView } from "@/components/tracker/student-view"; export const dynamic = "force-dynamic"; @@ -17,15 +10,6 @@ export async function generateMetadata({ params }: { params: Promise<{ github: s return { title: `${decodeURIComponent(github)} · Student tracker` }; } -function Stat({ label, value, hint }: { label: string; value: string | number; hint?: string }) { - return ( -
-
{value}
-
{label}
-
- ); -} - export default async function StudentTrackerPage({ params }: { params: Promise<{ github: string }> }) { const { github } = await params; const session = await getSession(); @@ -33,113 +17,5 @@ export default async function StudentTrackerPage({ params }: { params: Promise<{ const me = await getMember(session.usn); if (!me || me.status !== "approved" || !can(me, "tracker:view")) redirect("/dashboard"); - const s = await loadStudent(decodeURIComponent(github)); - if (!s) notFound(); - const now = new Date(); - const t = s.totals; - const pct = (n: number | null) => (n === null ? "—" : `${n}%`); - - return ( -
-
- - -
- -
-

{s.name}

- - @{s.github} - -
- -
- -
- - {s.syncedAt ? `PR numbers refreshed ${ageLabel(s.syncedAt, now)}` : `PR numbers from the ${formatDate(s.snapshotDate)} sheet; not yet refreshed from GitHub`} - - - {s.syncError && Last sync failed: {s.syncError}. Showing the previous numbers.} -
- -
- - - - - - - - -
- -
-

What needs doing

-
-
Blocker
{s.blocker ?? "None recorded"}
-
Waiting
{s.waitingDays !== null ? `${s.waitingDays} days on the primary PR` : "—"}
-
Last PR opened
{formatDate(s.lastStudentActivity)}{s.daysSinceActivity !== null && ` (${s.daysSinceActivity}d ago)`}
-
Last maintainer response
{s.daysSinceMaintainer !== null ? `${s.daysSinceMaintainer}d ago` : "None on record"}
-
Suggested next step
{s.recommendation ?? "—"}
- {s.suggestedMessage &&
Draft message (edit before sending)
{s.suggestedMessage}
} -
-

These suggestions come from the mentorship sheet and may be out of date after a sync.

-
- -
-

Change since 31 Oct

-

- {s.progress.summary || "No change recorded."} (PRs {s.progress.prevTotal} → {t.total}, merged {s.progress.prevMerged} → {t.merged} - {s.progress.gradeChange && `, grade ${s.progress.gradeChange}`}) -

-
- -
-

Pull requests ({s.prs.length})

- {s.prs.length === 0 ? ( -

No public pull requests on record.

- ) : ( - - )} -
- -
-

Appreciation ({s.appreciation.length})

- {s.appreciation.length === 0 ? ( -

No maintainer appreciation found yet.

- ) : ( -
    - {s.appreciation.map((a, i) => ( -
  • -

    “{a.comment}”

    -

    - {a.reviewer} · {formatDate(a.date)} · {a.repo}#{a.prNumber ?? ""} -

    -
  • - ))} -
- )} -
-
-
- ); + return ; } diff --git a/app/admin/tracker/page.tsx b/app/admin/tracker/page.tsx index ef70579..2862828 100644 --- a/app/admin/tracker/page.tsx +++ b/app/admin/tracker/page.tsx @@ -1,14 +1,7 @@ import { redirect } from "next/navigation"; -import Link from "next/link"; -import { ChevronRight } from "lucide-react"; import { getMember, getSession } from "@/lib/session"; import { can } from "@/lib/permissions"; -import { loadStudents } from "@/lib/tracker/store"; -import { toRow } from "@/lib/tracker/rows"; -import { summarize } from "@/lib/tracker/summary"; -import { ageLabel, formatDate } from "@/lib/tracker/format"; -import { TrackerDashboard, type FeedItem } from "@/components/tracker/tracker-dashboard"; -import { SyncButton } from "@/components/tracker/sync-button"; +import { TrackerOverview } from "@/components/tracker/tracker-overview"; export const metadata = { title: "Open Source Student Tracker" }; // Reads Firestore per request so a sync shows up on the next refresh; GitHub is never called from here. @@ -20,54 +13,5 @@ export default async function TrackerPage() { const me = await getMember(session.usn); if (!me || me.status !== "approved" || !can(me, "tracker:view")) redirect("/dashboard"); - const students = await loadStudents(); - const now = new Date(); - - if (students.length === 0) { - return ( -
-

Open Source Student Tracker

-

- No first-year data has been imported yet. Run npm run import:tracker -- <export.txt> --commit to load the mentorship workbook. -

-
- ); - } - - const summary = summarize(students); - const snapshotDate = students.reduce((latest, s) => (s.snapshotDate > latest ? s.snapshotDate : latest), ""); - const synced = students.filter((s) => s.syncedAt).map((s) => s.syncedAt as string).sort(); - const failing = students.filter((s) => s.syncError).length; - - const feed: FeedItem[] = students - .flatMap((s) => s.appreciation.map((a) => ({ github: s.github, name: s.name, reviewer: a.reviewer, comment: a.comment.slice(0, 220), date: a.date, repo: a.repo, url: a.url }))) - .sort((a, b) => (b.date ?? "").localeCompare(a.date ?? "")) - .slice(0, 8); - - return ( -
-
- - -
-

Open Source Student Tracker

-

- First-year progress in open source. Numbers describe public GitHub activity only, so a quiet student may be working privately. -

-

- Imported snapshot {formatDate(snapshotDate)} · {synced.length}/{students.length} students refreshed from GitHub - {synced.length > 0 && ` · latest ${ageLabel(synced[synced.length - 1], now)}`} - {failing > 0 && ` · ${failing} failed their last sync`} -

- -
- - -
-
- ); + return ; } diff --git a/app/api/admin/tracker/records/route.ts b/app/api/admin/tracker/records/route.ts new file mode 100644 index 0000000..4261d42 --- /dev/null +++ b/app/api/admin/tracker/records/route.ts @@ -0,0 +1,82 @@ +import { NextResponse, type NextRequest } from "next/server"; +import { z } from "zod"; +import { authErrorResponse, requireCapability } from "@/lib/session"; +import { checkRateLimit, RATE_LIMITS } from "@/lib/rate-limit"; +import { createRecord, deleteRecord, loadRecords, updateRecord, type Author } from "@/lib/tracker/records-store"; + +export const runtime = "nodejs"; + +async function actor() { + const { session, member } = await requireCapability("tracker:view"); + const author: Author = { usn: session.usn, name: member.name, isAdmin: member.role === "admin" }; + return { session, author }; +} + +const fail = (status: number, message: string) => NextResponse.json({ ok: false, message }, { status }); + +/** GET ?github= → that student's mentor records. Mentors and admins only. */ +export async function GET(request: NextRequest) { + try { + await actor(); + } catch (error) { + return authErrorResponse(error); + } + const github = request.nextUrl.searchParams.get("github")?.trim(); + if (!github) return fail(400, "github is required."); + return NextResponse.json({ ok: true, records: await loadRecords(github) }); +} + +async function limited(usn: string) { + const r = await checkRateLimit("tracker-records", usn, RATE_LIMITS.write); + return r.ok ? null : NextResponse.json({ ok: false, message: `Slow down: try again in ${r.retryAfterSeconds}s.` }, { status: 429, headers: { "Retry-After": String(r.retryAfterSeconds) } }); +} + +export async function POST(request: NextRequest) { + let a; + try { + a = await actor(); + } catch (error) { + return authErrorResponse(error); + } + const blocked = await limited(a.session.usn); + if (blocked) return blocked; + + const result = await createRecord(await request.json().catch(() => null), a.author); + return result.ok ? NextResponse.json({ ok: true, record: result.record }, { status: 201 }) : fail(result.status, result.message); +} + +const IdBody = z.object({ id: z.string().trim().min(1).max(100) }); + +/** PUT { id, ...record } replaces a record's content; type and student stay fixed. */ +export async function PUT(request: NextRequest) { + let a; + try { + a = await actor(); + } catch (error) { + return authErrorResponse(error); + } + const blocked = await limited(a.session.usn); + if (blocked) return blocked; + + const body = await request.json().catch(() => null); + const id = IdBody.safeParse(body); + if (!id.success) return fail(400, "id is required."); + const result = await updateRecord(id.data.id, body, a.author); + return result.ok ? NextResponse.json({ ok: true, record: result.record }) : fail(result.status, result.message); +} + +export async function DELETE(request: NextRequest) { + let a; + try { + a = await actor(); + } catch (error) { + return authErrorResponse(error); + } + const blocked = await limited(a.session.usn); + if (blocked) return blocked; + + const id = IdBody.safeParse({ id: request.nextUrl.searchParams.get("id") }); + if (!id.success) return fail(400, "id is required."); + const result = await deleteRecord(id.data.id, a.author); + return result.ok ? NextResponse.json({ ok: true }) : fail(result.status, result.message); +} diff --git a/app/api/dev/tracker/records/route.ts b/app/api/dev/tracker/records/route.ts new file mode 100644 index 0000000..81571ef --- /dev/null +++ b/app/api/dev/tracker/records/route.ts @@ -0,0 +1,34 @@ +import { NextResponse, type NextRequest } from "next/server"; +import { demoEnabled } from "@/lib/tracker/demo"; +import { createRecord, deleteRecord, updateRecord, type Author } from "@/lib/tracker/records-store"; + +export const runtime = "nodejs"; + +/** + * Same record logic as /api/admin/tracker/records, but on the in-memory demo + * data and with no sign-in. Exists only for `next dev` with TRACKER_DEMO=1 and + * answers 404 otherwise, so it cannot be reached in production. + */ +const author: Author = { usn: "demo", name: "Demo Mentor", isAdmin: true }; +const gone = () => new NextResponse(null, { status: 404 }); +const out = (r: { ok: boolean; status?: number; message?: string; record?: unknown }, okStatus = 200) => + r.ok ? NextResponse.json({ ok: true, record: r.record }, { status: okStatus }) : NextResponse.json({ ok: false, message: r.message }, { status: r.status }); + +export async function POST(request: NextRequest) { + if (!demoEnabled()) return gone(); + return out(await createRecord(await request.json().catch(() => null), author), 201); +} + +export async function PUT(request: NextRequest) { + if (!demoEnabled()) return gone(); + const body = (await request.json().catch(() => null)) as { id?: string } | null; + if (!body?.id) return NextResponse.json({ ok: false, message: "id is required." }, { status: 400 }); + return out(await updateRecord(body.id, body, author)); +} + +export async function DELETE(request: NextRequest) { + if (!demoEnabled()) return gone(); + const id = request.nextUrl.searchParams.get("id"); + if (!id) return NextResponse.json({ ok: false, message: "id is required." }, { status: 400 }); + return out(await deleteRecord(id, author)); +} diff --git a/app/dev/tracker/[github]/page.tsx b/app/dev/tracker/[github]/page.tsx new file mode 100644 index 0000000..44677bb --- /dev/null +++ b/app/dev/tracker/[github]/page.tsx @@ -0,0 +1,11 @@ +import { notFound } from "next/navigation"; +import { demoEnabled } from "@/lib/tracker/demo"; +import { StudentView } from "@/components/tracker/student-view"; + +export const dynamic = "force-dynamic"; + +export default async function DemoStudentPage({ params }: { params: Promise<{ github: string }> }) { + if (!demoEnabled()) notFound(); + const { github } = await params; + return ; +} diff --git a/app/dev/tracker/page.tsx b/app/dev/tracker/page.tsx new file mode 100644 index 0000000..40359bf --- /dev/null +++ b/app/dev/tracker/page.tsx @@ -0,0 +1,12 @@ +import { notFound } from "next/navigation"; +import { demoEnabled } from "@/lib/tracker/demo"; +import { TrackerOverview } from "@/components/tracker/tracker-overview"; + +export const metadata = { title: "Student tracker (demo)" }; +export const dynamic = "force-dynamic"; + +/** Development preview on made-up data. 404s everywhere except `next dev` with TRACKER_DEMO=1. */ +export default function DemoTrackerPage() { + if (!demoEnabled()) notFound(); + return ; +} diff --git a/components/dashboard/dashboard-nav.tsx b/components/dashboard/dashboard-nav.tsx index 271eb08..f232cf1 100644 --- a/components/dashboard/dashboard-nav.tsx +++ b/components/dashboard/dashboard-nav.tsx @@ -13,6 +13,7 @@ import { Trophy, ShieldCheck, ClipboardCheck, + Activity, Menu, X, } from "lucide-react"; @@ -32,13 +33,13 @@ interface NavLink { const LINKS: NavLink[] = [ { name: "Overview", href: "/dashboard", icon: }, + { name: "Student tracker", href: "/admin/tracker", icon: , tracker: true }, { name: "Projects", href: "/dashboard/projects", icon: }, { name: "Explore", href: "/dashboard/explore", icon: }, { name: "Sessions", href: "/dashboard/events", icon: }, { name: "Members", href: "/dashboard/members", icon: }, { name: "Leaderboard", href: "/dashboard/leaderboard", icon: }, { name: "Sign-offs", href: "/dashboard/journey", icon: , reviewer: true }, - { name: "Tracker", href: "/admin/tracker", icon: , tracker: true }, { name: "Admin", href: "/admin", icon: , elevated: true }, ]; diff --git a/components/tracker/records-panel.tsx b/components/tracker/records-panel.tsx new file mode 100644 index 0000000..e129543 --- /dev/null +++ b/components/tracker/records-panel.tsx @@ -0,0 +1,301 @@ +"use client"; + +import { useState, type FormEvent } from "react"; +import { useRouter } from "next/navigation"; +import { CalendarClock, CheckCircle2, Pencil, Plus, Trash2, TriangleAlert, X } from "lucide-react"; +import { formatDate } from "@/lib/tracker/format"; +import { + BADGES, BADGE_LABELS, CONTEXT_LABELS, CONTEXT_TYPES, DIFFICULTIES, NOTE_TYPES, NOTE_TYPE_LABELS, TASK_STATUSES, TASK_STATUS_LABELS, + type TrackerRecord, +} from "@/lib/tracker/records"; +import type { WeeklySummary } from "@/lib/tracker/weekly"; + +type Kind = TrackerRecord["kind"]; +type Values = Record; + +interface Field { + name: string; + label: string; + type: "text" | "textarea" | "date" | "number" | "select"; + required?: boolean; + options?: readonly (readonly [string, string])[]; + hint?: string; +} + +const opts = (values: readonly T[], labels?: Record) => values.map((v) => [v, labels?.[v] ?? v] as const); + +const FIELDS: Record = { + task: [ + { name: "title", label: "Task or issue title", type: "text", required: true }, + { name: "repo", label: "Repository (owner/name)", type: "text" }, + { name: "issueNumber", label: "Issue number", type: "number" }, + { name: "issueUrl", label: "Issue link", type: "text", hint: "Must start with https://" }, + { name: "description", label: "Description", type: "textarea" }, + { name: "difficulty", label: "Difficulty", type: "select", required: true, options: opts(DIFFICULTIES, { easy: "Easy", medium: "Medium", hard: "Hard" }) }, + { name: "status", label: "Status", type: "select", required: true, options: opts(TASK_STATUSES, TASK_STATUS_LABELS) }, + { name: "assignedAt", label: "Assigned on", type: "date", required: true }, + { name: "dueDate", label: "Expected by", type: "date" }, + { name: "blockers", label: "Blockers", type: "textarea" }, + { name: "nextAction", label: "Next action", type: "text" }, + ], + note: [ + { name: "noteType", label: "Type of note", type: "select", required: true, options: opts(NOTE_TYPES, NOTE_TYPE_LABELS) }, + { name: "text", label: "Note", type: "textarea", required: true }, + { name: "visibility", label: "Who can see it", type: "select", required: true, options: [["mentors", "Mentors only"], ["student", "Mentors and the student"]], hint: "The student view is not built yet, so nothing is shown to students today." }, + ], + appreciation: [ + { name: "title", label: "Title", type: "text", required: true }, + { name: "reason", label: "Why they deserve it", type: "textarea", required: true }, + { name: "badge", label: "Badge", type: "select", required: true, options: opts(BADGES, BADGE_LABELS) }, + { name: "sourceUrl", label: "Link to the work", type: "text" }, + { name: "date", label: "Date", type: "date", required: true }, + ], + review: [ + { name: "weekStart", label: "Week starting (Monday)", type: "date", required: true }, + { name: "completed", label: "Completed this week", type: "textarea" }, + { name: "inProgress", label: "In progress", type: "textarea" }, + { name: "learned", label: "What was learned", type: "textarea" }, + { name: "difficult", label: "What was difficult", type: "textarea" }, + { name: "helpNeeded", label: "Help needed", type: "textarea" }, + { name: "nextWeek", label: "Plan for next week", type: "textarea" }, + { name: "blockers", label: "Blockers", type: "textarea" }, + { name: "confidence", label: "Confidence", type: "select", required: true, options: [["1", "1 – lost"], ["2", "2 – unsure"], ["3", "3 – okay"], ["4", "4 – good"], ["5", "5 – very confident"]] }, + { name: "hours", label: "Hours or sessions", type: "number" }, + { name: "mentorFeedback", label: "Mentor feedback", type: "textarea" }, + ], + context: [ + { name: "contextType", label: "What happened", type: "select", required: true, options: opts(CONTEXT_TYPES, CONTEXT_LABELS), hint: "These days are left out of the consistency score." }, + { name: "startDate", label: "From", type: "date", required: true }, + { name: "endDate", label: "To", type: "date", required: true }, + { name: "text", label: "Detail (optional)", type: "textarea" }, + ], +}; + +const KIND_LABELS: Record = { task: "Task", note: "Note", appreciation: "Appreciation", review: "Weekly review", context: "Leave / context" }; +const NUMERIC = new Set(["issueNumber", "confidence", "hours"]); +const NULLABLE = new Set(["issueNumber", "hours", "dueDate"]); + +export function defaults(kind: Kind, today: string, monday: string): Values { + switch (kind) { + case "task": return { difficulty: "medium", status: "planned", assignedAt: today }; + case "note": return { noteType: "learned", visibility: "mentors" }; + case "appreciation": return { badge: "general", date: today }; + case "review": return { weekStart: monday, confidence: "3" }; + case "context": return { contextType: "approved-leave", startDate: today, endDate: today }; + } +} + +/** Form strings → the JSON the API validates. Blank optional numbers and dates become null. */ +export function toPayload(kind: Kind, github: string, values: Values): Record { + const out: Record = { github, kind }; + for (const f of FIELDS[kind]) { + const raw = (values[f.name] ?? "").trim(); + if (raw === "" && NULLABLE.has(f.name)) out[f.name] = null; + else if (NUMERIC.has(f.name)) out[f.name] = raw === "" ? undefined : Number(raw); + else out[f.name] = raw; + } + return out; +} + +const fromRecord = (r: TrackerRecord): Values => + Object.fromEntries(FIELDS[r.kind].map((f) => [f.name, String((r as unknown as Record)[f.name] ?? "")])); + +function summary(r: TrackerRecord): { title: string; sub: string; date: string } { + switch (r.kind) { + case "task": return { title: r.title, sub: `${TASK_STATUS_LABELS[r.status]} · ${r.difficulty}${r.dueDate ? ` · due ${formatDate(r.dueDate)}` : ""}${r.blockers ? ` · blocked: ${r.blockers}` : ""}`, date: r.assignedAt }; + case "note": return { title: NOTE_TYPE_LABELS[r.noteType], sub: r.text, date: r.createdAt.slice(0, 10) }; + case "appreciation": return { title: `${BADGE_LABELS[r.badge]}: ${r.title}`, sub: r.reason, date: r.date }; + case "review": return { title: `Week of ${formatDate(r.weekStart)} (confidence ${r.confidence}/5)`, sub: [r.completed && `Done: ${r.completed}`, r.blockers && `Blockers: ${r.blockers}`, r.helpNeeded && `Needs: ${r.helpNeeded}`].filter(Boolean).join(" · ") || "No details", date: r.weekStart }; + case "context": return { title: CONTEXT_LABELS[r.contextType], sub: r.text || `${formatDate(r.startDate)} to ${formatDate(r.endDate)}`, date: r.startDate }; + } +} + +interface Props { + github: string; + /** Records API; defaults to the real, signed-in one. */ + endpoint?: string; + records: TrackerRecord[]; + today: string; + monday: string; + weekly: WeeklySummary; + currentTask: Extract | null; + counts: { open: number; overdue: number; blocked: number }; +} + +const input = "mt-1 w-full bg-neutral-900 border border-white/10 rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-cyan-400/60"; + +function List({ title, items }: { title: string; items: string[] }) { + return ( +
+
{title}
+
{items.length === 0 ? None :
    {items.slice(0, 5).map((i) =>
  • {i}
  • )}{items.length > 5 &&
  • and {items.length - 5} more
  • }
}
+
+ ); +} + +export function RecordsPanel({ github, endpoint = "/api/admin/tracker/records", records, today, monday, weekly, currentTask, counts }: Props) { + const router = useRouter(); + const [kind, setKind] = useState("task"); + const [values, setValues] = useState(defaults("task", today, monday)); + const [editing, setEditing] = useState(null); + const [open, setOpen] = useState(false); + const [busy, setBusy] = useState(false); + const [confirming, setConfirming] = useState(null); + const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null); + + function start(k: Kind, record?: TrackerRecord) { + setKind(k); + setValues(record ? fromRecord(record) : defaults(k, today, monday)); + setEditing(record?.id ?? null); + setOpen(true); + setMessage(null); + } + + async function call(method: string, url: string, body?: unknown): Promise<{ ok: boolean; message?: string }> { + try { + const res = await fetch(url, { method, headers: body ? { "Content-Type": "application/json" } : undefined, body: body ? JSON.stringify(body) : undefined }); + return await res.json().catch(() => ({ ok: false, message: `Request failed (${res.status}).` })); + } catch { + return { ok: false, message: "Could not reach the server. Check your connection and try again." }; + } + } + + async function submit(e: FormEvent) { + e.preventDefault(); + setBusy(true); + const payload = toPayload(kind, github, values); + const res = await call(editing ? "PUT" : "POST", endpoint, editing ? { ...payload, id: editing } : payload); + setBusy(false); + if (res.ok) { + setMessage({ ok: true, text: editing ? "Saved." : "Added." }); + setOpen(false); + setEditing(null); + router.refresh(); + } else setMessage({ ok: false, text: res.message ?? "Something went wrong." }); + } + + async function remove(id: string) { + setBusy(true); + const res = await call("DELETE", `${endpoint}?id=${encodeURIComponent(id)}`); + setBusy(false); + setConfirming(null); + setMessage(res.ok ? { ok: true, text: "Deleted." } : { ok: false, text: res.message ?? "Could not delete." }); + if (res.ok) router.refresh(); + } + + return ( +
+
+

Current work

+ {currentTask ? ( + <> +

{currentTask.title}

+
+
Repository
{currentTask.repo || "—"}{currentTask.issueNumber ? ` #${currentTask.issueNumber}` : ""}
+
Status
{TASK_STATUS_LABELS[currentTask.status]} · {currentTask.difficulty}
+
Assigned / expected
{formatDate(currentTask.assignedAt)} / {formatDate(currentTask.dueDate)}
+
Next action
{currentTask.nextAction || "—"}
+
Blockers
{currentTask.blockers || "None recorded"}
+ {currentTask.description &&
Description
{currentTask.description}
} +
+

{counts.open} open task{counts.open === 1 ? "" : "s"}{counts.overdue > 0 && ` · ${counts.overdue} overdue`}{counts.blocked > 0 && ` · ${counts.blocked} blocked`}

+ + ) : ( +

No open task recorded. Add one below so mentors can see what this student is working on.

+ )} +
+ +
+

Week of {formatDate(weekly.week.start)}

+
+ + + + + +
+
Progress and consistency
+
{weekly.progress.explanation}{weekly.consistencyChange !== null && ` Consistency ${weekly.consistencyChange >= 0 ? "up" : "down"} ${Math.abs(weekly.consistencyChange)} points over four weeks.`}
+
+
+
+
+ +
+
+

Mentor records ({records.length})

+ {(Object.keys(KIND_LABELS) as Kind[]).map((k) => ( + + ))} +
+ +
+ {message && ( +

+ {message.ok ? : }{message.text} +

+ )} +
+ + {open && ( +
+
+

{editing ? "Edit" : "Add"}: {KIND_LABELS[kind]}

+ +
+
+ {FIELDS[kind].map((f) => { + const common = { id: `f-${f.name}`, name: f.name, required: f.required, value: values[f.name] ?? "", className: input, onChange: (e: React.ChangeEvent) => setValues((v) => ({ ...v, [f.name]: e.target.value })) }; + return ( +
+ + {f.type === "textarea" ?