import{d as w,eB as P,eA as k,G as C,u as c,b as _,c as h,ex as I,cw as x}from"./outputWidgets.31ce2d5c.js";import{v,C as z}from"./icons.266b547d.js";import{a as D}from"./asyncComputed.7e3e21f4.js";import"./router.8f071dc2.js";import"./index.e05c62e3.js";import{P as l}from"./project.41cba40c.js";import{O as N}from"./organization.e24bfce8.js";import{C as O}from"./CrudView.9d67f588.js";import{a as A}from"./ant-design.feb03817.js";import"./FormItem.5f0b61bf.js";import"./hasIn.932773c2.js";import"./index.0d76378d.js";import"./index.cf4c23b9.js";import"./record.b2148451.js";import"./pubsub.2d9ab3f4.js";import"./gateway.3615e807.js";import"./Text.46c5bec2.js";import"./Base.eeda2dae.js";import"./Form.482980d3.js";import"./Modal.32a7843c.js";import"./url.94a5ee71.js";import"./index.627ab86d.js";import"./index.ef6e34b6.js";import"./Title.951eccc5.js";import"./index.5765ee72.js";import"./index.f1d2e592.js";import"./index.7e964756.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]="01fbf2a8-eaf4-4013-986b-d81d22933c88",r._sentryDebugIdIdentifier="sentry-dbid-01fbf2a8-eaf4-4013-986b-d81d22933c88")}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}=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})},b=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=C(()=>{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:v,label:"Edit Project",onClick:m},{icon:z,label:"Delete",onClick:b,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(i)?(_(),h(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:g},null,8,["loading","title","table"])):I("",!0)}});export{ne as default};
//# sourceMappingURL=Projects.abccef83.js.map
