import{d as w,eA as P,ez as k,J as _,u as c,b as h,c as C,ew as I,cG as x}from"./outputWidgets.d94fff8c.js";import{e as z,b as D}from"./icons.fec42461.js";import{a as v}from"./asyncComputed.6da48dd7.js";import{P as l}from"./project.ee914ec2.js";import"./router.4a188c48.js";import{O as N}from"./organization.f12114ad.js";import"./index.a5166b6d.js";import{C as O}from"./CrudView.e6c5592c.js";import{a as A}from"./ant-design.b0e50c8b.js";import"./gateway.8dd534ee.js";import"./activeRecord.4bb9e983.js";import"./pubsub.39314a92.js";import"./Title.c70c7e79.js";import"./index.3dad0da1.js";import"./index.7d7e00b1.js";import"./Form.57801503.js";import"./url.596d80c9.js";import"./index.e7f021ad.js";import"./index.3709b59d.js";import"./index.0f14f01f.js";import"./index.209f6c1c.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]="51063442-d157-4d36-96d0-152d5856c830",r._sentryDebugIdIdentifier="sentry-dbid-51063442-d157-4d36-96d0-152d5856c830")}catch{}})();const ee=w({__name:"Projects",setup(r){const a=[{key:"name",label:"Project Name"}],i=P().params.organizationId,u=k(),{loading:f,result:n,refetch:y}=v(()=>Promise.all([l.list(i),N.get(i)]).then(([e,t])=>({projects:e,organization:t}))),d=({key:e})=>u.push({name:"project",params:{projectId:e}}),g=async e=>{const t=await l.create({organizationId:i,name:e.name});d({key:t.id})},j=async({key:e})=>{var o,m;if(await A("Are you sure you want to delete this project?"))try{await((m=(o=n.value)==null?void 0:o.projects.find(s=>s.id===e))==null?void 0:m.delete())}catch(s){x.error({message:"Error deleting project",description:String(s)})}finally{await y()}},b=_(()=>{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:d},{icon:D,label:"Delete",onClick:j,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(n)?(h(),C(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:b.value,fields:a,onCreate:g},null,8,["loading","title","table"])):I("",!0)}});export{ee as default};
//# sourceMappingURL=Projects.c65826bb.js.map
