import{N as k}from"./Navbar.fcfe029d.js";import{B as I}from"./BaseLayout.59c8f3b5.js";import{C as N}from"./ContentLayout.82d36039.js";import{C as _}from"./CrudView.6dc35c9a.js";import{a as O}from"./asyncComputed.a244f4e2.js";import{F as x}from"./PhArrowSquareOut.vue.ae0d54ee.js";import{G as M}from"./PhPencil.vue.41c0ea13.js";import{d as R,e4 as h,r as B,c as D,a4 as F,f as o,b as i,u as s,aQ as V,o as f,a as $,cw as j,bI as A,cv as E,h as G,M as L}from"./jwt-decode.esm.335fee36.js";import"./router.17c03c82.js";import{a as m}from"./organization.4c37d52d.js";import"./tables.425b82ff.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.d33119e7.js";import"./constants.9b601448.js";import"./PhChats.vue.6adc6999.js";import"./PhSignOut.vue.37ff0a54.js";import"./index.51e85c7e.js";import"./index.0b9c81d1.js";import"./omniChatStore.4e127235.js";import"./record.98dcb0d9.js";import"./PhSparkle.vue.41ff2bfd.js";import"./index.38654d24.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.17b4292d.js";import"./url.620305e5.js";import"./PhDotsThreeVertical.vue.e3743d4f.js";import"./string.43ee44ca.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[l]="7d526f50-ba07-4919-9fe9-be2939eb3d0a",r._sentryDebugIdIdentifier="sentry-dbid-7d526f50-ba07-4919-9fe9-be2939eb3d0a")}catch{}})();const pe=R({__name:"Organizations",setup(r){const l=[{label:"My organizations",path:"/organizations"}],u=[{key:"name",label:"Organization Name"}],g=h(),{loading:b,result:y,refetch:v}=O(()=>m.list()),d=({key:t})=>{g.push({name:"organization",params:{organizationId:t}})},n=B({state:"idle"});function z(t){n.value={state:"renaming",organizationId:t.id,newName:t.name}}async function p(t){if(n.value.state==="renaming"&&t){const{organizationId:e,newName:a}=n.value;await m.rename(e,a),v()}n.value={state:"idle"}}const w=async t=>{const e=await m.create(t.name);d({key:e.id})},C=D(()=>{var t,e;return{columns:[{title:"Organization Name",align:"left"},{title:"Path"},{title:"",align:"right"}],rows:(e=(t=y.value)==null?void 0:t.map(a=>{var c;return{key:a.id,cells:[{type:"link",text:a.name,to:`/organizations/${encodeURIComponent(a.id)}`},{type:"text",text:(c=a.id)!=null?c:null},{type:"actions",actions:[{icon:x,label:"Go to projects",onClick:d},{icon:M,label:"Rename",onClick:()=>z(a)}]}]}}))!=null?e:[]}});return(t,e)=>(f(),F(V,null,[o(I,null,{navbar:i(()=>[o(k,{breadcrumb:l})]),content:i(()=>[o(N,null,{default:i(()=>[o(_,{"entity-name":"organization",loading:s(b),title:"My organizations",description:"An organization is your company\u2019s account. Manage editors, projects and billing.","create-button-text":"Create Organization","empty-title":"No organizations here yet",table:C.value,fields:u,create:w},null,8,["loading","table"])]),_:1})]),_:1}),o(s(L),{open:n.value.state==="renaming",title:"Rename organization",onCancel:e[1]||(e[1]=a=>p(!1)),onOk:e[2]||(e[2]=a=>p(!0))},{default:i(()=>[n.value.state==="renaming"?(f(),$(s(E),{key:0,layout:"vertical"},{default:i(()=>[o(s(j),{label:"New name"},{default:i(()=>[o(s(A),{value:n.value.newName,"onUpdate:value":e[0]||(e[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):G("",!0)]),_:1},8,["open"])],64))}});export{pe as default};
//# sourceMappingURL=Organizations.0ec3da27.js.map
