Skip to content

Commit 8f72043

Browse files
authored
Merge pull request #347 from codeunia-dev/fix/event
feat(hackathons): Add total views and registrations statistics to hackathons dashboard
2 parents a9cb289 + 4fb8c86 commit 8f72043

File tree

1 file changed

+48
-17
lines changed
  • app/dashboard/company/[slug]/hackathons

1 file changed

+48
-17
lines changed

app/dashboard/company/[slug]/hackathons/page.tsx

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,40 +130,42 @@ export default function CompanyHackathonsPage() {
130130
approved: hackathons.filter(h => h.approval_status === 'approved').length,
131131
pending: hackathons.filter(h => h.approval_status === 'pending').length,
132132
draft: hackathons.filter(h => h.status === 'draft').length,
133+
totalViews: hackathons.reduce((sum, h) => sum + (h.views || 0), 0),
134+
totalRegistrations: hackathons.reduce((sum, h) => sum + (h.registered || 0), 0),
133135
}
134136

135137
const getApprovalBadge = (status: string) => {
136138
switch (status) {
137139
case 'approved':
138140
return (
139-
<Badge className="bg-green-500/10 text-green-600 border-green-500/20">
141+
<Badge className="bg-green-500/10 text-green-600 border-green-500/20 pointer-events-none">
140142
<CheckCircle className="h-3 w-3 mr-1" />
141143
Approved
142144
</Badge>
143145
)
144146
case 'pending':
145147
return (
146-
<Badge className="bg-yellow-500/10 text-yellow-600 border-yellow-500/20">
148+
<Badge className="bg-yellow-500/10 text-yellow-600 border-yellow-500/20 pointer-events-none">
147149
<Clock className="h-3 w-3 mr-1" />
148150
Pending
149151
</Badge>
150152
)
151153
case 'rejected':
152154
return (
153-
<Badge className="bg-red-500/10 text-red-600 border-red-500/20">
155+
<Badge className="bg-red-500/10 text-red-600 border-red-500/20 pointer-events-none">
154156
<XCircle className="h-3 w-3 mr-1" />
155157
Rejected
156158
</Badge>
157159
)
158160
case 'changes_requested':
159161
return (
160-
<Badge className="bg-orange-500/10 text-orange-600 border-orange-500/20">
162+
<Badge className="bg-orange-500/10 text-orange-600 border-orange-500/20 pointer-events-none">
161163
<AlertCircle className="h-3 w-3 mr-1" />
162164
Changes Requested
163165
</Badge>
164166
)
165167
default:
166-
return <Badge variant="outline">{status}</Badge>
168+
return <Badge variant="outline" className="pointer-events-none">{status}</Badge>
167169
}
168170
}
169171

@@ -172,31 +174,31 @@ export default function CompanyHackathonsPage() {
172174
if (hackathon.approval_status !== 'approved') {
173175
switch (hackathon.approval_status) {
174176
case 'pending':
175-
return <Badge className="bg-yellow-500/10 text-yellow-600 border-yellow-500/20">Pending Review</Badge>
177+
return <Badge className="bg-yellow-500/10 text-yellow-600 border-yellow-500/20 pointer-events-none">Pending Review</Badge>
176178
case 'draft':
177-
return <Badge variant="outline">Draft</Badge>
179+
return <Badge variant="outline" className="pointer-events-none">Draft</Badge>
178180
case 'rejected':
179-
return <Badge className="bg-red-500/10 text-red-600 border-red-500/20">Rejected</Badge>
181+
return <Badge className="bg-red-500/10 text-red-600 border-red-500/20 pointer-events-none">Rejected</Badge>
180182
case 'changes_requested':
181-
return <Badge className="bg-orange-500/10 text-orange-600 border-orange-500/20">Changes Requested</Badge>
183+
return <Badge className="bg-orange-500/10 text-orange-600 border-orange-500/20 pointer-events-none">Changes Requested</Badge>
182184
default:
183-
return <Badge variant="outline">{hackathon.approval_status}</Badge>
185+
return <Badge variant="outline" className="pointer-events-none">{hackathon.approval_status}</Badge>
184186
}
185187
}
186188

187189
// If approved, show event status
188190
switch (hackathon.status) {
189191
case 'live':
190192
case 'published':
191-
return <Badge className="bg-blue-500/10 text-blue-600 border-blue-500/20">Live</Badge>
193+
return <Badge className="bg-blue-500/10 text-blue-600 border-blue-500/20 pointer-events-none">Live</Badge>
192194
case 'draft':
193-
return <Badge variant="outline">Draft</Badge>
195+
return <Badge variant="outline" className="pointer-events-none">Draft</Badge>
194196
case 'cancelled':
195-
return <Badge variant="outline" className="text-gray-500">Cancelled</Badge>
197+
return <Badge variant="outline" className="text-gray-500 pointer-events-none">Cancelled</Badge>
196198
case 'completed':
197-
return <Badge variant="outline" className="text-gray-500">Completed</Badge>
199+
return <Badge variant="outline" className="text-gray-500 pointer-events-none">Completed</Badge>
198200
default:
199-
return <Badge variant="outline">{hackathon.status}</Badge>
201+
return <Badge variant="outline" className="pointer-events-none">{hackathon.status}</Badge>
200202
}
201203
}
202204

@@ -229,7 +231,7 @@ export default function CompanyHackathonsPage() {
229231
</div>
230232

231233
{/* Stats Cards */}
232-
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
234+
<div className="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-6 gap-4">
233235
<Card>
234236
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
235237
<CardTitle className="text-sm font-medium">Total Hackathons</CardTitle>
@@ -266,6 +268,24 @@ export default function CompanyHackathonsPage() {
266268
<div className="text-2xl font-bold">{stats.draft}</div>
267269
</CardContent>
268270
</Card>
271+
<Card>
272+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
273+
<CardTitle className="text-sm font-medium">Total Views</CardTitle>
274+
<Eye className="h-4 w-4 text-blue-600" />
275+
</CardHeader>
276+
<CardContent>
277+
<div className="text-2xl font-bold text-blue-600">{stats.totalViews}</div>
278+
</CardContent>
279+
</Card>
280+
<Card>
281+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
282+
<CardTitle className="text-sm font-medium">Total Registrations</CardTitle>
283+
<CheckCircle className="h-4 w-4 text-purple-600" />
284+
</CardHeader>
285+
<CardContent>
286+
<div className="text-2xl font-bold text-purple-600">{stats.totalRegistrations}</div>
287+
</CardContent>
288+
</Card>
269289
</div>
270290

271291
{/* Search */}
@@ -346,7 +366,18 @@ export default function CompanyHackathonsPage() {
346366
{hackathon.views || 0}
347367
</div>
348368
</TableCell>
349-
<TableCell>{hackathon.registered || 0}</TableCell>
369+
<TableCell>
370+
{hackathon.registered && hackathon.registered > 0 ? (
371+
<Link
372+
href={`/dashboard/company/${currentCompany.slug}/hackathons/${hackathon.slug}/registrations`}
373+
className="text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 font-medium hover:underline"
374+
>
375+
{hackathon.registered}
376+
</Link>
377+
) : (
378+
<span className="text-gray-500">0</span>
379+
)}
380+
</TableCell>
350381
{canManageEvents ? (
351382
<TableCell>
352383
<div className="flex items-center gap-2">

0 commit comments

Comments
 (0)