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.04a14374.js";import{e as z,d as D}from"./icons.dee9dbe8.js";import{a as v}from"./asyncComputed.53598080.js";import{P as l}from"./project.e6570f82.js";import"./router.4677d467.js";import{O as N}from"./organization.2fe75ceb.js";import"./columns.19f4f485.js";import{C as O}from"./CrudView.a6f509b7.js";import{a as A}from"./ant-design.213d3e09.js";import"./gateway.f7d4a0c5.js";import"./record.b64a41e6.js";import"./pubsub.bb759777.js";import"./Base.0c1843db.js";import"./transButton.772cc0ed.js";import"./Text.84d5ffc7.js";import"./Title.9beb186f.js";import"./index.5d9ba614.js";import"./url.311573c2.js";import"./index.9bdc1e6b.js";import"./index.90d3343e.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]="f02dec61-f55f-4676-9eba-bc5da8b5cce7",r._sentryDebugIdIdentifier="sentry-dbid-f02dec61-f55f-4676-9eba-bc5da8b5cce7")}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: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}}),b=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 y()}},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:b},null,8,["loading","title","table"])):I("",!0)}});export{Z as default};
//# sourceMappingURL=Projects.6d925d77.js.map
