import{d as w,eA as P,ez as k,J as _,u as c,b as h,c as C,ew as I,cG as x}from"./outputWidgets.5f5dca9f.js";import{e as z,b as D}from"./icons.a77543dc.js";import{a as v}from"./asyncComputed.eae0c0ea.js";import{P as l}from"./project.de2f38b9.js";import"./router.a7910fab.js";import{O as N}from"./organization.dacfc6ab.js";import"./index.fcdb7e23.js";import{C as O}from"./CrudView.f3b7e8d3.js";import{a as A}from"./ant-design.b34b2997.js";import"./gateway.68ea1e37.js";import"./activeRecord.ad81cab4.js";import"./pubsub.628f19a6.js";import"./Title.c2ba09dc.js";import"./index.92c8cf6e.js";import"./index.d2da0107.js";import"./Form.09052538.js";import"./url.1555ad6e.js";import"./index.f5a72b75.js";import"./index.10f6bb5a.js";import"./index.7ef152c5.js";import"./index.7ab474e7.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]="f0ce7161-8e65-4c44-95f4-65e8721a4f88",r._sentryDebugIdIdentifier="sentry-dbid-f0ce7161-8e65-4c44-95f4-65e8721a4f88")}catch{}})();const ee=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})},j=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()}},b=_(()=>{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:j,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:b.value,fields:a,onCreate:g},null,8,["loading","title","table"])):I("",!0)}});export{ee as default};
//# sourceMappingURL=Projects.218130a2.js.map
