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.6d6b4a37.js";import{e as z,d as D}from"./icons.28d0d847.js";import{a as v}from"./asyncComputed.17a6198d.js";import"./router.4e9df257.js";import"./index.2cafcd9c.js";import{P as l}from"./project.c406c3ff.js";import{O as A}from"./organization.f89e67cc.js";import{C as N}from"./CrudView.230a173f.js";import{a as O}from"./ant-design.c99b7781.js";import"./Form.1ff54ed5.js";import"./index.72c317ca.js";import"./record.7835c07e.js";import"./pubsub.7d377b25.js";import"./gateway.7a58b0c8.js";import"./index.0e216cc8.js";import"./Title.b41b4f96.js";import"./url.b5fbb423.js";import"./index.9eddb8ae.js";import"./index.6f6e8ffd.js";import"./index.f2a53bdb.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]="c64f9e22-bfee-483e-b1ab-013f497c8d14",r._sentryDebugIdIdentifier="sentry-dbid-c64f9e22-bfee-483e-b1ab-013f497c8d14")}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),A.get(i)]).then(([e,t])=>({projects:e,organization:t}))),m=({key:e})=>u.push({name:"project",params:{projectId:e}}),b=async e=>{const t=await l.create({organizationId:i,name:e.name});m({key:t.id})},g=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:g,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:b},null,8,["loading","title","table"])):I("",!0)}});export{Z as default};
//# sourceMappingURL=Projects.7af33113.js.map
