Skip to content

Commit 4db34cb

Browse files
authored
Merge pull request #86 from codeunia-dev/refactor/adminhack
Refactor HackathonDetailPage: Update schedule and FAQ rendering
2 parents 01f484c + 0b4e05b commit 4db34cb

File tree

2 files changed

+50
-38
lines changed

2 files changed

+50
-38
lines changed

app/hackathons/[id]/page.tsx

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,32 @@ export default function HackathonDetailPage() {
158158
</div>
159159
)
160160

161-
const renderSchedule = () => (
162-
<div className="space-y-6">
163-
<div className="bg-background/50 backdrop-blur-sm p-8 rounded-2xl border border-primary/10 shadow-xl">
164-
<h2 className="text-2xl font-bold mb-4 flex items-center gap-2">
165-
<Clock className="h-6 w-6 text-primary" />
166-
Hackathon Schedule
167-
</h2>
168-
<ul className="divide-y divide-primary/10">
169-
{hackathon?.schedule?.map((item: { date: string, label: string }) => (
170-
<li key={item.date} className="py-3 flex flex-col md:flex-row md:items-center md:gap-4">
171-
<span className="font-medium min-w-[120px] text-primary">{item.date}</span>
172-
<span className="text-muted-foreground">{item.label}</span>
173-
</li>
174-
))}
175-
</ul>
161+
const renderSchedule = () => {
162+
let scheduleArray: { date: string, label: string }[] = [];
163+
if (Array.isArray(hackathon?.schedule)) {
164+
scheduleArray = hackathon.schedule;
165+
} else if (hackathon?.schedule && typeof hackathon.schedule === 'object') {
166+
scheduleArray = Object.entries(hackathon.schedule).map(([date, label]) => ({ date, label: String(label) }));
167+
}
168+
return (
169+
<div className="space-y-6">
170+
<div className="bg-background/50 backdrop-blur-sm p-8 rounded-2xl border border-primary/10 shadow-xl">
171+
<h2 className="text-2xl font-bold mb-4 flex items-center gap-2">
172+
<Clock className="h-6 w-6 text-primary" />
173+
Hackathon Schedule
174+
</h2>
175+
<ul className="divide-y divide-primary/10">
176+
{scheduleArray.map((item) => (
177+
<li key={item.date} className="py-3 flex flex-col md:flex-row md:items-center md:gap-4">
178+
<span className="font-medium min-w-[120px] text-primary">{item.date}</span>
179+
<span className="text-muted-foreground">{item.label}</span>
180+
</li>
181+
))}
182+
</ul>
183+
</div>
176184
</div>
177-
</div>
178-
)
185+
);
186+
};
179187

180188
const renderPrizes = () => (
181189
<div className="space-y-6">
@@ -190,24 +198,32 @@ export default function HackathonDetailPage() {
190198
</div>
191199
)
192200

193-
const renderFAQ = () => (
194-
<div className="space-y-6">
195-
<div className="bg-background/50 backdrop-blur-sm p-8 rounded-2xl border border-primary/10 shadow-xl">
196-
<h2 className="text-2xl font-bold mb-4 flex items-center gap-2">
197-
<Sparkles className="h-6 w-6 text-primary" />
198-
Frequently Asked Questions
199-
</h2>
200-
<ul className="space-y-4">
201-
{hackathon?.faq?.map((q: { question: string, answer: string }) => (
202-
<li key={q.question}>
203-
<div className="font-semibold">{q.question}</div>
204-
<div className="text-muted-foreground">{q.answer}</div>
205-
</li>
206-
))}
207-
</ul>
201+
const renderFAQ = () => {
202+
let faqArray: { question: string, answer: string }[] = [];
203+
if (Array.isArray(hackathon?.faq)) {
204+
faqArray = hackathon.faq;
205+
} else if (hackathon?.faq && typeof hackathon.faq === 'object') {
206+
faqArray = Object.entries(hackathon.faq).map(([question, answer]) => ({ question, answer: String(answer) }));
207+
}
208+
return (
209+
<div className="space-y-6">
210+
<div className="bg-background/50 backdrop-blur-sm p-8 rounded-2xl border border-primary/10 shadow-xl">
211+
<h2 className="text-2xl font-bold mb-4 flex items-center gap-2">
212+
<Sparkles className="h-6 w-6 text-primary" />
213+
Frequently Asked Questions
214+
</h2>
215+
<ul className="space-y-4">
216+
{faqArray.map((q) => (
217+
<li key={q.question}>
218+
<div className="font-semibold">{q.question}</div>
219+
<div className="text-muted-foreground">{q.answer}</div>
220+
</li>
221+
))}
222+
</ul>
223+
</div>
208224
</div>
209-
</div>
210-
)
225+
);
226+
};
211227

212228
const hackathonTabs = [
213229
{

lib/services/hackathons.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ export interface Hackathon {
4343
prize_details?: string
4444
faq?: Record<string, unknown> | { question: string; answer: string }[]
4545
socials?: {
46-
email?: string
47-
website?: string
48-
twitter?: string
49-
discord?: string
5046
linkedin?: string
5147
whatsapp?: string
5248
instagram?: string

0 commit comments

Comments
 (0)