import{d as w,ez as P,ey as k,G as _,u as c,b as h,c as C,ev as I,cz as z}from"./outputWidgets.24bc53e6.js";import{e as x,b as v}from"./icons.346b8028.js";import{a as D}from"./asyncComputed.e4b96939.js";import{P as l}from"./project.92896cfe.js";import"./router.5678fba5.js";import{O as N}from"./organization.ed42d739.js";import"./columns.29187485.js";import{C as O}from"./CrudView.acebed42.js";import{a as E}from"./ant-design.3bddf1a0.js";import"./gateway.c4f59e31.js";import"./activeRecord.7f48ce0d.js";import"./pubsub.6b8c4d65.js";import"./Form.026abd8d.js";import"./Title.d959e45a.js";import"./transButton.082aab94.js";import"./Text.9efc0467.js";import"./index.bf56aca1.js";import"./index.cf4c23b9.js";import"./url.12ca99c5.js";import"./index.0ec384bd.js";import"./index.3a0ced65.js";import"./index.b19c9d88.js";import"./index.4b05c792.js";import"./index.d2b2175c.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]="da48f144-41ac-4f64-99a0-6cd7355833d5",r._sentryDebugIdIdentifier="sentry-dbid-da48f144-41ac-4f64-99a0-6cd7355833d5")}catch{}})();const re=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})},j=async({key:e})=>{var o,d;if(await E("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){z.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=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:x,label:"Edit Project",onClick:m},{icon:v,label:"Delete",onClick:j,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(i)?(h(),C(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:b.value,fields:a,onCreate:g},null,8,["loading","title","table"])):I("",!0)}});export{re as default};
//# sourceMappingURL=Projects.26997061.js.map
