import{d as w,eA as _,ez as P,J as k,u as c,b as h,c as I,ew as C,cG as x}from"./outputWidgets.1f391ab3.js";import{e as z,b as D}from"./icons.35fd2af6.js";import{a as v}from"./asyncComputed.56fb497e.js";import{P as d}from"./project.76ccde49.js";import"./console.3edc9cde.js";import{O as N}from"./organization.390058ee.js";import"./index.e8fb5940.js";import{_ as O}from"./CrudView.vue_vue_type_script_setup_true_lang.fc3376a4.js";import{a as A}from"./ant-design.080bc381.js";import"./gateway.98993b50.js";import"./activeRecord.b9964a93.js";import"./pubsub.ab26e051.js";import"./index.a24e4cfd.js";import"./Form.d88e907e.js";import"./Title.e19c9b7e.js";import"./CollapsePanel.ed22c9ce.js";import"./index.3daa08be.js";import"./index.beaf06d8.js";import"./index.16917afa.js";import"./dayjs.12321a58.js";import"./index.06f9a351.js";import"./index.130e9d58.js";import"./TabPane.49afc3f4.js";import"./index.a2705008.js";import"./index.257ed691.js";import"./index.72e9f57c.js";import"./index.4260e6cf.js";import"./index.f0baefdd.js";import"./index.37b8f4ea.js";import"./index.18aa8459.js";import"./index.d09067f1.js";import"./index.6e066317.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},i=new Error().stack;i&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[i]="efbd03f4-7822-49c7-90f9-c3ae68583974",r._sentryDebugIdIdentifier="sentry-dbid-efbd03f4-7822-49c7-90f9-c3ae68583974")}catch{}})();const de=w({__name:"Projects",setup(r){const i=[{key:"name",label:"Project Name"}],n=_().params.organizationId,u=P(),{loading:f,result:a,refetch:y}=v(()=>Promise.all([d.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 d.create({organizationId:n,name:e.name});m({key:t.id})},b=async({key:e})=>{var o,p;if(await A("Are you sure you want to delete this project?"))try{await((p=(o=a.value)==null?void 0:o.projects.find(s=>s.id===e))==null?void 0:p.delete())}catch(s){x.error({message:"Error deleting project",description:String(s)})}finally{await y()}},j=k(()=>{var e,t;return{columns:[{name:"Id"},{name:"Project Name"},{name:"Actions",align:"right"}],rows:(t=(e=a.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:b,dangerous:!0}]}]})))!=null?t:[]}});return(e,t)=>c(a)?(h(),I(O,{key:0,"entity-name":"project",loading:c(f),title:`${c(a).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:i,onCreate:g},null,8,["loading","title","table"])):C("",!0)}});export{de as default};
//# sourceMappingURL=Projects.70d57f1d.js.map
