import{d as w,ez as P,ey as k,H as C,u as c,b as _,c as h,ev as I,cC as x}from"./outputWidgets.a4629ff8.js";import{e as z,b as v}from"./icons.73bff2ab.js";import{a as D}from"./asyncComputed.fb8b9ba6.js";import{P as l}from"./project.b861b2fe.js";import"./router.ab2ac3ba.js";import{O as N}from"./organization.6571a8a9.js";import"./columns.464a3bb5.js";import{C as O}from"./CrudView.a5b1a4eb.js";import{a as E}from"./ant-design.523e8417.js";import"./gateway.68939de7.js";import"./activeRecord.a2b7d343.js";import"./pubsub.25dc8c41.js";import"./Title.cf2a531e.js";import"./index.339c7421.js";import"./index.f4ac7424.js";import"./Text.eb216708.js";import"./Form.ab59726f.js";import"./url.d6a620b9.js";import"./index.874565bb.js";import"./index.48817ebe.js";import"./index.0f6dde5f.js";import"./index.46db6cb2.js";import"./index.56cfba6d.js";import"./index.fda4c602.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]="cf14ee36-6ca1-4e91-968c-56b279ed523a",r._sentryDebugIdIdentifier="sentry-dbid-cf14ee36-6ca1-4e91-968c-56b279ed523a")}catch{}})();const re=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 E("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:z,label:"Edit Project",onClick:m},{icon:v,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{re as default};
//# sourceMappingURL=Projects.f4d431a5.js.map
