import{d as w,eA as P,ez as k,G as _,u as c,b as h,c as C,ew as I,cA as x}from"./outputWidgets.723dbd35.js";import{e as z,d as D}from"./icons.d199659e.js";import{a as v}from"./asyncComputed.6087fd05.js";import"./router.c09623bf.js";import"./index.f80aedcf.js";import{P as l}from"./project.47055dba.js";import{O as A}from"./organization.97807207.js";import{C as N}from"./CrudView.ca2cf6ee.js";import{a as O}from"./ant-design.64772334.js";import"./Form.71a7af16.js";import"./index.b41dfd0a.js";import"./record.c3c42720.js";import"./pubsub.97441533.js";import"./gateway.ed2ccaa3.js";import"./index.d0473694.js";import"./Title.ad9727d9.js";import"./url.c8598ea1.js";import"./index.4913d787.js";import"./index.f91ebf4c.js";import"./index.c827a0f6.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]="df03909e-96d3-4ffb-89f0-21f1629f526e",r._sentryDebugIdIdentifier="sentry-dbid-df03909e-96d3-4ffb-89f0-21f1629f526e")}catch{}})();const Z=w({__name:"Projects",setup(r){const a=[{key:"name",label:"Project Name"}],i=P().params.organizationId,f=k(),{loading:u,result:n,refetch:y}=v(()=>Promise.all([l.list(i),A.get(i)]).then(([e,t])=>({projects:e,organization:t}))),d=({key:e})=>f.push({name:"project",params:{projectId:e}}),g=async e=>{const t=await l.create({organizationId:i,name:e.name});d({key:t.id})},b=async({key:e})=>{var o,m;if(await O("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:b,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(n)?(h(),C(N,{key:0,"entity-name":"project",loading:c(u),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:g},null,8,["loading","title","table"])):I("",!0)}});export{Z as default};
//# sourceMappingURL=Projects.aa38dacf.js.map
