import{d as w,eB as P,eA as k,G as _,u as c,b as h,c as C,ew as I,cE as x}from"./outputWidgets.0ed3a637.js";import{e as z,a as D}from"./icons.8d5441dc.js";import{a as v}from"./asyncComputed.054ae312.js";import{P as l}from"./project.2789fa4a.js";import"./router.d8af0f7d.js";import{O as E}from"./organization.bd1b7f8e.js";import"./columns.15b333c9.js";import{C as N}from"./CrudView.931c84f7.js";import{a as O}from"./ant-design.b8da9ea1.js";import"./gateway.678b6185.js";import"./activeRecord.e0ef2424.js";import"./pubsub.5dd4605f.js";import"./Base.69739fb7.js";import"./transButton.3ca23b61.js";import"./Text.e89a9af1.js";import"./Title.53f943d2.js";import"./index.230ffe19.js";import"./url.4f7be002.js";import"./index.0f5ee3e7.js";import"./index.feaa4503.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]="a9e0e924-d8cc-44cb-886f-4eaed27302f9",r._sentryDebugIdIdentifier="sentry-dbid-a9e0e924-d8cc-44cb-886f-4eaed27302f9")}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),E.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 O("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(N,{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.6fa968a3.js.map
