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.df68f70a.js";import{e as z,d as D}from"./icons.6f0b428b.js";import{a as v}from"./asyncComputed.c4f3fa7a.js";import"./router.d34810ba.js";import"./index.5b8834fd.js";import{P as l}from"./project.7e3804c0.js";import{O as N}from"./organization.03354c62.js";import{C as O}from"./CrudView.8169c4b4.js";import{a as A}from"./ant-design.4f24b7fc.js";import"./Base.8da1f136.js";import"./transButton.b32cb3fc.js";import"./Text.5293eafa.js";import"./Title.d7a9606c.js";import"./index.a1698b08.js";import"./record.493f7d84.js";import"./pubsub.26abae80.js";import"./gateway.104fd643.js";import"./url.e14018a7.js";import"./index.4c2136c4.js";import"./index.f12da0b9.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]="081f557c-42ee-4e23-9cf4-f3890227b6c4",r._sentryDebugIdIdentifier="sentry-dbid-081f557c-42ee-4e23-9cf4-f3890227b6c4")}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}))),m=({key:e})=>u.push({name:"project",params:{projectId:e}}),g=async e=>{const t=await l.create({organizationId:i,name:e.name});m({key:t.id})},b=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 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:m},{icon:D,label:"Delete",onClick:b,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:g},null,8,["loading","title","table"])):I("",!0)}});export{Z as default};
//# sourceMappingURL=Projects.e6362236.js.map
