import{d as w,eB as P,eA as k,G as _,u as c,b as h,c as C,ew as I,cE as x}from"./outputWidgets.562826ac.js";import{e as z,b as D}from"./icons.63405824.js";import{a as v}from"./asyncComputed.df2d9552.js";import{P as l}from"./project.e065d842.js";import"./router.e5ce2c0b.js";import{O as E}from"./organization.ab77399d.js";import"./columns.29d297cf.js";import{C as N}from"./CrudView.6f7097f4.js";import{a as O}from"./ant-design.1ee2ab2c.js";import"./gateway.c80b0686.js";import"./activeRecord.6bb1bd7f.js";import"./pubsub.7185b91b.js";import"./Base.bf8dc0b1.js";import"./FormItem.fc4e7da8.js";import"./transButton.17480f27.js";import"./Text.712cfc26.js";import"./Title.f7aaa881.js";import"./index.82606edc.js";import"./index.cf4c23b9.js";import"./url.5a1383d2.js";import"./index.01bf1f2c.js";import"./index.583cd440.js";import"./index.9cdd1b35.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]="8e098ca7-2897-4c70-93e7-572390dde49e",r._sentryDebugIdIdentifier="sentry-dbid-8e098ca7-2897-4c70-93e7-572390dde49e")}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}=v(()=>Promise.all([l.list(i),E.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 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()}},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(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:b.value,fields:a,onCreate:g},null,8,["loading","title","table"])):I("",!0)}});export{oe as default};
//# sourceMappingURL=Projects.104ae9ab.js.map
