import{u as r,j as t}from"./fields-wnm5Jtc6.js";import{a as u,R as C}from"./vendor-D21mNUGX.js";import{L as j,n as o}from"./Layout-CFk9FOHT.js";import{C as v}from"./index-5Ilcd7WA.js";import{C as n}from"./CardRow-Bf5pkBel.js";import{m as R,c as b,B as p,s as m,A as g,w as f}from"./index-pmrLY__j.js";const S=()=>{const[a,d]=u.useState(null),[h,l]=u.useState([]),x=()=>{f("runRepairAction",{}).then(e=>{e.success?(o.success(r("The repair was carried out successfully.")),i()):o.error(e.error)}).catch(e=>{console.error(e),o.error(r("Something went wrong, please retry."))})},i=()=>{d(null),l([]),f("healthCheckAction",{}).then(e=>{d(e),e.db!=="ok"&&l(s=>[...s,"db"]),e.version!=="ok"&&l(s=>[...s,"version"]),e.cache!=="ok"&&l(s=>[...s,"cache"]),e.curl!=="ok"&&l(s=>[...s,"curl"])}).catch(e=>{console.error(e),o.error(r("Something went wrong, please retry."))})};u.useEffect(()=>{R(r("Health check")),b("#/tools"),i()},[]);let k=[t.jsx(p,{style:m.SECONDARY,onClick:e=>{e.preventDefault(),i()},children:r("Run health check")})];(h==null?void 0:h.length)>0&&k.push(t.jsx(p,{style:m.PRIMARY,onClick:e=>{e.preventDefault(),x()},children:r("Launch the repair")}));const c=e=>t.jsx("div",{className:`color-${e==="ok"?"success":"danger"}`,children:e});return t.jsx(j,{title:r("Health check"),actions:k,crumbs:[{label:r("ACPT Tools"),link:"/tools"},{label:r("Health check")}],children:a?t.jsx(C.Fragment,{children:t.jsxs(v,{title:r("Health check"),children:[t.jsx(n,{label:r("Plugin version"),value:c(a.version)}),t.jsx(n,{label:r("DB status"),value:c(a.db)}),t.jsx(n,{label:r("CURL"),value:c(a.curl)}),t.jsx(n,{label:r("Cache"),value:c(a.cache)})]})}):t.jsx(g,{style:m.WARNING,children:"Health check running..."})})};export{S as default};
