import{d as w,ez as P,ey as k,G as _,u as c,b as h,c as C,ev as I,cz as z}from"./outputWidgets.0fb707c7.js";import{e as x,b as v}from"./icons.24a85994.js";import{a as D}from"./asyncComputed.a0ca296c.js";import{P as l}from"./project.f9503600.js";import"./router.81de177d.js";import{O as N}from"./organization.510c9436.js";import"./columns.37a1e6f7.js";import{C as O}from"./CrudView.e365e55f.js";import{a as E}from"./ant-design.c18e1d39.js";import"./gateway.7ee47e62.js";import"./activeRecord.204186f3.js";import"./pubsub.7d8bce56.js";import"./Form.0dcb97c0.js";import"./Title.f00a58f9.js";import"./transButton.220177fb.js";import"./Text.3ec0a64d.js";import"./index.140c5bc8.js";import"./index.cf4c23b9.js";import"./url.d43b75f5.js";import"./index.85d2f01b.js";import"./index.8dbf2994.js";import"./index.0d3d2205.js";import"./index.e8ef1073.js";import"./index.a2e845fd.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]="1afe1abb-bd27-4554-8da9-6b82fe5d73f5",r._sentryDebugIdIdentifier="sentry-dbid-1afe1abb-bd27-4554-8da9-6b82fe5d73f5")}catch{}})();const re=w({__name:"Projects",setup(r){const a=[{key:"name",label:"Project Name"}],n=P().params.organizationId,u=k(),{loading:f,result:i,refetch:b}=D(()=>Promise.all([l.list(n),N.get(n)]).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:n,name:e.name});m({key:t.id})},g=async({key:e})=>{var o,d;if(await E("Are you sure you want to delete this project?"))try{await((d=(o=i.value)==null?void 0:o.projects.find(s=>s.id===e))==null?void 0:d.delete())}catch(s){z.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=i.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:x,label:"Edit Project",onClick:m},{icon:v,label:"Delete",onClick:g,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(i)?(h(),C(O,{key:0,"entity-name":"project",loading:c(f),title:`${c(i).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{re as default};
//# sourceMappingURL=Projects.8a1fd7a4.js.map
