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.5ced94d7.js";import{e as z,b as D}from"./icons.157295a5.js";import{a as v}from"./asyncComputed.6f213f9d.js";import{P as l}from"./project.ec0f904a.js";import"./router.c33f3e79.js";import{O as N}from"./organization.44bb6c7b.js";import"./index.13e3df9c.js";import{C as O}from"./CrudView.1c9778e2.js";import{a as A}from"./ant-design.49bf0c8e.js";import"./gateway.06420003.js";import"./activeRecord.6ae8bce9.js";import"./pubsub.f395e26b.js";import"./Title.74cb802d.js";import"./index.48bbb941.js";import"./index.8ea91ac5.js";import"./Form.3717142f.js";import"./url.b91ad4a3.js";import"./index.54325f84.js";import"./index.d48bc6c3.js";import"./index.c946e10c.js";import"./index.fe1573f2.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]="01e622f7-26bb-4443-8b7e-fb76c6f493de",r._sentryDebugIdIdentifier="sentry-dbid-01e622f7-26bb-4443-8b7e-fb76c6f493de")}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:b}=v(()=>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}}),y=async e=>{const t=await l.create({organizationId:i,name:e.name});m({key:t.id})},g=async({key:e})=>{var o,d;if(await A("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 b()}},j=_(()=>{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:D,label:"Delete",onClick:g,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:j.value,fields:a,onCreate:y},null,8,["loading","title","table"])):I("",!0)}});export{ee as default};
//# sourceMappingURL=Projects.a3f683aa.js.map
