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 / woocommerce / ProductFaqGroups.js

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

41 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { useEffect } from "react";
2 import { FAQProvider, useFAQ } from "../../components/FAQContext";
3 import { FAQScopeProvider, PRODUCT_TAXONOMY } from "../context/ScopeContext";
4 import BetterDocsFaqRoot from "../components/index";
5
6 // Fired by the header "Create a New Product FAQ Group" button after a group is
7 // created; the header sits outside this nested provider, so a window event is
8 // how it asks the product list to refresh.
9 export const PRODUCT_FAQ_REFRESH_EVENT = "betterdocs:product-faq-refresh";
10
11 // Bridges the header's refresh event to the nested provider's refetch.
12 const ProductGroupsRefresher = () => {
13 const { reFetchCategories } = useFAQ();
14
15 useEffect(() => {
16 const handler = () => reFetchCategories?.();
17 window.addEventListener(PRODUCT_FAQ_REFRESH_EVENT, handler);
18 return () =>
19 window.removeEventListener(PRODUCT_FAQ_REFRESH_EVENT, handler);
20 }, [reFetchCategories]);
21
22 return null;
23 };
24
25 // A nested FAQProvider isolates the Product scope's category/stat state from the
26 // General tab's shared provider, so switching tabs never bleeds one list into
27 // the other. The "Create a New Product FAQ Group" button lives in the page
28 // header (see CreateProductFAQGroup), matching the General tab's layout.
29 const ProductFaqGroups = () => {
30 return (
31 <FAQProvider>
32 <FAQScopeProvider taxonomy={PRODUCT_TAXONOMY}>
33 <ProductGroupsRefresher />
34 <BetterDocsFaqRoot />
35 </FAQScopeProvider>
36 </FAQProvider>
37 );
38 };
39
40 export default ProductFaqGroups;
41