-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathpage.tsx
144 lines (129 loc) · 4.17 KB
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'use client';
import { format } from 'date-fns';
import React, { useState } from 'react';
import { FaChevronDown, FaChevronUp } from 'react-icons/fa';
import { Divider } from '@/components/ui';
import { useForumData } from '@/context/ForumDataContext';
import { renderContent } from '@/utils/quillUtils';
const AccordionItem: React.FC<any> = ({
title,
subText,
sessions,
isOpen,
onToggle,
}) => {
const formatTime = (time: string) => {
try {
return format(new Date(`1970-01-01T${time}Z`), 'p');
} catch (error) {
console.error(error);
return time;
}
};
return (
<div className="bg-gray-100 rounded-lg shadow-sm p-4 mb-4">
<div
className="flex justify-between items-center cursor-pointer"
onClick={onToggle}
>
<div>
<h2 className="text-lg font-bold">{title}</h2>
<div
className="text-sm text-gray-600"
dangerouslySetInnerHTML={{ __html: renderContent(subText) }}
/>
</div>
<span>{isOpen ? <FaChevronUp /> : <FaChevronDown />}</span>
</div>
{isOpen && (
<div className="mt-4 pt-4">
{sessions?.map((item: any, index: any) => (
<div className="flex flex-col gap-4" key={index}>
<Divider className="bg-black p-0 m-0 h-[1px] w-full" />
<div className="grid grid-cols-12 gap-4 mb-4">
<div className="col-span-2 text-sm font-semibold">
{formatTime(item.start_time)}
</div>
<div className="col-span-10">
<h3 className="font-bold">{item.session_title}</h3>
<div
className="text-sm"
dangerouslySetInnerHTML={{
__html: renderContent(item.session_details),
}}
/>
</div>
</div>
</div>
))}
</div>
)}
</div>
);
};
// Page Component that renders Accordion Items
const Page = () => {
const data = useForumData();
const [openAccordion, setOpenAccordion] = useState<string | null>(null);
const handleToggle = (id: string) => {
setOpenAccordion(openAccordion === id ? null : id);
};
if (!data) {
return null;
}
return (
<div className=" px-4 lg:px-0 flex flex-col gap-6">
{/* Schedule Section */}
<div className="py-4">
<h2 className="text-2xl font-bold">Schedule</h2>
<div
dangerouslySetInnerHTML={{
__html: renderContent(data?.schedule_details),
}}
/>
</div>
{/* Programs Accordion */}
{data?.programs?.map((program: any) => (
<AccordionItem
key={program.id}
title={program.title}
subText={program.sub_text}
sessions={program.sessions}
isOpen={openAccordion === program.id}
onToggle={() => handleToggle(program.id)}
/>
))}
<Divider className="bg-black p-0 m-0 h-[1px] w-full" />
{/* Registration Section */}
<div>
<div className="flex flex-col md:flex-row md:space-x-8">
<div className="md:w-1/3 mb-4 md:mb-0">
<h2 className="text-2xl font-bold">Registration</h2>
</div>
<div
className="md:w-2/3 space-y-4"
dangerouslySetInnerHTML={{
__html: renderContent(data?.registration_details),
}}
/>
</div>
</div>
<Divider className="bg-black p-0 m-0 h-[1px] w-full" />
{/* Sponsorship Section */}
<div>
<div className="flex flex-col md:flex-row md:space-x-8">
<div className="md:w-1/3 mb-4 md:mb-0">
<h2 className="text-2xl font-bold">Sponsorship opportunities</h2>
</div>
<div
className="md:w-2/3 space-y-4"
dangerouslySetInnerHTML={{
__html: renderContent(data?.sponsorship_opportunities_schedule),
}}
/>
</div>
</div>
</div>
);
};
export default Page;