import{d as w,eB as P,eA as k,G as _,u as c,b as h,c as C,ex as I,cw as x}from"./outputWidgets.396f5ce1.js";import{v as D,D as v}from"./icons.37b6f90f.js";import{a as z}from"./asyncComputed.95737324.js";import"./router.898a5ca4.js";import"./index.d80eeb49.js";import{P as l}from"./project.e7f48580.js";import{O as N}from"./organization.e739f1ec.js";import{C as O}from"./CrudView.ece8081d.js";import{a as A}from"./ant-design.e656dd24.js";import"./FormItem.a8de7296.js";import"./hasIn.63a13365.js";import"./index.f3919413.js";import"./index.cf4c23b9.js";import"./record.1aff3d29.js";import"./pubsub.06faa612.js";import"./gateway.a0e7cb55.js";import"./Text.4e180dc2.js";import"./Base.ee1dde08.js";import"./Form.716e7fa5.js";import"./Modal.c02a2840.js";import"./url.4e42e1d0.js";import"./index.645b3e28.js";import"./index.a44632c5.js";import"./Title.819eb0fe.js";import"./index.f0384574.js";import"./index.a23873b5.js";import"./index.b703167a.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]="592f411b-8366-49ab-9e26-a11b1df6f203",r._sentryDebugIdIdentifier="sentry-dbid-592f411b-8366-49ab-9e26-a11b1df6f203")}catch{}})();const ne=w({__name:"Projects",setup(r){const a=[{key:"name",label:"Project Name"}],n=P().params.organizationId,u=k(),{loading:f,result:i,refetch:y}=z(()=>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}}),b=async e=>{const t=await l.create({organizationId:n,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=i.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()}},j=_(()=>{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:D,label:"Edit Project",onClick:m},{icon:v,label:"Delete",onClick:g,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:j.value,fields:a,onCreate:b},null,8,["loading","title","table"])):I("",!0)}});export{ne as default};
//# sourceMappingURL=Projects.663dd9b2.js.map
