Skip to content

Commit 207299c

Browse files
committed
faqs updated
1 parent 5c4eda2 commit 207299c

File tree

1 file changed

+55
-12
lines changed

1 file changed

+55
-12
lines changed

src/components/Faqs.tsx

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,66 @@
1-
import { FaChevronRight } from "react-icons/fa";
1+
import { useState } from "react";
2+
import { FaChevronRight, FaChevronDown } from "react-icons/fa";
3+
4+
interface Faq {
5+
question: string;
6+
answer: string;
7+
}
8+
9+
const Faqs: React.FC = () => {
10+
const [activeIndex, setActiveIndex] = useState<number | null>(null);
11+
12+
const faqs: Faq[] = [
13+
{
14+
question: "What does Renergy Hub offer?",
15+
answer: "Renergy Hub offers innovative and sustainable energy solutions for homes, businesses, and communities.",
16+
},
17+
{
18+
question: "What are the benefits of Renergy Hub products?",
19+
answer: "They provide reliable, eco-friendly energy, reduce utility costs, and support a sustainable future.",
20+
},
21+
{
22+
question: "How do I install Renergy Hub products?",
23+
answer: "Installation is simple and handled by certified professionals or guided by clear user instructions.",
24+
},
25+
{
26+
question: "How often should I inspect Renergy Hub products?",
27+
answer: "Regular inspections every 6–12 months are recommended to ensure optimal performance.",
28+
},
29+
{
30+
question: "How can I purchase the Renergy Hub products?",
31+
answer: "Products can be purchased directly from our website or through authorized distributors.",
32+
},
33+
];
34+
35+
const toggleAnswer = (index: number): void => {
36+
setActiveIndex(activeIndex === index ? null : index);
37+
};
238

3-
const Faqs = () => {
439
return (
540
<div className="flex flex-col px-4 py-8 md:px-8 lg:px-32">
641
<h2 className="text-2xl font-bold mb-6">FAQs</h2>
742
<div className="w-full space-y-4">
8-
{[
9-
"What does Renergy Hub offer?",
10-
"What are the benefits of Renergy Hub products?",
11-
"How do I install Renergy Hub products?",
12-
"How often should I inspect Renergy Hub products?",
13-
"How can I purchase the Renergy Hub products?",
14-
].map((question, index) => (
43+
{faqs.map((faq, index) => (
1544
<div
1645
key={index}
17-
className="flex items-center justify-between p-4 border border-gray-300 rounded-lg hover:shadow-md transition-shadow cursor-pointer"
46+
className="border border-gray-300 rounded-lg hover:shadow-md transition-shadow"
1847
>
19-
<p className="text-gray-700 cursor-pointer">{question}</p>
20-
<FaChevronRight className="text-gray-500" />
48+
<div
49+
className="flex items-center justify-between p-4 cursor-pointer"
50+
onClick={() => toggleAnswer(index)}
51+
>
52+
<p className="text-gray-700">{faq.question}</p>
53+
{activeIndex === index ? (
54+
<FaChevronDown className="text-gray-500" />
55+
) : (
56+
<FaChevronRight className="text-gray-500" />
57+
)}
58+
</div>
59+
{activeIndex === index && (
60+
<div className="p-4 text-gray-600 bg-green-50">
61+
{faq.answer}
62+
</div>
63+
)}
2164
</div>
2265
))}
2366
</div>

0 commit comments

Comments
 (0)