Skip to content

Commit 2b5210b

Browse files
authored
Merge pull request #323 from codeunia-dev/fix/companyfunctions
Fix/companyfunctions – Improve Company Analytics Functions & Stability**
2 parents 120ae39 + 2f871d1 commit 2b5210b

9 files changed

Lines changed: 321 additions & 120 deletions

File tree

README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
11
# 🌐 Codeunia
22

3-
*Codeunia* is a dynamic platform designed to empower developers by keeping them informed and inspired. Stay updated with the latest hackathons, AI breakthroughs, tech blogs, and developer tools — all in one place.
3+
*Codeunia* is a professional developer platform designed to power the modern tech ecosystem. We bring organizations, developers, and innovators together through a unified marketplace for hackathons, events, insights, and tools — all in one place.
44

5-
## 🚀 Features
5+
## 🚀 Platform Highlights
66

7-
- 🔍 Discover Upcoming Hackathons
8-
- 🧠 Latest News in Artificial Intelligence & Machine Learning
9-
- ✍ Developer-Focused Blog Posts
10-
- 📅 Event Calendar and Reminders
11-
- 🧰 Curated Tools and Resources for Developers *(Coming Soon)*
12-
- 📬 Newsletter Subscription *(Coming Soon)*
13-
- 📊 Community Polls and Discussions *(Coming Soon)*
7+
* 🏢 **Multi-Company Event Marketplace**
8+
Verified organizations can host, manage, and scale their own hackathons and tech events.
9+
10+
* 🔍 **Discover Global Hackathons**
11+
Stay updated with curated events from top companies and institutions.
12+
13+
* 🧠 **Tech & AI Insights**
14+
Access the latest breakthroughs in AI, ML, startups, and software engineering.
15+
16+
***Developer Articles & Blogs**
17+
In-depth writeups from experts, engineers, and industry contributors.
18+
19+
* 📅 **Smart Event Calendar & Reminders**
20+
Never miss an opportunity — get personalized updates and alerts.
21+
22+
* 🎯 **Organization Dashboards**
23+
Complete event lifecycle management: creation, moderation, registrations, analytics, and monetization.
24+
25+
* 📊 **Advanced Analytics for Hosts**
26+
Real-time insights into views, clicks, conversions, and performance trends.
27+
28+
* 🧰 **Developer Tools & Resources** *(Coming Soon)*
29+
Curated utilities and productivity enhancers for engineering teams.
30+
31+
* 📬 **Tech Newsletter** *(Coming Soon)*
32+
Weekly insights for developers and organizations.
1433

1534
---
1635

17-
### ⚠️ Disclaimer
36+
## ⚠️ Intellectual Property Notice
37+
38+
Codeunia operates multiple GitHub organizations for structured development and deployment:
1839

