import{d as w,eB as P,eA as k,G as _,u as c,b as h,c as C,ew as I,cz as x}from"./outputWidgets.c4f3de67.js";import{e as z,d as D}from"./icons.49e74e71.js";import{a as v}from"./asyncComputed.c75b06d6.js";import{P as l}from"./project.fda53dcc.js";import"./router.88734ca5.js";import{O as N}from"./organization.73e64f9c.js";import"./columns.aa61756c.js";import{C as O}from"./CrudView.4072ea68.js";import{a as A}from"./ant-design.a1a552ac.js";import"./gateway.5578a098.js";import"./record.685c8ba7.js";import"./pubsub.1842fa2d.js";import"./Base.9ed9c296.js";import"./transButton.ebe60b80.js";import"./Text.fcf8f28f.js";import"./Title.345a4775.js";import"./index.db3809d7.js";import"./url.d2782274.js";import"./index.c4339fad.js";import"./index.b168b141.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]="b952fa86-a012-45cb-beb0-9addf1e866f7",r._sentryDebugIdIdentifier="sentry-dbid-b952fa86-a012-45cb-beb0-9addf1e866f7")}catch{}})();const Z=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}))),d=({key:e})=>u.push({name:"project",params:{projectId:e}}),y=async e=>{const t=await l.create({organizationId:i,name:e.name});d({key:t.id})},g=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 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:d},{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{Z as default};
//# sourceMappingURL=Projects.aa22d539.js.map
