import{d as w,ez as P,ey as k,H as C,u as c,b as _,c as h,ev as I,cC as x}from"./outputWidgets.9a4dffd5.js";import{e as z,b as v}from"./icons.d935dec9.js";import{a as D}from"./asyncComputed.947a021a.js";import{P as l}from"./project.e0e41272.js";import"./router.e9c58c63.js";import{O as N}from"./organization.ab53ea01.js";import"./columns.2487afd8.js";import{C as O}from"./CrudView.32e9e362.js";import{a as E}from"./ant-design.edc4db28.js";import"./gateway.a8fa6711.js";import"./activeRecord.6b2e89dc.js";import"./pubsub.25596209.js";import"./Title.72e90637.js";import"./index.a351ac5c.js";import"./index.f4ac7424.js";import"./index.0d204717.js";import"./Form.0ea0ca53.js";import"./url.152c5826.js";import"./index.c64df437.js";import"./index.c4327f7e.js";import"./index.d0b58c73.js";import"./index.3ecad98a.js";import"./index.0e22fd42.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[a]="7413625a-1d36-48ae-a0d8-935c88286b1a",r._sentryDebugIdIdentifier="sentry-dbid-7413625a-1d36-48ae-a0d8-935c88286b1a")}catch{}})();const oe=w({__name:"Projects",setup(r){const a=[{key:"name",label:"Project Name"}],i=P().params.organizationId,u=k(),{loading:f,result:n,refetch:y}=D(()=>Promise.all([l.list(i),N.get(i)]).then(([e,t])=>({projects:e,organization:t}))),m=({key:e})=>u.push({name:"project",params:{projectId:e}}),g=async e=>{const t=await l.create({organizationId:i,name:e.name});m({key:t.id})},b=async({key:e})=>{var o,d;if(await E("Are you sure you want to delete this project?"))try{await((d=(o=n.value)==null?void 0:o.projects.find(s=>s.id===e))==null?void 0:d.delete())}catch(s){x.error({message:"Error deleting project",description:String(s)})}finally{await y()}},j=C(()=>{var e,t;return{columns:[{name:"Id"},{name:"Project Name"},{name:"Actions",align:"right"}],rows:(t=(e=n.value)==null?void 0:e.projects.map(o=>({key:o.id,cells:[{text:o.id.slice(0,8)},{text:o.name,link:`/projects/${encodeURIComponent(o.id)}`},{text:"",actions:[{icon:z,label:"Edit Project",onClick:m},{icon:v,label:"Delete",onClick:b,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(n)?(_(),h(O,{key:0,"entity-name":"project",loading:c(f),title:`${c(n).organization.name}'s Projects`,description:"Organize your team's work into different Projects, each with it's own subdomain.","create-button-text":"Create Project","empty-title":"No projects here yet",table:j.value,fields:a,onCreate:g},null,8,["loading","title","table"])):I("",!0)}});export{oe as default};
//# sourceMappingURL=Projects.458bdf52.js.map