19-
> We do have an official GitHub organization: [github.com/codeunia](https://github.com/codeunia).
20-
> However, due to being a student-led initiative and operating with limited resources (like funds for paid GitHub features), we are currently using [github.com/codeunia-dev](https://github.com/codeunia-dev) to manage our repositories and development.
40+
* **github.com/codeunia** — Official organization
41+
* **github.com/codeunia-dev** — Development & engineering projects
2142

22-
> **All code, assets, and content under both profiles are the intellectual property of Codeunia. Unauthorized use, reproduction, or redistribution is strictly prohibited without written permission.**
43+
**All source code, assets, and content under these organizations are the intellectual property of Codeunia.
44+
Unauthorized use, reproduction, or redistribution is strictly prohibited without prior written approval.**
2345

2446
---

SECURITY.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

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

Lines changed: 58 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -109,61 +109,67 @@ export default function EditEventPage() {
109109
}
110110

111111
return (
112-
<div className="space-y-6">
113-
{/* Header */}
114-
<div className="flex items-center justify-between">
115-
<div className="flex items-center gap-4">
116-
<Link href={`/dashboard/company/${companySlug}/events`}>
117-
<Button variant="outline" size="sm">
118-
<ArrowLeft className="h-4 w-4 mr-2" />
119-
Back to Events
120-
</Button>
121-
</Link>
122-
<div>
123-
<h1 className="text-3xl font-bold tracking-tight">Edit Event</h1>
124-
<p className="text-muted-foreground mt-1">
125-
Update your event details
126-
</p>
127-
</div>
112+
<div className="min-h-screen dark:bg-black dark:text-white">
113+
<div className="space-y-6">
114+
{/* Back Button */}
115+
<Link href={`/dashboard/company/${companySlug}/events`}>
116+
<Button variant="ghost" size="sm" className="gap-2">
117+
<ArrowLeft className="h-4 w-4" />
118+
Back to Events
119+
</Button>
120+
</Link>
121+
122+
{/* Header */}
123+
<div>
124+
<h1 className="text-3xl font-bold tracking-tight">Edit Event</h1>
125+
<p className="text-muted-foreground mt-1">
126+
Update your event details
127+
</p>
128128
</div>
129129

130-
{/* Delete Button */}
131-
<AlertDialog>
132-
<AlertDialogTrigger asChild>
133-
<Button variant="outline" className="text-red-600 border-red-600 hover:bg-red-50">
134-
<Trash2 className="h-4 w-4 mr-2" />
135-
Delete Event
136-
</Button>
137-
</AlertDialogTrigger>
138-
<AlertDialogContent>
139-
<AlertDialogHeader>
140-
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
141-
<AlertDialogDescription>
142-
This action cannot be undone. This will permanently delete the event
143-
&quot;{event.title}&quot; and all associated data.
144-
</AlertDialogDescription>
145-
</AlertDialogHeader>
146-
<AlertDialogFooter>
147-
<AlertDialogCancel>Cancel</AlertDialogCancel>
148-
<AlertDialogAction
149-
onClick={handleDelete}
150-
disabled={deleting}
151-
className="bg-red-600 hover:bg-red-700"
152-
>
153-
{deleting ? 'Deleting...' : 'Delete Event'}
154-
</AlertDialogAction>
155-
</AlertDialogFooter>
156-
</AlertDialogContent>
157-
</AlertDialog>
158-
</div>
130+
{/* Event Form */}
131+
<EventForm
132+
company={currentCompany}
133+
event={event}
134+
mode="edit"
135+
onSuccess={handleSuccess}
136+
/>
159137

160-
{/* Event Form */}
161-
<EventForm
162-
company={currentCompany}
163-
event={event}
164-
mode="edit"
165-
onSuccess={handleSuccess}
166-
/>
138+
{/* Delete Button at Bottom */}
139+
<div className="flex items-center justify-between pt-6 border-t dark:border-gray-800">
140+
<div className="text-sm text-muted-foreground">
141+
<p className="font-medium">Danger Zone</p>
142+
<p>Once you delete an event, there is no going back.</p>
143+
</div>
144+
<AlertDialog>
145+
<AlertDialogTrigger asChild>
146+
<Button variant="destructive">
147+
<Trash2 className="h-4 w-4 mr-2" />
148+
Delete Event
149+
</Button>
150+
</AlertDialogTrigger>
151+
<AlertDialogContent>
152+
<AlertDialogHeader>
153+
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
154+
<AlertDialogDescription>
155+
This action cannot be undone. This will permanently delete the event
156+
&quot;{event.title}&quot; and all associated data.
157+
</AlertDialogDescription>
158+
</AlertDialogHeader>
159+
<AlertDialogFooter>
160+
<AlertDialogCancel>Cancel</AlertDialogCancel>
161+
<AlertDialogAction
162+
onClick={handleDelete}
163+
disabled={deleting}
164+
className="bg-red-600 hover:bg-red-700"
165+
>
166+
{deleting ? 'Deleting...' : 'Delete Event'}
167+
</AlertDialogAction>
168+
</AlertDialogFooter>
169+
</AlertDialogContent>
170+
</AlertDialog>
171+
</div>
172+
</div>
167173
</div>
168174
)
169175
}

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

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,28 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
77
import { Badge } from '@/components/ui/badge'
88
import { Input } from '@/components/ui/input'
99
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
10-
import { Calendar, Search, Plus, Edit, Eye, Clock, CheckCircle, XCircle, AlertCircle } from 'lucide-react'
10+
import { Calendar, Search, Plus, Edit, Eye, Clock, CheckCircle, XCircle, AlertCircle, Trash2 } from 'lucide-react'
1111
import { toast } from 'sonner'
1212
import Link from 'next/link'
1313
import { Event } from '@/types/events'
14+
import {
15+
AlertDialog,
16+
AlertDialogAction,
17+
AlertDialogCancel,
18+
AlertDialogContent,
19+
AlertDialogDescription,
20+
AlertDialogFooter,
21+
AlertDialogHeader,
22+
AlertDialogTitle,
23+
AlertDialogTrigger,
24+
} from '@/components/ui/alert-dialog'
1425

1526
export default function CompanyEventsPage() {
1627
const { currentCompany, loading: companyLoading } = useCompanyContext()
1728
const [events, setEvents] = useState<Event[]>([])
1829
const [loading, setLoading] = useState(true)
1930
const [searchTerm, setSearchTerm] = useState('')
31+
const [deletingEventSlug, setDeletingEventSlug] = useState<string | null>(null)
2032

2133
const fetchEvents = useCallback(async () => {
2234
if (!currentCompany) return
@@ -51,6 +63,30 @@ export default function CompanyEventsPage() {
5163
event.category.toLowerCase().includes(searchTerm.toLowerCase())
5264
)
5365

66+
const handleDeleteEvent = async (eventSlug: string) => {
67+
try {
68+
setDeletingEventSlug(eventSlug)
69+
70+
const response = await fetch(`/api/events/${eventSlug}`, {
71+
method: 'DELETE',
72+
})
73+
74+
if (!response.ok) {
75+
throw new Error('Failed to delete event')
76+
}
77+
78+
toast.success('Event deleted successfully')
79+
80+
// Refresh the events list
81+
await fetchEvents()
82+
} catch (error) {
83+
console.error('Error deleting event:', error)
84+
toast.error('Failed to delete event')
85+
} finally {
86+
setDeletingEventSlug(null)
87+
}
88+
}
89+
5490
const stats = {
5591
total: events.length,
5692
approved: events.filter(e => e.approval_status === 'approved').length,
@@ -276,6 +312,43 @@ export default function CompanyEventsPage() {
276312
</Button>
277313
</Link>
278314
)}
315+
<AlertDialog>
316+
<AlertDialogTrigger asChild>
317+
<Button
318+
variant="outline"
319+
size="sm"
320+
disabled={deletingEventSlug === event.slug}
321+
>
322+
{deletingEventSlug === event.slug ? (
323+
<div className="h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600" />
324+
) : (
325+
<Trash2 className="h-4 w-4 text-red-600" />
326+
)}
327+
</Button>
328+
</AlertDialogTrigger>
329+
<AlertDialogContent>
330+
<AlertDialogHeader>
331+
<AlertDialogTitle>Delete Event</AlertDialogTitle>
332+
<AlertDialogDescription>
333+
Are you sure you want to delete &quot;{event.title}&quot;? This action cannot be undone.
334+
{event.registered && event.registered > 0 && (
335+
<span className="block mt-2 text-red-600 font-medium">
336+
Warning: This event has {event.registered} registered participant{event.registered > 1 ? 's' : ''}.
337+
</span>
338+
)}
339+
</AlertDialogDescription>
340+
</AlertDialogHeader>
341+
<AlertDialogFooter>
342+
<AlertDialogCancel>Cancel</AlertDialogCancel>
343+
<AlertDialogAction
344+
onClick={() => handleDeleteEvent(event.slug)}
345+
className="bg-red-600 hover:bg-red-700"
346+
>
347+
Delete
348+
</AlertDialogAction>
349+
</AlertDialogFooter>
350+
</AlertDialogContent>
351+
</AlertDialog>
279352
</div>
280353
</TableCell>
281354
</TableRow>

0 commit comments

Comments
 (0)