PageSourceSearch

https://blogbotz.com/build/assets/BlogBotzIntegration-DP4WO6C8.js

js blogbotz.com collected 2026-10-02 05:17:45 UTC 13,431 bytes, 1 lines download raw bytes

1import{r as t,a as i,j as e,A as U,l as J}from"./main-C2BHBFqc.js";const Q=({className:r})=>e.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244"})}),Z=({className:r})=>e.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),ee=({className:r})=>e.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.75 9.75l4.5 4.5m0-4.5l-4.5 4.5M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),se=({className:r})=>e.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})}),te=({className:r})=>e.jsx("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9.75v6.75m0 0l-3-3m3 3l3-3m-8.25 6a4.5 4.5 0 01-1.41-8.775 5.25 5.25 0 0110.233-2.33 3 3 0 013.758 3.848A3.752 3.752 0 0118 19.5H6.75z"})});function le(){var R,E,W,T;const[r,N]=t.useState(!0),[v,c]=t.useState(""),[w,x]=t.useState(""),[o,p]=t.useState(!1),[l,u]=t.useState(null),[m,B]=t.useState(null),[k,$]=t.useState([]),[C,q]=t.useState([]),[d,H]=t.useState("overview"),[S,y]=t.useState(!1),[g,_]=t.useState({api_key:"",api_secret:""}),[z,I]=t.useState(!1),[j,L]=t.useState(!1),[A,D]=t.useState(null),[O,b]=t.useState(!1);t.useEffect(()=>{F()},[]),t.useEffect(()=>{o&&(f(),d==="blogs"?M():d==="published"&&P())},[o,d]);const F=async()=>{try{N(!0);const s=await i.get("/admin/blogbotz/status");p(s.data.connected),u(s.data.connection)}catch{c("Failed to load BlogBotz status")}finally{N(!1)}},f=async()=>{try{const s=await i.get("/admin/blogbotz/stats");B(s.data)}catch(s){console.error("Failed to load stats",s)}},M=async()=>{try{const s=await i.get("/admin/blogbotz/blogs",{params:{status:"approved",per_page:20}});$(s.data.data||[])}catch(s){console.error("Failed to load blogs",s)}},P=async()=>{try{const s=await i.get("/admin/blogbotz/published-blogs");q(s.data.data||[])}catch(s){console.error("Failed to load published blogs",s)}},Y=async s=>{var a,n;s.preventDefault(),I(!0),c("");try{const h=await i.post("/admin/blogbotz/connect",g);x("Successfully connected to BlogBotz!"),p(!0),u(h.data.connection),y(!1),f()}catch(h){c(((n=(a=h.response)==null?void 0:a.data)==null?void 0:n.message)||"Failed to connect to BlogBotz")}finally{I(!1)}},K=()=>{b(!0)},V=async()=>{var s,a;b(!1);try{await i.post("/admin/blogbotz/disconnect"),x("Disconnected from BlogBotz"),p(!1),u(null),B(null)}catch(n){c(((a=(s=n.response)==null?void 0:s.data)==null?void 0:a.message)||"Failed to disconnect")}},X=async()=>{var s,a;L(!0);try{await i.post("/admin/blogbotz/sync"),x("Synced with BlogBotz"),F(),f()}catch(n){c(((a=(s=n.response)==null?void 0:s.data)==null?void 0:a.message)||"Failed to sync")}finally{L(!1)}},G=async s=>{var a,n;D(s);try{await i.post("/admin/blogbotz/blogs/import",{blog_id:s}),x("Blog imported successfully! Check the Blog Posts section."),M(),P()}catch(h){c(((n=(a=h.response)==null?void 0:a.data)==null?void 0:n.message)||"Failed to import blog")}finally{D(null)}};return r?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-red-600"})}):e.jsxs("div",{className:"space-y-6",children:[v&&e.jsx(U,{type:"error",message:v,onClose:()=>c("")}),w&&e.jsx(U,{type:"success",message:w,onClose:()=>x("")}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"BlogBotz Integration"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Connect to BlogBotz to automatically import AI-generated blog posts"})]}),o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:X,disabled:j,className:"inline-flex items-center px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 disabled:opacity-50",children:[e.jsx(se,{className:`w-4 h-4 mr-2 ${j?"animate-spin":""}`}),j?"Syncing...":"Sync"]}),e.jsx("button",{onClick:K,className:"px-4 py-2 border border-red-300 text-red-600 rounded-lg hover:bg-red-50",children:"Disconnect"})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-8 h-8 text-green-500 mr-3"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Connected to BlogBotz"}),e.jsxs("p",{className:"text-sm text-gray-500",children:[l==null?void 0:l.site_name," - ",l==null?void 0:l.api_key]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-8 h-8 text-gray-400 mr-3"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Not Connected"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Connect your BlogBotz account to start importing blogs"})]})]})}),!o&&!S&&e.jsxs("button",{onClick:()=>y(!0),className:"inline-flex items-center px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700",children:[e.jsx(Q,{className:"w-4 h-4 mr-2"}),"Connect"]})]}),S&&!o&&e.jsxs("form",{onSubmit:Y,className:"mt-6 border-t pt-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"API Key"}),e.jsx("input",{type:"text",value:g.api_key,onChange:s=>_({...g,api_key:s.target.value}),placeholder:"bbk_your_api_key",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"API Secret"}),e.jsx("input",{type:"password",value:g.api_secret,onChange:s=>_({...g,api_secret:s.target.value}),placeholder:"Your API secret",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500",required:!0})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{type:"submit",disabled:z,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50",children:z?"Connecting...":"Connect"}),e.jsx("button",{type:"button",onClick:()=>y(!1),className:"px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50",children:"Cancel"})]}),e.jsx("p",{className:"mt-3 text-sm text-gray-500",children:"Enter your API credentials from a BlogBotz site's Automation Settings page. Site details will be retrieved automatically."})]}),o&&l&&e.jsx("div",{className:"mt-6 border-t pt-6",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Site ID"}),e.jsx("p",{className:"font-medium",children:l.site_id||"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Credits Remaining"}),e.jsx("p",{className:"font-medium",children:l.credits_remaining??"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Connected At"}),e.jsx("p",{className:"font-medium",children:l.connected_at?new Date(l.connected_at).toLocaleDateString():"N/A"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Last Synced"}),e.jsx("p",{className:"font-medium",children:l.last_synced_at?new Date(l.last_synced_at).toLocaleStr
1ing():"Never"})]})]})})]}),o&&e.jsxs(e.Fragment,{children:[m&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white rounded-lg shadow p-4",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Imported Blogs"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:((R=m.local)==null?void 0:R.imported_blogs)||0})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-4",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Published"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:((E=m.local)==null?void 0:E.published_blogs)||0})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-4",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Pending"}),e.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:((W=m.local)==null?void 0:W.pending_blogs)||0})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-4",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Failed"}),e.jsx("p",{className:"text-2xl font-bold text-red-600",children:((T=m.local)==null?void 0:T.failed_blogs)||0})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow",children:[e.jsx("div",{className:"border-b",children:e.jsx("nav",{className:"flex -mb-px",children:["overview","blogs","published"].map(s=>e.jsxs("button",{onClick:()=>H(s),className:`px-6 py-3 text-sm font-medium border-b-2 ${d===s?"border-red-500 text-red-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[s==="overview"&&"Overview",s==="blogs"&&"Available Blogs",s==="published"&&"Imported Blogs"]},s))})}),e.jsxs("div",{className:"p-6",children:[d==="overview"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-medium text-gray-900",children:"How it works"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-gray-600",children:[e.jsx("li",{children:"BlogBotz generates AI blog posts based on your topics and keywords"}),e.jsx("li",{children:'Approved blogs appear in the "Available Blogs" tab'}),e.jsx("li",{children:"Import blogs to your website with one click"}),e.jsx("li",{children:"Review and publish imported blogs from the Blog Posts section"})]}),e.jsxs("div",{className:"mt-6 p-4 bg-gray-50 rounded-lg",children:[e.jsx("h4",{className:"font-medium text-gray-900 mb-2",children:"Webhook URL"}),e.jsxs("code",{className:"text-sm bg-gray-100 px-2 py-1 rounded",children:[window.location.origin,"/api/webhooks/blogbotz"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Configure this URL in your BlogBotz settings to receive automatic updates."})]})]}),d==="blogs"&&e.jsx("div",{children:k.length===0?e.jsx("p",{className:"text-gray-500 text-center py-8",children:"No approved blogs available for import"}):e.jsx("div",{className:"space-y-4",children:k.map(s=>{var a;return e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900",children:s.title}),e.jsxs("p",{className:"text-sm text-gray-500",children:[(a=s.topic)==null?void 0:a.name," - ",new Date(s.created_at).toLocaleDateString()]})]}),e.jsxs("button",{onClick:()=>G(s.id),disabled:A===s.id,className:"inline-flex items-center px-3 py-1.5 bg-red-600 text-white text-sm rounded-lg hover:bg-red-700 disabled:opacity-50",children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),A===s.id?"Importing...":"Import"]})]},s.id)})})}),d==="published"&&e.jsx("div",{children:C.length===0?e.jsx("p",{className:"text-gray-500 text-center py-8",children:"No imported blogs yet"}):e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Title"}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"Imported"}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase",children:"URL"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200",children:C.map(s=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-3 text-sm text-gray-900",children:s.title}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${s.status==="published"?"bg-green-100 text-green-700":s.status==="failed"?"bg-red-100 text-red-700":"bg-yellow-100 text-yellow-700"}`,children:s.status})}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500",children:new Date(s.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3 text-sm",children:s.published_url?e.jsx("a",{href:s.published_url,target:"_blank",rel:"noopener noreferrer",className:"text-red-600 hover:underline",children:"View"}):"-"})]},s.id))})]})})]})]})]}),e.jsx(J,{isOpen:O,onClose:()=>b(!1),onConfirm:V,title:"Disconnect from BlogBotz",message:"Are you sure you want to disconnect from BlogBotz? You will no longer be able to import blogs until you reconnect.",confirmText:"Disconnect",cancelText:"Cancel",variant:"danger"})]})}
1export{le as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.