Spaces:
Sleeping
Sleeping
v4.1: Dashboard — admin quick access, no upgrade CTA for admin, role badge, v4 descriptions
Browse files
web/app/dashboard-pages/dashboard/page.tsx
CHANGED
|
@@ -2,7 +2,8 @@ import { createClient } from "@/lib/supabase/server";
|
|
| 2 |
import Link from "next/link";
|
| 3 |
import {
|
| 4 |
ScanText, ShieldCheck, Tag, AlertTriangle, ClipboardList,
|
| 5 |
-
GitCompare, Cpu, Layers, Clock
|
|
|
|
| 6 |
} from "lucide-react";
|
| 7 |
|
| 8 |
export default async function DashboardPage() {
|
|
@@ -17,8 +18,10 @@ export default async function DashboardPage() {
|
|
| 17 |
.order("created_at", { ascending: false }).limit(10);
|
| 18 |
|
| 19 |
const plan = profile?.plan || "free";
|
|
|
|
|
|
|
| 20 |
const usedThisMonth = profile?.analyses_this_month || 0;
|
| 21 |
-
const limit = plan === "free" ? 10 : "
|
| 22 |
|
| 23 |
const avgRisk = analyses && analyses.length > 0
|
| 24 |
? Math.round(analyses.reduce((s: number, a: any) => s + a.risk_score, 0) / analyses.length)
|
|
@@ -36,22 +39,35 @@ export default async function DashboardPage() {
|
|
| 36 |
<h1 className="text-xl sm:text-2xl font-bold text-gray-900 flex items-center gap-2">
|
| 37 |
<ShieldCheck className="w-5 h-5 sm:w-6 sm:h-6 text-indigo-500" />
|
| 38 |
Dashboard
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
</h1>
|
| 40 |
<p className="text-gray-500 text-sm mt-1">Welcome back, {profile?.full_name || user?.email}</p>
|
| 41 |
</div>
|
| 42 |
-
<
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</div>
|
| 47 |
|
| 48 |
{/* Primary Stats */}
|
| 49 |
<div className="grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-6 mb-8 sm:mb-10">
|
| 50 |
{[
|
| 51 |
-
{ label: "Plan", value: plan, capitalize: true },
|
| 52 |
{ label: "Scans This Month", value: `${usedThisMonth} / ${limit}` },
|
| 53 |
{ label: "Total Scans", value: String(count || 0) },
|
| 54 |
-
{ label: "Avg Risk Score", value: avgRisk !== null ? String(avgRisk) : "
|
| 55 |
].map((s) => (
|
| 56 |
<div key={s.label} className="bg-white rounded-xl p-4 sm:p-6 border border-gray-200">
|
| 57 |
<p className="text-xs sm:text-sm text-gray-500">{s.label}</p>
|
|
@@ -81,24 +97,33 @@ export default async function DashboardPage() {
|
|
| 81 |
</div>
|
| 82 |
|
| 83 |
{/* Quick Actions */}
|
| 84 |
-
<div className="grid sm:grid-cols-2 gap-3 sm:gap-
|
| 85 |
-
<Link href="/dashboard-pages/analyze" className="bg-white rounded-xl p-5
|
| 86 |
<div className="flex items-center gap-3 mb-2">
|
| 87 |
-
<div className="w-
|
| 88 |
-
<ScanText className="w-5 h-5 text-indigo-600" />
|
| 89 |
</div>
|
| 90 |
-
<h3 className="font-semibold text-gray-900">Analyze Contract</h3>
|
| 91 |
</div>
|
| 92 |
-
<p className="text-
|
| 93 |
</Link>
|
| 94 |
-
<Link href="/dashboard-pages/compare" className="bg-white rounded-xl p-5
|
| 95 |
<div className="flex items-center gap-3 mb-2">
|
| 96 |
-
<div className="w-
|
| 97 |
-
<GitCompare className="w-5 h-5 text-indigo-600" />
|
| 98 |
</div>
|
| 99 |
-
<h3 className="font-semibold text-gray-900">Compare Contracts</h3>
|
| 100 |
</div>
|
| 101 |
-
<p className="text-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
</Link>
|
| 103 |
</div>
|
| 104 |
|
|
@@ -132,11 +157,6 @@ export default async function DashboardPage() {
|
|
| 132 |
<ClipboardList className="w-2.5 h-2.5" />{a.obligations.length}
|
| 133 |
</span>
|
| 134 |
)}
|
| 135 |
-
{a.model && a.model !== "regex" && (
|
| 136 |
-
<span className="inline-flex items-center gap-1 text-[10px] bg-indigo-50 text-indigo-600 px-1.5 py-0.5 rounded border border-indigo-100">
|
| 137 |
-
<Cpu className="w-2.5 h-2.5" />ML
|
| 138 |
-
</span>
|
| 139 |
-
)}
|
| 140 |
</div>
|
| 141 |
</div>
|
| 142 |
<span className={`self-start sm:self-auto text-sm font-bold px-3 py-1 rounded-full whitespace-nowrap ${
|
|
@@ -158,12 +178,12 @@ export default async function DashboardPage() {
|
|
| 158 |
)}
|
| 159 |
</div>
|
| 160 |
|
| 161 |
-
{/* Upgrade CTA */}
|
| 162 |
-
{plan === "free" && (
|
| 163 |
<div className="mt-8 bg-indigo-50 border border-indigo-200 rounded-xl p-5 sm:p-6 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
|
| 164 |
<div>
|
| 165 |
<p className="font-semibold text-indigo-900">Upgrade to Pro</p>
|
| 166 |
-
<p className="text-sm text-indigo-700 mt-1">Unlimited scans, contract comparison, PDF exports,
|
| 167 |
</div>
|
| 168 |
<Link href="/#pricing" className="bg-indigo-600 text-white px-6 py-2.5 rounded-lg font-semibold text-sm hover:bg-indigo-700 transition whitespace-nowrap">
|
| 169 |
View Plans
|
|
|
|
| 2 |
import Link from "next/link";
|
| 3 |
import {
|
| 4 |
ScanText, ShieldCheck, Tag, AlertTriangle, ClipboardList,
|
| 5 |
+
GitCompare, Cpu, Layers, Clock, Crown, PenTool, MessageSquare,
|
| 6 |
+
ScanLine, Settings
|
| 7 |
} from "lucide-react";
|
| 8 |
|
| 9 |
export default async function DashboardPage() {
|
|
|
|
| 18 |
.order("created_at", { ascending: false }).limit(10);
|
| 19 |
|
| 20 |
const plan = profile?.plan || "free";
|
| 21 |
+
const role = profile?.role || "user";
|
| 22 |
+
const isAdmin = role === "admin";
|
| 23 |
const usedThisMonth = profile?.analyses_this_month || 0;
|
| 24 |
+
const limit = isAdmin ? "∞" : plan === "free" ? 10 : "∞";
|
| 25 |
|
| 26 |
const avgRisk = analyses && analyses.length > 0
|
| 27 |
? Math.round(analyses.reduce((s: number, a: any) => s + a.risk_score, 0) / analyses.length)
|
|
|
|
| 39 |
<h1 className="text-xl sm:text-2xl font-bold text-gray-900 flex items-center gap-2">
|
| 40 |
<ShieldCheck className="w-5 h-5 sm:w-6 sm:h-6 text-indigo-500" />
|
| 41 |
Dashboard
|
| 42 |
+
{isAdmin && (
|
| 43 |
+
<span className="text-xs bg-amber-50 text-amber-700 border border-amber-200 px-2 py-0.5 rounded-full flex items-center gap-1">
|
| 44 |
+
<Crown className="w-3 h-3" /> Admin
|
| 45 |
+
</span>
|
| 46 |
+
)}
|
| 47 |
</h1>
|
| 48 |
<p className="text-gray-500 text-sm mt-1">Welcome back, {profile?.full_name || user?.email}</p>
|
| 49 |
</div>
|
| 50 |
+
<div className="flex gap-2">
|
| 51 |
+
{isAdmin && (
|
| 52 |
+
<Link href="/admin"
|
| 53 |
+
className="bg-amber-50 text-amber-700 border border-amber-200 px-4 py-2.5 rounded-xl font-semibold hover:bg-amber-100 transition text-sm whitespace-nowrap flex items-center gap-2">
|
| 54 |
+
<Crown className="w-4 h-4" /> Admin Panel
|
| 55 |
+
</Link>
|
| 56 |
+
)}
|
| 57 |
+
<Link href="/dashboard-pages/analyze"
|
| 58 |
+
className="bg-indigo-600 text-white px-5 sm:px-6 py-2.5 rounded-xl font-semibold hover:bg-indigo-700 transition text-sm whitespace-nowrap">
|
| 59 |
+
+ New Scan
|
| 60 |
+
</Link>
|
| 61 |
+
</div>
|
| 62 |
</div>
|
| 63 |
|
| 64 |
{/* Primary Stats */}
|
| 65 |
<div className="grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-6 mb-8 sm:mb-10">
|
| 66 |
{[
|
| 67 |
+
{ label: "Plan", value: isAdmin ? "Admin" : plan, capitalize: true },
|
| 68 |
{ label: "Scans This Month", value: `${usedThisMonth} / ${limit}` },
|
| 69 |
{ label: "Total Scans", value: String(count || 0) },
|
| 70 |
+
{ label: "Avg Risk Score", value: avgRisk !== null ? String(avgRisk) : "—" },
|
| 71 |
].map((s) => (
|
| 72 |
<div key={s.label} className="bg-white rounded-xl p-4 sm:p-6 border border-gray-200">
|
| 73 |
<p className="text-xs sm:text-sm text-gray-500">{s.label}</p>
|
|
|
|
| 97 |
</div>
|
| 98 |
|
| 99 |
{/* Quick Actions */}
|
| 100 |
+
<div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4 mb-8 sm:mb-10">
|
| 101 |
+
<Link href="/dashboard-pages/analyze" className="bg-white rounded-xl p-5 border border-gray-200 hover:border-indigo-200 hover:shadow-sm transition-all group">
|
| 102 |
<div className="flex items-center gap-3 mb-2">
|
| 103 |
+
<div className="w-9 h-9 rounded-lg bg-indigo-50 flex items-center justify-center group-hover:bg-indigo-100 transition-colors">
|
| 104 |
+
<ScanText className="w-4.5 h-4.5 text-indigo-600" />
|
| 105 |
</div>
|
| 106 |
+
<h3 className="font-semibold text-gray-900 text-sm">Analyze Contract</h3>
|
| 107 |
</div>
|
| 108 |
+
<p className="text-xs text-gray-500">6 ML models: classifier, NER, NLI, embeddings, OCR, LLM.</p>
|
| 109 |
</Link>
|
| 110 |
+
<Link href="/dashboard-pages/compare" className="bg-white rounded-xl p-5 border border-gray-200 hover:border-indigo-200 hover:shadow-sm transition-all group">
|
| 111 |
<div className="flex items-center gap-3 mb-2">
|
| 112 |
+
<div className="w-9 h-9 rounded-lg bg-indigo-50 flex items-center justify-center group-hover:bg-indigo-100 transition-colors">
|
| 113 |
+
<GitCompare className="w-4.5 h-4.5 text-indigo-600" />
|
| 114 |
</div>
|
| 115 |
+
<h3 className="font-semibold text-gray-900 text-sm">Compare Contracts</h3>
|
| 116 |
</div>
|
| 117 |
+
<p className="text-xs text-gray-500">Side-by-side diff with semantic similarity and risk delta.</p>
|
| 118 |
+
</Link>
|
| 119 |
+
<Link href="/dashboard-pages/settings" className="bg-white rounded-xl p-5 border border-gray-200 hover:border-indigo-200 hover:shadow-sm transition-all group">
|
| 120 |
+
<div className="flex items-center gap-3 mb-2">
|
| 121 |
+
<div className="w-9 h-9 rounded-lg bg-zinc-100 flex items-center justify-center group-hover:bg-zinc-200 transition-colors">
|
| 122 |
+
<Settings className="w-4.5 h-4.5 text-zinc-600" />
|
| 123 |
+
</div>
|
| 124 |
+
<h3 className="font-semibold text-gray-900 text-sm">Settings</h3>
|
| 125 |
+
</div>
|
| 126 |
+
<p className="text-xs text-gray-500">Account, subscription, API keys, team management.</p>
|
| 127 |
</Link>
|
| 128 |
</div>
|
| 129 |
|
|
|
|
| 157 |
<ClipboardList className="w-2.5 h-2.5" />{a.obligations.length}
|
| 158 |
</span>
|
| 159 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
</div>
|
| 161 |
</div>
|
| 162 |
<span className={`self-start sm:self-auto text-sm font-bold px-3 py-1 rounded-full whitespace-nowrap ${
|
|
|
|
| 178 |
)}
|
| 179 |
</div>
|
| 180 |
|
| 181 |
+
{/* Upgrade CTA — only for non-admin free users */}
|
| 182 |
+
{plan === "free" && !isAdmin && (
|
| 183 |
<div className="mt-8 bg-indigo-50 border border-indigo-200 rounded-xl p-5 sm:p-6 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
|
| 184 |
<div>
|
| 185 |
<p className="font-semibold text-indigo-900">Upgrade to Pro</p>
|
| 186 |
+
<p className="text-sm text-indigo-700 mt-1">Unlimited scans, file uploads, contract comparison, PDF exports, Q&A chatbot, and LLM-powered redlining.</p>
|
| 187 |
</div>
|
| 188 |
<Link href="/#pricing" className="bg-indigo-600 text-white px-6 py-2.5 rounded-lg font-semibold text-sm hover:bg-indigo-700 transition whitespace-nowrap">
|
| 189 |
View Plans
|