Skip to content

Commit c467cad

Browse files
committed
feat(company-dashboard): Add hackathon support and improve status display
- Add Trophy icon import for hackathon representation - Implement strict typing for approval_status with union type ('draft' | 'pending' | 'approved' | 'rejected' | 'changes_requested') - Refactor getStatusBadge function to accept full hackathon object and display approval status when not approved - Update status badge logic to show event status only for approved hackathons, approval status otherwise - Add Total Hackathons stats card to dashboard with orange Trophy icon - Expand quick actions grid from 3 to 4 columns on large screens to accommodate new Create Hackathon button - Add Create Hackathon quick action button alongside Create Event for event managers - Replace generic Plus icon with Calendar icon for Create Event button for better visual distinction
1 parent 4d64cec commit c467cad

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface Hackathon {
2929
excerpt: string
3030
category: string
3131
status: string
32-
approval_status: string
32+
approval_status: 'draft' | 'pending' | 'approved' | 'rejected' | 'changes_requested'
3333
date: string
3434
time: string
3535
duration: string
@@ -167,8 +167,25 @@ export default function CompanyHackathonsPage() {
167167
}
168168
}
169169

170-
const getStatusBadge = (status: string) => {
171-
switch (status) {
170+
const getStatusBadge = (hackathon: Hackathon) => {
171+
// If not approved, show approval status instead of event status
172+
if (hackathon.approval_status !== 'approved') {
173+
switch (hackathon.approval_status) {
174+
case 'pending':
175+
return <Badge className="bg-yellow-500/10 text-yellow-600 border-yellow-500/20">Pending Review</Badge>
176+
case 'draft':
177+
return <Badge variant="outline">Draft</Badge>
178+
case 'rejected':
179+
return <Badge className="bg-red-500/10 text-red-600 border-red-500/20">Rejected</Badge>
180+
case 'changes_requested':
181+
return <Badge className="bg-orange-500/10 text-orange-600 border-orange-500/20">Changes Requested</Badge>
182+
default:
183+
return <Badge variant="outline">{hackathon.approval_status}</Badge>
184+
}
185+
}
186+
187+
// If approved, show event status
188+
switch (hackathon.status) {
172189
case 'live':
173190
case 'published':
174191
return <Badge className="bg-blue-500/10 text-blue-600 border-blue-500/20">Live</Badge>
@@ -179,7 +196,7 @@ export default function CompanyHackathonsPage() {
179196
case 'completed':
180197
return <Badge variant="outline" className="text-gray-500">Completed</Badge>
181198
default:
182-
return <Badge variant="outline">{status}</Badge>
199+
return <Badge variant="outline">{hackathon.status}</Badge>
183200
}
184201
}
185202

@@ -321,7 +338,7 @@ export default function CompanyHackathonsPage() {
321338
<TableCell>
322339
<Badge variant="outline">{hackathon.category || 'General'}</Badge>
323340
</TableCell>
324-
<TableCell>{getStatusBadge(hackathon.status)}</TableCell>
341+
<TableCell>{getStatusBadge(hackathon)}</TableCell>
325342
<TableCell>{getApprovalBadge(hackathon.approval_status)}</TableCell>
326343
<TableCell>
327344
<div className="flex items-center gap-1">

components/dashboard/CompanyDashboard.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
ArrowDownRight,
2020
Activity,
2121
FileText,
22+
Trophy,
2223
} from 'lucide-react'
2324
import { Company } from '@/types/company'
2425
import { format, formatDistanceToNow } from 'date-fns'
@@ -229,7 +230,7 @@ export function CompanyDashboard({ company }: CompanyDashboardProps) {
229230
return (
230231
<div className="space-y-6">
231232
{/* Stats Cards */}
232-
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
233+
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-5">
233234
<StatsCard
234235
title="Total Events"
235236
value={stats.totalEvents}
@@ -238,6 +239,13 @@ export function CompanyDashboard({ company }: CompanyDashboardProps) {
238239
description="Events hosted"
239240
change={stats.recentChange?.events}
240241
/>
242+
<StatsCard
243+
title="Total Hackathons"
244+
value={stats.totalHackathons}
245+
icon={Trophy}
246+
iconColor="text-orange-400"
247+
description="Hackathons hosted"
248+
/>
241249
<StatsCard
242250
title="Total Views"
243251
value={stats.totalViews}
@@ -347,14 +355,22 @@ export function CompanyDashboard({ company }: CompanyDashboardProps) {
347355
<CardDescription>Common tasks and shortcuts</CardDescription>
348356
</CardHeader>
349357
<CardContent>
350-
<div className="grid gap-4 md:grid-cols-3">
358+
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
351359
{canManageEvents && (
352-
<QuickActionButton
353-
href={`/dashboard/company/${company.slug}/events/create`}
354-
icon={Plus}
355-
title="Create Event"
356-
description="Host a new event"
357-
/>
360+
<>
361+
<QuickActionButton
362+
href={`/dashboard/company/${company.slug}/events/create`}
363+
icon={Calendar}
364+
title="Create Event"
365+
description="Host a new event"
366+
/>
367+
<QuickActionButton
368+
href={`/dashboard/company/${company.slug}/hackathons/create`}
369+
icon={Trophy}
370+
title="Create Hackathon"
371+
description="Launch a coding challenge"
372+
/>
373+
</>
358374
)}
359375
{canManageTeam && (
360376
<QuickActionButton

0 commit comments

Comments
 (0)