forked from codu-code/codu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_client.tsx
More file actions
230 lines (216 loc) · 7.56 KB
/
_client.tsx
File metadata and controls
230 lines (216 loc) · 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
"use client";
import Link from "next/link";
import {
UsersIcon,
DocumentTextIcon,
FlagIcon,
RssIcon,
ShieldExclamationIcon,
TagIcon,
} from "@heroicons/react/24/outline";
import { api } from "@/server/trpc/react";
const colorClasses = {
blue: "bg-blue-50 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400",
green: "bg-green-50 text-green-600 dark:bg-green-900/30 dark:text-green-400",
yellow:
"bg-yellow-50 text-yellow-600 dark:bg-yellow-900/30 dark:text-yellow-400",
red: "bg-red-50 text-red-600 dark:bg-red-900/30 dark:text-red-400",
purple:
"bg-purple-50 text-purple-600 dark:bg-purple-900/30 dark:text-purple-400",
orange:
"bg-orange-50 text-orange-600 dark:bg-orange-900/30 dark:text-orange-400",
};
const StatCard = ({
title,
value,
icon: Icon,
href,
color = "blue",
isLoading,
}: {
title: string;
value: number | undefined;
icon: React.ComponentType<{ className?: string }>;
href?: string;
color?: "blue" | "green" | "yellow" | "red" | "purple" | "orange";
isLoading?: boolean;
}) => {
const content = (
<div className="rounded-lg border border-neutral-200 bg-white p-4 transition-colors hover:border-neutral-300 dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-neutral-600">
<div className="flex items-center gap-3">
<div className={`rounded-lg p-2 ${colorClasses[color]}`}>
<Icon className="h-5 w-5" />
</div>
<div>
<p className="text-sm text-neutral-500 dark:text-neutral-400">
{title}
</p>
<p className="text-2xl font-bold text-neutral-900 dark:text-white">
{isLoading ? (
<span className="inline-block h-8 w-16 animate-pulse rounded bg-neutral-200 dark:bg-neutral-700" />
) : (
(value ?? 0)
)}
</p>
</div>
</div>
</div>
);
if (href) {
return <Link href={href}>{content}</Link>;
}
return content;
};
const AdminDashboard = () => {
const { data: stats, isLoading } = api.admin.getStats.useQuery();
const { data: reportCounts } = api.report.getCounts.useQuery();
return (
<div className="mx-auto max-w-6xl px-4 py-8">
<div className="mb-8">
<h1 className="text-3xl font-bold text-neutral-900 dark:text-white">
Admin Dashboard
</h1>
<p className="mt-1 text-neutral-500 dark:text-neutral-400">
Manage and monitor the Codú platform
</p>
</div>
{/* Stats Grid */}
<div className="mb-8 grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
<StatCard
title="Total Users"
value={stats?.totalUsers}
icon={UsersIcon}
color="blue"
href="/admin/users"
isLoading={isLoading}
/>
<StatCard
title="Published Posts"
value={stats?.publishedPosts}
icon={DocumentTextIcon}
color="green"
isLoading={isLoading}
/>
<StatCard
title="Active Feed Sources"
value={stats?.activeFeedSources}
icon={RssIcon}
color="orange"
href="/admin/sources"
isLoading={isLoading}
/>
<StatCard
title="Total Reports"
value={reportCounts?.total}
icon={FlagIcon}
color="purple"
href="/admin/moderation"
isLoading={isLoading}
/>
</div>
{/* Moderation Stats */}
<div className="mb-8">
<h2 className="mb-4 text-xl font-semibold text-neutral-900 dark:text-white">
Moderation
</h2>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
<StatCard
title="Pending Reports"
value={reportCounts?.pending}
icon={FlagIcon}
color="yellow"
href="/admin/moderation"
isLoading={isLoading}
/>
<StatCard
title="Actioned Reports"
value={reportCounts?.actioned}
icon={ShieldExclamationIcon}
color="red"
isLoading={isLoading}
/>
<StatCard
title="Banned Users"
value={stats?.bannedUsers}
icon={ShieldExclamationIcon}
color="red"
href="/admin/users?filter=banned"
isLoading={isLoading}
/>
<StatCard
title="Dismissed Reports"
value={reportCounts?.dismissed}
icon={FlagIcon}
color="green"
isLoading={isLoading}
/>
</div>
</div>
{/* Quick Links */}
<div className="mb-8">
<h2 className="mb-4 text-xl font-semibold text-neutral-900 dark:text-white">
Quick Actions
</h2>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
<Link
href="/admin/moderation"
className="flex items-center gap-3 rounded-lg border border-neutral-200 bg-white p-4 transition-colors hover:border-orange-300 hover:bg-orange-50 dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-orange-700 dark:hover:bg-orange-900/20"
>
<FlagIcon className="h-6 w-6 text-orange-500" />
<div>
<p className="font-medium text-neutral-900 dark:text-white">
Moderation Queue
</p>
<p className="text-sm text-neutral-500 dark:text-neutral-400">
Review reported content
</p>
</div>
</Link>
<Link
href="/admin/users"
className="flex items-center gap-3 rounded-lg border border-neutral-200 bg-white p-4 transition-colors hover:border-blue-300 hover:bg-blue-50 dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-blue-700 dark:hover:bg-blue-900/20"
>
<UsersIcon className="h-6 w-6 text-blue-500" />
<div>
<p className="font-medium text-neutral-900 dark:text-white">
User Management
</p>
<p className="text-sm text-neutral-500 dark:text-neutral-400">
Search and manage users
</p>
</div>
</Link>
<Link
href="/admin/sources"
className="flex items-center gap-3 rounded-lg border border-neutral-200 bg-white p-4 transition-colors hover:border-purple-300 hover:bg-purple-50 dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-purple-700 dark:hover:bg-purple-900/20"
>
<RssIcon className="h-6 w-6 text-purple-500" />
<div>
<p className="font-medium text-neutral-900 dark:text-white">
Feed Sources
</p>
<p className="text-sm text-neutral-500 dark:text-neutral-400">
Manage RSS feed sources
</p>
</div>
</Link>
<Link
href="/admin/tags"
className="flex items-center gap-3 rounded-lg border border-neutral-200 bg-white p-4 transition-colors hover:border-green-300 hover:bg-green-50 dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-green-700 dark:hover:bg-green-900/20"
>
<TagIcon className="h-6 w-6 text-green-500" />
<div>
<p className="font-medium text-neutral-900 dark:text-white">
Tag Management
</p>
<p className="text-sm text-neutral-500 dark:text-neutral-400">
Merge, curate, and manage tags
</p>
</div>
</Link>
</div>
</div>
</div>
);
};
export default AdminDashboard;