import{d as w,eB as P,eA as k,G as C,u as s,b as _,c as h,ex as I,cw as x}from"./outputWidgets.737278d2.js";import{v,C as z}from"./icons.00e0b192.js";import{a as D}from"./asyncComputed.a421a144.js";import"./authorManager.f6785b31.js";import"./index.7dd076b6.js";import{P as l}from"./project.d832252e.js";import{O as N}from"./organization.706dc625.js";import{C as O}from"./CrudView.094ad1c0.js";import{a as A}from"./ant-design.38d76521.js";import"./index.cf4c23b9.js";import"./record.605beade.js";import"./pubsub.88c6ed51.js";import"./gateway.5706e313.js";import"./Text.208da576.js";import"./Title.17b695f3.js";import"./FormItem.b35c2502.js";import"./hasIn.1648684d.js";import"./Form.fbb1233f.js";import"./Modal.2dd7ed00.js";import"./router.c82f2111.js";import"./index.ab3c62e5.js";import"./url.2a6e0213.js";import"./index.5d720f89.js";import"./index.d4ece610.js";import"./index.b108b24d.js";import"./index.9006f0ce.js";import"./index.10799228.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]="cfca6cb9-c49c-483a-9133-e79720aa9c6d",r._sentryDebugIdIdentifier="sentry-dbid-cfca6cb9-c49c-483a-9133-e79720aa9c6d")}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(c=>c.id===e))==null?void 0:d.delete())}catch(c){x.error({message:"Error deleting project",description:String(c)})}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)=>s(i)?(_(),h(O,{key:0,"entity-name":"project",loading:s(f),title:`${s(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.d6015e51.js.map
