import{d as w,ez as P,ey as k,H as C,u as c,b as _,c as h,ev as I,cC as x}from"./outputWidgets.8a1294ac.js";import{e as z,b as v}from"./icons.25b21aee.js";import{a as D}from"./asyncComputed.3699cd44.js";import{P as l}from"./project.b6e75c34.js";import"./router.e765b2a2.js";import{O as N}from"./organization.d966701f.js";import"./columns.a2ad5768.js";import{C as O}from"./CrudView.707fb9d1.js";import{a as E}from"./ant-design.8f569ff8.js";import"./gateway.ec720fac.js";import"./activeRecord.4f50a80e.js";import"./pubsub.5ff7800d.js";import"./Title.c5e29cf7.js";import"./index.04ab96ef.js";import"./index.f4ac7424.js";import"./index.21148e20.js";import"./Form.1860c0ed.js";import"./url.9a5c0e6d.js";import"./index.d5d7d1dc.js";import"./index.4fc6eb1b.js";import"./index.91683b65.js";import"./index.bf7f5369.js";import"./index.0f4f2049.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]="0ecd7ece-be90-4fbd-9132-7af332ddea95",r._sentryDebugIdIdentifier="sentry-dbid-0ecd7ece-be90-4fbd-9132-7af332ddea95")}catch{}})();const oe=w({__name:"Projects",setup(r){const a=[{key:"name",label:"Project Name"}],i=P().params.organizationId,u=k(),{loading:f,result:n,refetch:y}=D(()=>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}}),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 E("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=C(()=>{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:v,label:"Delete",onClick:b,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(n)?(_(),h(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{oe as default};
//# sourceMappingURL=Projects.52ef57c4.js.map
