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.903ef13f.js";import{e as z,b as D}from"./icons.c6b9d5b7.js";import{a as v}from"./asyncComputed.c4e04ddf.js";import{P as l}from"./project.f7671242.js";import"./router.ddb32f08.js";import{O as N}from"./organization.3570e1df.js";import"./index.7a97ebf0.js";import{C as O}from"./CrudView.87fcb808.js";import{a as A}from"./ant-design.6476f34e.js";import"./gateway.a6a9ad01.js";import"./activeRecord.55ed0790.js";import"./pubsub.c9a1cd12.js";import"./Title.a0ce44ea.js";import"./index.e5fe38b8.js";import"./index.038e0c5b.js";import"./Form.49dc913d.js";import"./url.08ed6687.js";import"./index.c70ecf50.js";import"./index.d93d8aa2.js";import"./index.abf1ee4c.js";import"./index.ff825c04.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]="b12aed9c-57e8-4624-86da-2e9cd493fdb1",r._sentryDebugIdIdentifier="sentry-dbid-b12aed9c-57e8-4624-86da-2e9cd493fdb1")}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}))),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 A("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=_(()=>{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:D,label:"Delete",onClick:b,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:j.value,fields:a,onCreate:g},null,8,["loading","title","table"])):I("",!0)}});export{ee as default};
//# sourceMappingURL=Projects.5e8bb1e2.js.map
