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.300f3e96.js";import{e as z,b as D}from"./icons.faa6dbaa.js";import{a as v}from"./asyncComputed.6561fe78.js";import{P as l}from"./project.7820674a.js";import"./router.fdc19966.js";import{O as N}from"./organization.ffaf9442.js";import"./index.92fda3db.js";import{C as O}from"./CrudView.0d50f6ef.js";import{a as A}from"./ant-design.e9641753.js";import"./gateway.d0550bff.js";import"./activeRecord.6e31bcda.js";import"./pubsub.f4c4af7d.js";import"./Title.f9e3ac72.js";import"./index.4c022ec6.js";import"./index.b12dda90.js";import"./Form.e5ad8df8.js";import"./url.f346bb44.js";import"./index.f69106a7.js";import"./index.0deb6cbe.js";import"./index.b49fb559.js";import"./index.c74452a7.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]="a1f376e2-b155-442b-8e5b-9bf36984b231",r._sentryDebugIdIdentifier="sentry-dbid-a1f376e2-b155-442b-8e5b-9bf36984b231")}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:b}=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}}),y=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 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 b()}},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(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:y},null,8,["loading","title","table"])):I("",!0)}});export{ee as default};
//# sourceMappingURL=Projects.5286ffd0.js.map
