From 4acc297709510bd4933aaa1c506f8ed90106c336 Mon Sep 17 00:00:00 2001 From: gunshiz Date: Sun, 2 Aug 2026 17:12:12 +0700 Subject: [PATCH] feat(admin): reshape overview into operations dashboard --- app/admin/page.tsx | 426 +++++++++++++++++++++------------------------ 1 file changed, 203 insertions(+), 223 deletions(-) diff --git a/app/admin/page.tsx b/app/admin/page.tsx index db5cd5e..ca432ae 100644 --- a/app/admin/page.tsx +++ b/app/admin/page.tsx @@ -5,11 +5,13 @@ import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, + CardAction, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; +import { Progress } from "@/components/ui/progress"; import { Table, TableBody, @@ -20,11 +22,11 @@ import { } from "@/components/ui/table"; import { getAdminDashboardData } from "@/lib/admin/admin-dashboard"; import { + ArrowUpRight, ClipboardList, FilePlus2, - Inbox, - ListChecks, Server, + Upload, } from "lucide-react"; import Link from "next/link"; @@ -49,29 +51,57 @@ function respondentName(submission: { return submission.userName || submission.userDiscordId || "Anonymous"; } -function StatCard({ - title, +function MetricCard({ + label, value, + detail, +}: { + label: string; + value: number; + detail: string; +}) { + return ( + + + {label} + + {formatNumber(value)} + + + + {detail} + + + ); +} + +function QuickAction({ + href, + title, description, icon: Icon, }: { + href: string; title: string; - value: number; description: string; icon: typeof ClipboardList; }) { return ( - - -
- {title} - {formatNumber(value)} -
- + + + + + {title} + + {description} + + + - -

{description}

-
); } @@ -79,17 +109,22 @@ function StatCard({ export default async function AdminPage() { const { summary, recentSubmissions, activeForms } = await getAdminDashboardData(); + const busiestFormResponses = Math.max( + ...activeForms.map((form) => form.responsesLast7Days), + 1, + ); return ( -
-
+
+
+

Command center

Dashboard

- Forms, responses, and activity at a glance. + Live form operations · Bangkok time

@@ -98,55 +133,77 @@ export default async function AdminPage() { Create form
-
+ -
- - - - -
- -
+
-
-
- Recent responses - - Latest submissions across all forms. - -
+ Responses today + + {formatNumber(summary.responsesToday)} + + + Live + + + +

+ Submissions received since midnight. Realtime updates keep this + workspace current while you are here. +

+
+ + {formatNumber(summary.responsesLast7Days)} this week + + + {formatNumber(summary.openForms)} forms accepting responses + +
+
+ + +
+ + + + +
+
+ +
+ + + Recent responses + + The latest submissions across every form. + + -
+ {recentSubmissions.length === 0 ? ( -
- Responses will appear here after people submit a form. -
+

+ Responses will appear here after someone submits a form. +

) : ( <>
@@ -169,12 +226,6 @@ export default async function AdminPage() { > {respondentName(submission)} - {submission.userName && - submission.userDiscordId && ( -

- {submission.userDiscordId} -

- )} - {formatDate(submission.submittedAt)} + + {formatDate(submission.submittedAt)} +
{recentSubmissions.map((submission) => ( - + -
-
- - - {respondentName(submission)} - - - - {submission.formTitle} - -
+ + + {respondentName(submission)} + + + + {submission.formTitle} · {formatDate(submission.submittedAt)} + + {submission.edited ? "Edited" : "Original"} -
+
- - {formatDate(submission.submittedAt)} -
))}
@@ -236,148 +284,80 @@ export default async function AdminPage() { -
- - - -
- -
- Forms - - Manage forms and view submissions - -
-
-
-
- - - - -
- -
- Backend - - Follower API settings and cache - -
-
-
-
- -
-
- - - - Form activity - - Forms ranked by responses in the last 7 days. - - - - {activeForms.length === 0 ? ( -
+ + + Form momentum + + Response activity during the last 7 days. + + + + {activeForms.length === 0 ? (

- No forms found. Create one to start collecting responses. + Create a form to start tracking activity.

-
- -
-
- ) : ( - <> -
- - - - Form - Status - Today - Last 7 days - Total - Last response - Actions - - - - {activeForms.map((form) => ( - - - - {form.title} - - - - - {form.isOpen ? "Open" : "Closed"} - - - {formatNumber(form.responsesToday)} - - {formatNumber(form.responsesLast7Days)} - - {formatNumber(form.totalResponses)} - {formatDate(form.lastResponseAt)} - - - - - ))} - -
-
-
- {activeForms.map((form) => ( - - -
-
- - - {form.title} - - - - Last response: {formatDate(form.lastResponseAt)} - -
- - {form.isOpen ? "Open" : "Closed"} - -
-
- -
- {formatNumber(form.responsesLast7Days)} this week ·{" "} - {formatNumber(form.totalResponses)} total -
- -
-
- ))} -
- - )} -
-
-
+ ) : ( + activeForms.map((form) => ( +
+
+ + {form.title} + + + {formatNumber(form.responsesLast7Days)} + +
+ +
+ + {form.isOpen ? "Open" : "Closed"} + + {formatNumber(form.totalResponses)} total +
+
+ )) + )} + +
+ + +
+
+

Workspace

+

+ Go directly to the tools you operate most often. +

+
+
+ + + +
+
+ ); }