import{d as w,eB as P,eA as k,G as C,u as c,b as _,c as h,ex as I,cw as x}from"./outputWidgets.e33755f8.js";import{v,C as z}from"./icons.f6b19bc0.js";import{a as D}from"./asyncComputed.8bd4aeca.js";import"./authorManager.62b862f9.js";import"./index.0a6756f7.js";import{P as l}from"./project.8cd2a0dc.js";import{O as N}from"./organization.a0d50745.js";import{C as O}from"./CrudView.2f0c3c83.js";import{a as A}from"./ant-design.4ca18c4d.js";import"./index.cf4c23b9.js";import"./record.fe2d13ca.js";import"./pubsub.d8fbcc91.js";import"./gateway.f3da19f9.js";import"./Text.03e848c4.js";import"./Title.ac2baa04.js";import"./FormItem.fdb358e6.js";import"./hasIn.5c4a4bf3.js";import"./Form.e78b9235.js";import"./Modal.e934f1f6.js";import"./router.8c7b3fad.js";import"./index.9f6d3055.js";import"./url.3d250afc.js";import"./index.98828044.js";import"./index.58a4a13c.js";import"./index.4b06b554.js";import"./index.72b0b8fe.js";import"./index.7be3845f.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]="40681446-be86-4a3c-919f-1c838c6f1e15",r._sentryDebugIdIdentifier="sentry-dbid-40681446-be86-4a3c-919f-1c838c6f1e15")}catch{}})();const ne=w({__name:"Projects",setup(r){const a=[{key:"name",label:"Project Name"}],n=P().params.organizationId,u=k(),{loading:f,result:i,refetch:y}=D(()=>Promise.all([l.list(n),N.get(n)]).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:n,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=i.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=C(()=>{var e,t;return{columns:[{name:"Id"},{name:"Project Name"},{name:"Actions",align:"right"}],rows:(t=(e=i.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:v,label:"Edit Project",onClick:m},{icon:z,label:"Delete",onClick:b,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(i)?(_(),h(O,{key:0,"entity-name":"project",loading:c(f),title:`${c(i).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{ne as default};
//# sourceMappingURL=Projects.61e89f90.js.map
