Skip to content

Commit 37b3cab

Browse files
committed
feat: Add total views and registrations statistics to the company event dashboard and refine the stats card layout.
1 parent 328957b commit 37b3cab

File tree

1 file changed

+36
-16
lines changed
  • app/dashboard/company/[slug]/events

1 file changed

+36
-16
lines changed

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

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default function CompanyEventsPage() {
4141
setLoading(true)
4242
// Fetch all events (not just approved) for company members
4343
const response = await fetch(`/api/companies/${currentCompany.slug}/events?status=all&limit=100`)
44-
44+
4545
if (!response.ok) {
4646
throw new Error('Failed to fetch events')
4747
}
@@ -78,7 +78,7 @@ export default function CompanyEventsPage() {
7878
const handleDeleteEvent = async (eventSlug: string) => {
7979
try {
8080
setDeletingEventSlug(eventSlug)
81-
81+
8282
const response = await fetch(`/api/events/${eventSlug}`, {
8383
method: 'DELETE',
8484
})
@@ -88,7 +88,7 @@ export default function CompanyEventsPage() {
8888
}
8989

9090
toast.success('Event deleted successfully')
91-
91+
9292
// Refresh the events list
9393
await fetchEvents()
9494
} catch (error) {
@@ -104,56 +104,58 @@ export default function CompanyEventsPage() {
104104
approved: events.filter(e => e.approval_status === 'approved').length,
105105
pending: events.filter(e => e.approval_status === 'pending').length,
106106
draft: events.filter(e => e.status === 'draft').length,
107+
totalViews: events.reduce((sum, e) => sum + (e.views || 0), 0),
108+
totalRegistrations: events.reduce((sum, e) => sum + (e.registered || 0), 0),
107109
}
108110

109111
const getApprovalBadge = (status: string) => {
110112
switch (status) {
111113
case 'approved':
112114
return (
113-
<Badge className="bg-green-500/10 text-green-600 border-green-500/20">
115+
<Badge className="bg-green-500/10 text-green-600 border-green-500/20 pointer-events-none">
114116
<CheckCircle className="h-3 w-3 mr-1" />
115117
Approved
116118
</Badge>
117119
)
118120
case 'pending':
119121
return (
120-
<Badge className="bg-yellow-500/10 text-yellow-600 border-yellow-500/20">
122+
<Badge className="bg-yellow-500/10 text-yellow-600 border-yellow-500/20 pointer-events-none">
121123
<Clock className="h-3 w-3 mr-1" />
122124
Pending
123125
</Badge>
124126
)
125127
case 'rejected':
126128
return (
127-
<Badge className="bg-red-500/10 text-red-600 border-red-500/20">
129+
<Badge className="bg-red-500/10 text-red-600 border-red-500/20 pointer-events-none">
128130
<XCircle className="h-3 w-3 mr-1" />
129131
Rejected
130132
</Badge>
131133
)
132134
case 'changes_requested':
133135
return (
134-
<Badge className="bg-orange-500/10 text-orange-600 border-orange-500/20">
136+
<Badge className="bg-orange-500/10 text-orange-600 border-orange-500/20 pointer-events-none">
135137
<AlertCircle className="h-3 w-3 mr-1" />
136138
Changes Requested
137139
</Badge>
138140
)
139141
default:
140-
return <Badge variant="outline">{status}</Badge>
142+
return <Badge variant="outline" className="pointer-events-none">{status}</Badge>
141143
}
142144
}
143145

144146
const getStatusBadge = (status: string) => {
145147
switch (status) {
146148
case 'live':
147149
case 'published':
148-
return <Badge className="bg-blue-500/10 text-blue-600 border-blue-500/20">Live</Badge>
150+
return <Badge className="bg-blue-500/10 text-blue-600 border-blue-500/20 pointer-events-none">Live</Badge>
149151
case 'draft':
150-
return <Badge variant="outline">Draft</Badge>
152+
return <Badge variant="outline" className="pointer-events-none">Draft</Badge>
151153
case 'cancelled':
152-
return <Badge variant="outline" className="text-gray-500">Cancelled</Badge>
154+
return <Badge variant="outline" className="text-gray-500 pointer-events-none">Cancelled</Badge>
153155
case 'completed':
154-
return <Badge variant="outline" className="text-gray-500">Completed</Badge>
156+
return <Badge variant="outline" className="text-gray-500 pointer-events-none">Completed</Badge>
155157
default:
156-
return <Badge variant="outline">{status}</Badge>
158+
return <Badge variant="outline" className="pointer-events-none">{status}</Badge>
157159
}
158160
}
159161

@@ -186,7 +188,7 @@ export default function CompanyEventsPage() {
186188
</div>
187189

188190
{/* Stats Cards */}
189-
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
191+
<div className="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-6 gap-4">
190192
<Card>
191193
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
192194
<CardTitle className="text-sm font-medium">Total Events</CardTitle>
@@ -223,6 +225,24 @@ export default function CompanyEventsPage() {
223225
<div className="text-2xl font-bold">{stats.draft}</div>
224226
</CardContent>
225227
</Card>
228+
<Card>
229+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
230+
<CardTitle className="text-sm font-medium">Total Views</CardTitle>
231+
<Eye className="h-4 w-4 text-blue-600" />
232+
</CardHeader>
233+
<CardContent>
234+
<div className="text-2xl font-bold text-blue-600">{stats.totalViews}</div>
235+
</CardContent>
236+
</Card>
237+
<Card>
238+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
239+
<CardTitle className="text-sm font-medium">Total Registrations</CardTitle>
240+
<CheckCircle className="h-4 w-4 text-purple-600" />
241+
</CardHeader>
242+
<CardContent>
243+
<div className="text-2xl font-bold text-purple-600">{stats.totalRegistrations}</div>
244+
</CardContent>
245+
</Card>
226246
</div>
227247

228248
{/* Search */}
@@ -329,8 +349,8 @@ export default function CompanyEventsPage() {
329349
)}
330350
<AlertDialog>
331351
<AlertDialogTrigger asChild>
332-
<Button
333-
variant="outline"
352+
<Button
353+
variant="outline"
334354
size="sm"
335355
disabled={deletingEventSlug === event.slug}
336356
>

0 commit comments

Comments
 (0)