summaryrefslogtreecommitdiff
path: root/src2/pages/faqs.js
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-03-01 09:18:52 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-03-01 09:18:52 +0000
commita7abbf4ddc70068620e9f44b74dc162ce2e16ee2 (patch)
tree74f66253717515d364ce74bd8275015c1f829cbc /src2/pages/faqs.js
parent90e1edab9b6a8ccc09a49fed3addbec2cbc4e4c3 (diff)
parenta1b9b647a6c4bda1f5db63879639d44543f9557e (diff)
Merged in refactor (pull request #1)
Refactor
Diffstat (limited to 'src2/pages/faqs.js')
-rw-r--r--src2/pages/faqs.js91
1 files changed, 91 insertions, 0 deletions
diff --git a/src2/pages/faqs.js b/src2/pages/faqs.js
new file mode 100644
index 00000000..cdb8ef52
--- /dev/null
+++ b/src2/pages/faqs.js
@@ -0,0 +1,91 @@
+import AppBar from "@/components/layouts/AppBar";
+import Layout from "@/components/layouts/Layout";
+import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline";
+import { useEffect, useState } from "react";
+
+const dataFaqs = [
+ {
+ id: 1,
+ name: 'Akun',
+ description: 'Bantuan tentang pengelolaan fitur dan akun'
+ },
+ {
+ id: 2,
+ name: 'Pembelian',
+ description: 'Bantuan seputar status stock, layanan pengiriman & asuransi hingga seluruh indonesia'
+ },
+ {
+ id: 3,
+ name: 'Metode Pembayaran',
+ description: 'Bantuan terkait layanan metode pembayaran'
+ },
+ {
+ id: 4,
+ name: 'Quotation',
+ description: 'Bantuan fitur RFQ & quotation Express'
+ },
+ {
+ id: 5,
+ name: 'Faktur Pajak & Invoice',
+ description: 'Bantuan seputar layanan terbit faktur pajak & invoice'
+ },
+ {
+ id: 6,
+ name: 'Pengembalian & Garansi',
+ description: 'Bantuan cara pengembalian produk & garansi produk'
+ }
+];
+
+export default function Faqs() {
+ const [ faqs, setFaqs ] = useState([]);
+
+ useEffect(() => {
+ if (faqs.length == 0) {
+ setFaqs(dataFaqs.map((dataFaq) => ({
+ ...dataFaq,
+ isOpen: false
+ })));
+ }
+ }, [ faqs ]);
+
+ const toggleFaq = (id) => {
+ const faqsToUpdate = faqs.map(faq => {
+ if (faq.id == id) faq.isOpen = !faq.isOpen;
+ return faq;
+ });
+ setFaqs(faqsToUpdate);
+ };
+
+ return (
+ <Layout>
+ <AppBar title="FAQ's" />
+
+ <div className="divide-y divide-gray_r-6">
+ { faqs.map((faq, index) => (
+ <div className="p-4" key={index}>
+ <div className="flex gap-x-3 items-center">
+ <div className="flex-1">
+ <p className="font-medium mb-1">{ faq.name }</p>
+ <p className="text-caption-1 text-gray_r-11">
+ { faq.description }
+ </p>
+ </div>
+ <button type="button" className="p-2 rounded bg-gray_r-4 h-fit" onClick={() => toggleFaq(faq.id)}>
+ { faq.isOpen ? (
+ <ChevronUpIcon className="w-5"/>
+ ) : (
+ <ChevronDownIcon className="w-5"/>
+ ) }
+ </button>
+ </div>
+ { faq.isOpen && (
+ <p className="text-caption-1 text-gray_r-11 leading-7 mt-4">
+ { faq?.content || 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.' }
+ </p>
+ ) }
+ </div>
+ )) }
+ </div>
+ </Layout>
+ )
+} \ No newline at end of file