1import{_}from"./DJJdFeQj.js";import{Q as b,A as x,e as h,K as y,c as i,a as o,F as S,r as v,k as P,o as r,b as L,t as l}from"./DbfHA8MV.js";import"./JmDm_dP0.js";import"./BskQ2YPd.js";import"./CpOpcM8j.js";function $(){return globalThis.$fetch}const w={class:"bg-gray-50"},F={class:"max-w-2xl mx-auto pt-16 pb-20 p-4 h-screen"},U={class:"flex flex-col"},g={class:"text-sm font-medium text-neutral-950"},T={class:"text-xs text-neutral-500"},k={class:"text-xs text-neutral-500"},q=b({__name:"toggles",setup(C){const n=x(),d=$(),c=y([{name:"email_notifications",label:"Email notifications",description:"Process email notifications triggered by Wrike updates.",status:!1,lastPersistedStatus:!1,isLoading:!0,isSaving:!1},{name:"project_outcomes_report_emails",label:"Project outcomes report emails",description:"Send organization administrators a copy when a report is generated.",status:!1,lastPersistedStatus:!1,isLoading:!0,isSaving:!1}]);async function u(t){try{const s=await d(`/api/admin/feature-toggles/${encodeURIComponent(t.name)}`),a=typeof(s==null?void 0:s.status)=="boolean"?s.status:!1;t.status=a,t.lastPersistedStatus=a}catch(s){console.error(`Failed to load ${t.name} toggle`,s),n.add({title:"Unable to load toggle status",description:"Please refresh the page and try again.",color:"error"})}finally{t.isLoading=!1}}async function m(t,s){t.isSaving=!0;try{const a=await d(`/api/admin/feature-toggles/${encodeURIComponent(t.name)}`,{method:"PATCH",body:{status:s}}),e=typeof(a==null?void 0:a.status)=="boolean"?a.status:s;t.status=e,t.lastPersistedStatus=e,n.add({title:`${t.label} ${e?"enabled":"disabled"}`,color:"success"})}catch(a){console.error(`Failed to update ${t.name} toggle`,a),t.status=t.lastPersistedStatus,n.add({title:"Unable to update toggle",description:"Please try again.",color:"error"})}finally{t.isSaving=!1}}async function f(t,s){t.isLoading||s===t.lastPersistedStatus||(t.status=s,await m(t,s))}return h(()=>{for(const t of c)u(t)}),(t,s)=>{const a=_;return r(),i("div",w,[o("div",F,[s[0]||(s[0]=o("h1",{class:"text-4xl md:text-5xl font-bold text-neutral-950 mb-8"},"Feature toggles",-1)),(r(!0),i(S,null,v(P(c),e=>(r(),i("div",{key:e.name,class:"mb-6 flex flex-row items-center gap-4"},[L(a,{"model-value":e.status,disabled:e.isLoading||e.isSaving,"onUpdate:modelValue":p=>f(e,p)},null,8,["model-value","disabled","onUpdate:modelValue"]),o("div",U,[o("span",g,l(e.label),1),o("span",T,l(e.description),1),o("span",k,l(e.isLoading?"Loading current status...":e.status?"Enabled":"Disabled"),1)])]))),128))])])}}});export{q 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.