import{j as e}from"./jsx-runtime.D_zvdyIk.js";import{r as n}from"./index.DIfZGIpv.js";import{A as g,a as j,u as F}from"./AdminAuth.CbzFS552.js";import{A as l}from"./AdminLayout.CKC2eNsX.js";function b(){const{token:c}=F(),[u,m]=n.useState([]),[x,h]=n.useState(!0),[a,o]=n.useState(null),i={Authorization:`Bearer ${c}`},d=()=>{fetch("/api/admin/crons",{headers:i}).then(t=>t.json()).then(t=>m(t.crons||[])).finally(()=>h(!1))};n.useEffect(d,[]);const p=async t=>{o(t),await fetch("/api/admin/crons",{method:"POST",headers:{...i,"Content-Type":"application/json"},body:JSON.stringify({name:t})}),setTimeout(()=>{d(),o(null)},1e3)},f=t=>{if(!t)return"Nooit";const s=Date.now()-new Date(t).getTime(),r=Math.floor(s/36e5);return r<1?`${Math.floor(s/6e4)}m geleden`:r<24?`${r}u geleden`:`${Math.floor(r/24)}d geleden`};return x?e.jsx(l,{title:"Cron Jobs",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-2 border-[#00FF6A] border-t-transparent rounded-full animate-spin"})})}):e.jsx(l,{title:"Cron Jobs",children:e.jsx("div",{className:"space-y-3",children:u.map(t=>{const s=t.last_run,r=s?s.status==="ok"?"text-[#00FF6A]":s.status==="error"?"text-[#FF3B3B]":"text-[#FFD700]":"text-[#666]";return e.jsxs("div",{className:"bg-[#141414] border border-[#333] rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${s?s.status==="ok"?"bg-[#00FF6A]":s.status==="error"?"bg-[#FF3B3B]":"bg-[#FFD700]":"bg-[#666]"}`}),e.jsx("span",{className:"text-[#F5F5F5] font-medium",children:t.name}),e.jsx("span",{className:"text-xs text-[#666]",children:t.description})]}),e.jsxs("div",{className:"flex items-center gap-6 mt-2 text-sm text-[#999]",children:[e.jsxs("span",{children:["📅 ",t.schedule]}),e.jsxs("span",{children:["🕐 ",s?f(s.started_at):"Nooit gedraaid"]}),s?.duration_secs!=null&&e.jsxs("span",{children:["⏱️ ",Math.round(s.duration_secs),"s"]}),e.jsx("span",{className:r,children:s?.status||"unknown"})]})]}),e.jsxs("button",{onClick:()=>p(t.name),disabled:a===t.name,className:"px-4 py-2 rounded-lg text-sm bg-[#1A1A1A] border border-[#333] text-[#999] hover:text-[#00FF6A] hover:border-[#00FF6A] transition-colors disabled:opacity-50",children:[a===t.name?"⏳":"▶️"," Run"]})]}),s?.output_summary&&e.jsx("div",{className:"mt-3 text-xs text-[#666] bg-[#0A0A0A] p-2 rounded",children:s.output_summary}),s?.error_message&&e.jsx("div",{className:"mt-3 text-xs text-[#FF3B3B] bg-[#FF3B3B]/10 p-2 rounded",children:s.error_message})]},t.name)})})})}function B(){return e.jsx(g,{children:e.jsx(j,{children:e.jsx(b,{})})})}export{B as default};
