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 / dashboard / components / NoDocsBody.js

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

94 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from "react";
2 import { useState } from "@wordpress/element";
3 import { __ } from "@wordpress/i18n";
4 import { DocIllustration } from "../../sample-docs/icons";
5 import { AiBadge, GenerateBtn } from "../../sample-docs/Pieces";
6 import SampleDocsFlow from "../../sample-docs/SampleDocsFlow";
7 import { sampleDocsEnabled } from "../../sample-docs/api";
8
9 const NoDocsBody = ({ isDocs }) => {
10 const [text, setText] = useState(__("Generate Sample Docs", "betterdocs"));
11 const [flowOpen, setFlowOpen] = useState(false);
12 const aiEnabled = sampleDocsEnabled();
13
14 // Tier-3 fallback: the classic CSV "dummy data" import (used when AI is
15 // disabled, or as a manual fallback).
16 const createDummyData = async (e) => {
17 e.preventDefault();
18 setText(__("Generating...", "betterdocs"));
19 let response = await wp.apiFetch({
20 url: betterdocs_admin?.generate_data_url,
21 method: "POST",
22 data: {
23 action: "create-dummy-data",
24 _wpnonce: betterdocs_admin?.nonce,
25 },
26 });
27 if (response?.status == "success") {
28 setText(__("Generated Successfully", "betterdocs"));
29 window.location.reload();
30 } else {
31 setText(__("Generation Failed", "betterdocs"));
32 setTimeout(() => setText(__("Generate Sample Docs", "betterdocs")), 1000);
33 }
34 };
35
36 return (
37 <section className="betterdocs-dashboard-body">
38 <div className="betterdocs-no-docs-wrapper betterdocs-sd-empty-card">
39 <div className="betterdocs-no-docs-img-wrap">
40 <DocIllustration />
41 </div>
42
43 <div className="betterdocs-no-docs-content">
44 <h3 className="betterdocs-no-docs-title">
45 {__("No Category Found", "betterdocs")}
46 </h3>
47 <p className="betterdocs-no-docs-text">
48 {aiEnabled
49 ? __("Please create a new category to get started — or let AI build a starter knowledge base for you.", "betterdocs")
50 : __("Please create a new category to get started", "betterdocs")}
51 </p>
52
53 {!isDocs && (
54 <>
55 <div className="betterdocs-sd-empty-actions">
56 <a
57 href={`${betterdocs_admin.admin_url}admin.php?page=betterdocs-doc-categories&betterdocs_action=new-category`}
58 className="betterdocs-sd-create-btn"
59 >
60 {__("Create A New Category", "betterdocs")}
61 </a>
62
63 {aiEnabled ? (
64 <GenerateBtn block onClick={() => setFlowOpen(true)} />
65 ) : (
66 <a href="#" className="betterdocs-dashboard-btn" onClick={createDummyData}>
67 {text}
68 </a>
69 )}
70 </div>
71
72 {aiEnabled && (
73 <div className="betterdocs-sd-empty-badge">
74 <AiBadge />
75 </div>
76 )}
77 </>
78 )}
79 </div>
80 </div>
81
82 {flowOpen && (
83 <SampleDocsFlow
84 contentType="docs"
85 onClose={() => setFlowOpen(false)}
86 onComplete={() => window.location.reload()}
87 />
88 )}
89 </section>
90 );
91 };
92
93 export default NoDocsBody;
94