Spaces:
Sleeping
Sleeping
Upload web/app/dashboard-pages/dashboard/page.tsx
Browse files
web/app/dashboard-pages/dashboard/page.tsx
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
import { createClient } from "@/lib/supabase/server";
|
| 2 |
import Link from "next/link";
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
export default async function DashboardPage() {
|
| 5 |
const supabase = await createClient();
|
|
@@ -22,6 +26,15 @@ export default async function DashboardPage() {
|
|
| 22 |
const usedThisMonth = profile?.analyses_this_month || 0;
|
| 23 |
const limit = plan === "free" ? 10 : "∞";
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
return (
|
| 26 |
<div className="min-h-screen bg-gray-50">
|
| 27 |
<div className="max-w-6xl mx-auto px-6 py-12">
|
|
@@ -42,7 +55,7 @@ export default async function DashboardPage() {
|
|
| 42 |
</div>
|
| 43 |
|
| 44 |
{/* Stats */}
|
| 45 |
-
<div className="grid md:grid-cols-4 gap-6 mb-10">
|
| 46 |
<div className="bg-white rounded-xl p-6 border border-gray-200">
|
| 47 |
<p className="text-sm text-gray-500">Plan</p>
|
| 48 |
<p className="text-2xl font-bold text-gray-900 capitalize mt-1">{plan}</p>
|
|
@@ -57,14 +70,63 @@ export default async function DashboardPage() {
|
|
| 57 |
</div>
|
| 58 |
<div className="bg-white rounded-xl p-6 border border-gray-200">
|
| 59 |
<p className="text-sm text-gray-500">Avg Risk Score</p>
|
| 60 |
-
<p className="text-2xl font-bold text-gray-900 mt-1">
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
</div>
|
| 66 |
</div>
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
{/* Recent Scans */}
|
| 69 |
<div className="bg-white rounded-xl border border-gray-200 overflow-hidden">
|
| 70 |
<div className="px-6 py-4 border-b border-gray-100">
|
|
@@ -78,9 +140,17 @@ export default async function DashboardPage() {
|
|
| 78 |
<p className="text-sm font-medium text-gray-900 truncate">
|
| 79 |
{a.source_url || "Manual scan"}
|
| 80 |
</p>
|
| 81 |
-
<
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
</div>
|
| 85 |
<div className="flex items-center gap-3">
|
| 86 |
<span className={`text-sm font-bold px-3 py-1 rounded-full ${
|
|
@@ -108,7 +178,7 @@ export default async function DashboardPage() {
|
|
| 108 |
<div className="mt-8 bg-indigo-50 border border-indigo-200 rounded-xl p-6 flex items-center justify-between">
|
| 109 |
<div>
|
| 110 |
<p className="font-semibold text-indigo-900">Upgrade to Pro</p>
|
| 111 |
-
<p className="text-sm text-indigo-700 mt-1">Unlimited scans,
|
| 112 |
</div>
|
| 113 |
<Link
|
| 114 |
href="/#pricing"
|
|
|
|
| 1 |
import { createClient } from "@/lib/supabase/server";
|
| 2 |
import Link from "next/link";
|
| 3 |
+
import {
|
| 4 |
+
ScanText, ShieldCheck, TriangleAlert, Tag, AlertTriangle,
|
| 5 |
+
ClipboardList, FileCompare, TrendingUp, Clock
|
| 6 |
+
} from "lucide-react";
|
| 7 |
|
| 8 |
export default async function DashboardPage() {
|
| 9 |
const supabase = await createClient();
|
|
|
|
| 26 |
const usedThisMonth = profile?.analyses_this_month || 0;
|
| 27 |
const limit = plan === "free" ? 10 : "∞";
|
| 28 |
|
| 29 |
+
// Calculate stats
|
| 30 |
+
const avgRisk = analyses && analyses.length > 0
|
| 31 |
+
? Math.round(analyses.reduce((s, a) => s + a.risk_score, 0) / analyses.length)
|
| 32 |
+
: null;
|
| 33 |
+
|
| 34 |
+
const totalEntities = analyses?.reduce((s, a) => s + (a.entities?.length || 0), 0) || 0;
|
| 35 |
+
const totalContradictions = analyses?.reduce((s, a) => s + (a.contradictions?.length || 0), 0) || 0;
|
| 36 |
+
const totalObligations = analyses?.reduce((s, a) => s + (a.obligations?.length || 0), 0) || 0;
|
| 37 |
+
|
| 38 |
return (
|
| 39 |
<div className="min-h-screen bg-gray-50">
|
| 40 |
<div className="max-w-6xl mx-auto px-6 py-12">
|
|
|
|
| 55 |
</div>
|
| 56 |
|
| 57 |
{/* Stats */}
|
| 58 |
+
<div className="grid md:grid-cols-2 lg:grid-cols-4 gap-6 mb-10">
|
| 59 |
<div className="bg-white rounded-xl p-6 border border-gray-200">
|
| 60 |
<p className="text-sm text-gray-500">Plan</p>
|
| 61 |
<p className="text-2xl font-bold text-gray-900 capitalize mt-1">{plan}</p>
|
|
|
|
| 70 |
</div>
|
| 71 |
<div className="bg-white rounded-xl p-6 border border-gray-200">
|
| 72 |
<p className="text-sm text-gray-500">Avg Risk Score</p>
|
| 73 |
+
<p className="text-2xl font-bold text-gray-900 mt-1">{avgRisk !== null ? avgRisk : "—"}</p>
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
{/* Extended Stats v2 */}
|
| 78 |
+
<div className="grid md:grid-cols-3 gap-6 mb-10">
|
| 79 |
+
<div className="bg-white rounded-xl p-6 border border-gray-200 flex items-center gap-4">
|
| 80 |
+
<div className="w-10 h-10 rounded-lg bg-blue-50 flex items-center justify-center">
|
| 81 |
+
<Tag className="w-5 h-5 text-blue-600" />
|
| 82 |
+
</div>
|
| 83 |
+
<div>
|
| 84 |
+
<p className="text-sm text-gray-500">Entities Extracted</p>
|
| 85 |
+
<p className="text-xl font-bold text-gray-900">{totalEntities}</p>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
<div className="bg-white rounded-xl p-6 border border-gray-200 flex items-center gap-4">
|
| 89 |
+
<div className="w-10 h-10 rounded-lg bg-amber-50 flex items-center justify-center">
|
| 90 |
+
<AlertTriangle className="w-5 h-5 text-amber-600" />
|
| 91 |
+
</div>
|
| 92 |
+
<div>
|
| 93 |
+
<p className="text-sm text-gray-500">Contradictions Found</p>
|
| 94 |
+
<p className="text-xl font-bold text-gray-900">{totalContradictions}</p>
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
<div className="bg-white rounded-xl p-6 border border-gray-200 flex items-center gap-4">
|
| 98 |
+
<div className="w-10 h-10 rounded-lg bg-emerald-50 flex items-center justify-center">
|
| 99 |
+
<ClipboardList className="w-5 h-5 text-emerald-600" />
|
| 100 |
+
</div>
|
| 101 |
+
<div>
|
| 102 |
+
<p className="text-sm text-gray-500">Obligations Tracked</p>
|
| 103 |
+
<p className="text-xl font-bold text-gray-900">{totalObligations}</p>
|
| 104 |
+
</div>
|
| 105 |
</div>
|
| 106 |
</div>
|
| 107 |
|
| 108 |
+
{/* Quick Actions */}
|
| 109 |
+
<div className="grid md:grid-cols-2 gap-6 mb-10">
|
| 110 |
+
<Link href="/dashboard-pages/analyze" className="bg-white rounded-xl p-6 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-10 h-10 rounded-lg bg-indigo-50 flex items-center justify-center group-hover:bg-indigo-100 transition-colors">
|
| 113 |
+
<ScanText className="w-5 h-5 text-indigo-600" />
|
| 114 |
+
</div>
|
| 115 |
+
<h3 className="font-semibold text-gray-900">Analyze Contract</h3>
|
| 116 |
+
</div>
|
| 117 |
+
<p className="text-sm text-gray-500">Scan a contract for 41 clause types, risk scoring, NER, and compliance.</p>
|
| 118 |
+
</Link>
|
| 119 |
+
<Link href="/dashboard-pages/compare" className="bg-white rounded-xl p-6 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-10 h-10 rounded-lg bg-indigo-50 flex items-center justify-center group-hover:bg-indigo-100 transition-colors">
|
| 122 |
+
<FileCompare className="w-5 h-5 text-indigo-600" />
|
| 123 |
+
</div>
|
| 124 |
+
<h3 className="font-semibold text-gray-900">Compare Contracts</h3>
|
| 125 |
+
</div>
|
| 126 |
+
<p className="text-sm text-gray-500">Side-by-side diff with alignment scoring and risk delta analysis.</p>
|
| 127 |
+
</Link>
|
| 128 |
+
</div>
|
| 129 |
+
|
| 130 |
{/* Recent Scans */}
|
| 131 |
<div className="bg-white rounded-xl border border-gray-200 overflow-hidden">
|
| 132 |
<div className="px-6 py-4 border-b border-gray-100">
|
|
|
|
| 140 |
<p className="text-sm font-medium text-gray-900 truncate">
|
| 141 |
{a.source_url || "Manual scan"}
|
| 142 |
</p>
|
| 143 |
+
<div className="flex items-center gap-3 mt-1">
|
| 144 |
+
<p className="text-xs text-gray-500">
|
| 145 |
+
{new Date(a.created_at).toLocaleDateString()} · {a.total_clauses} clauses · {a.flagged_count} flagged
|
| 146 |
+
</p>
|
| 147 |
+
{a.entities && a.entities.length > 0 && (
|
| 148 |
+
<span className="text-[10px] bg-blue-50 text-blue-600 px-1.5 py-0.5 rounded">{a.entities.length} entities</span>
|
| 149 |
+
)}
|
| 150 |
+
{a.contradictions && a.contradictions.length > 0 && (
|
| 151 |
+
<span className="text-[10px] bg-amber-50 text-amber-600 px-1.5 py-0.5 rounded">{a.contradictions.length} issues</span>
|
| 152 |
+
)}
|
| 153 |
+
</div>
|
| 154 |
</div>
|
| 155 |
<div className="flex items-center gap-3">
|
| 156 |
<span className={`text-sm font-bold px-3 py-1 rounded-full ${
|
|
|
|
| 178 |
<div className="mt-8 bg-indigo-50 border border-indigo-200 rounded-xl p-6 flex items-center justify-between">
|
| 179 |
<div>
|
| 180 |
<p className="font-semibold text-indigo-900">Upgrade to Pro</p>
|
| 181 |
+
<p className="text-sm text-indigo-700 mt-1">Unlimited scans, contract comparison, PDF exports, and team features.</p>
|
| 182 |
</div>
|
| 183 |
<Link
|
| 184 |
href="/#pricing"
|