PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 All 203 releases
betterdocs / react-src / admin / faq-builder / components / SearchedCategoryList.js

SearchedCategoryList.js in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.5, at react-src/admin/faq-builder/components/SearchedCategoryList.js

83 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useEffect, useState } from "react";
2 import SearchedCategory from "./SearchedCategory";
3
4 const SearchedCategoryList = ({
5 isLoading,
6 categoriesLoading,
7 allFaqCategories,
8 reFetchCategories,
9 setUpdateCategory,
10 setShowFaqAIModalForm,
11 }) => {
12 const [createFaqAt, setCreateFaqAt] = useState(null);
13 const [faqExpanded, setFaqExpanded] = useState(undefined);
14 const [categoryExpanded, setCategoryExpanded] = useState(undefined);
15 const [sortableCategories, setSortableCategories] = useState([]);
16 const [changeFaqSort, setChangeFaqSort] = useState({});
17 const [reFetchFaqForCategory, setReFetchFaqForCategory] = useState(null);
18
19 useEffect(() => {
20 if (allFaqCategories?.length) {
21 const sorted = allFaqCategories.sort(function (a, b) {
22 return a?.meta?.order[0] - b?.meta?.order[0];
23 });
24 setSortableCategories(sorted, 33);
25 // Auto-open the first matched group after a search so the matching
26 // FAQs are visible without an extra click.
27 setCategoryExpanded(sorted[0]?.term_id);
28 } else {
29 setSortableCategories([]);
30 setCategoryExpanded(undefined);
31 }
32 }, [allFaqCategories]);
33
34 return (
35 <>
36 {!isLoading ? (
37 <div className="bd-faq-ctg-list">
38 <div className="bd-faq-ctg-list-droppable">
39 {!categoriesLoading
40 ? sortableCategories?.map((category, index) => {
41 return (
42 <SearchedCategory
43 key={category?.term_id}
44 index={index}
45 category={category}
46 categoriesLoading={categoriesLoading}
47 allFaqCategories={allFaqCategories}
48 reFetchCategories={reFetchCategories}
49 createFaqAt={createFaqAt}
50 setUpdateCategory={setUpdateCategory}
51 categoryExpanded={categoryExpanded}
52 setCategoryExpanded={
53 setCategoryExpanded
54 }
55 setCreateFaqAt={setCreateFaqAt}
56 faqExpanded={faqExpanded}
57 setFaqExpanded={setFaqExpanded}
58 changeFaqSort={changeFaqSort}
59 setChangeFaqSort={setChangeFaqSort}
60 reFetchFaqForCategory={
61 reFetchFaqForCategory
62 }
63 setReFetchFaqForCategory={
64 setReFetchFaqForCategory
65 }
66 setShowFaqAIModalForm={
67 setShowFaqAIModalForm
68 }
69 />
70 );
71 })
72 : "loading"}
73 </div>
74 </div>
75 ) : (
76 ""
77 )}
78 </>
79 );
80 };
81
82 export default React.memo(SearchedCategoryList);
83