1import{d as se,a as ae,l as ne,s as ie,v as x,g as le,a0 as U,h as B,S as ce,H as re,bc as me,bD as de,o as i,j as m,e as t,b as d,i as h,n as C,t as y,c as q,w as $,V as w,F as G,r as pe,N as ue,K as _e,_ as fe,aK as he,D as ye,bz as H,bv as be,a6 as ve,bE as ge,bF as ke,aA as xe,q as Ce}from"./entry.C_E2KLfC.js";import{u as $e}from"./companies.j5iVNZbJ.js";import{_ as we}from"./BaseConfirm.vue.BqKVO1rT.js";import"./autocomplete.DcyV24U5.js";const Ne={key:0,class:"py-10 flex justify-center"},Be={key:1},Le={class:"rounded-xl px-6 py-5 space-y-3 bg-amber-500 text-white text-md flex items-center"},Re={key:2},Fe={class:"bg-white rounded-xl p-4 sm:p-8"},Ve={class:"text-xl font-bold"},Me={class:"flex flex-col gap-3 mt-6"},Ae={key:0,class:"dark:border-t-trueGray-500"},Se={key:0,class:"py-5 dark:text-white flex justify-center"},Ie=se({__name:"company-members",setup(De){const{pushNotification:b}=ve(),c=ae(),{t:r}=ne(),J=ie(),N=$e(),s=x(null),L=x(!1),R=x(!1);le(async()=>{var e,a;if(!((e=c.profile)!=null&&e.company)){J.push(U()("/users/me/edit/basic"));return}s.value=N.initCompanyMembersList(c.profile.company.id);try{await((a=s.value)==null?void 0:a.getPage())}catch(n){n.status===403&&(L.value=!0),B(n)}R.value=!0});const v=x(null),p=ce({}),Q=re(me(de,!1),r,"companies.roles");async function W(e){var a;e&&await((a=s.value)==null?void 0:a.nextPage())}async function X(e,a){var n,u;try{p[e]=!0,await N.setRolesInCompany((u=(n=c.profile)==null?void 0:n.company)==null?void 0:u.id,e,a),b({title:r("notifications.companies.change_member_roles_success")})}catch(_){b({title:r("notifications.companies.change_member_roles_fail"),description:_.status===403?r("notifications.companies.not_enough_permissions"):void 0,theme:"destructive"}),B(_)}finally{p[e]=!1}}function Y(e){var a;(a=v==null?void 0:v.value)==null||a.open(e)}async function Z(e){var a,n,u,_,g;try{p[e.id]=!0,await N.removeMemberFromCompany((n=(a=c.profile)==null?void 0:a.company)==null?void 0:n.id,e.id),(_=(u=s.value)==null?void 0:u.state)!=null&&_.hits&&(s.value.state.hits=(g=s==null?void 0:s.value)==null?void 0:g.state.hits.filter(f=>f.id!==e.id)),b({title:r("notifications.companies.delete_member_success")})}catch(f){b({title:r("notifications.companies.delete_member_fail"),description:f.status===403?r("notifications.companies.not_enough_permissions"):void 0,theme:"destructive"}),B(f)}finally{p[e.id]=!1}}return(e,a)=>{var F,V,M,A,S,D,E,O,j,z,I,P,K;const n=ue,u=_e,_=fe,g=ge,f=ke,ee=xe,te=Ce,oe=he;return i(),m("div",null,[!t(R)||!t(s)?(i(),m("div",Ne,[d(n)])):t(L)?(i(),m("div",Be,[h("div",Le,[d(u,{name:"outline_exclamation",class:"mr-2"}),C(" "+y(t(r)("companies.not_enough_permissions")),1)])])):(i(),m("div",Re,[h("div",Fe,[(M=(V=(F=t(c))==null?void 0:F.profile)==null?void 0:V.company)!=null&&M.id?(i(),q(_,{key:0,to:`/companies/${(D=(S=(A=t(c))==null?void 0:A.profile)==null?void 0:S.company)==null?void 0:D.id}`,class:"hover:opacity-80 transition-opacity shrink mr-auto"},{default:$(()=>{var o,k,l;return[C(y((l=(k=(o=t(c))==null?void 0:o.profile)==null?void 0:k.company)==null?void 0:l.name),1)]}),_:1},8,["to"])):w("",!0),h("h2",Ve,y(e.$t("companies.member_title")),1),h("div",Me,[(i(!0),m(G,null,pe((E=t(s))==null?void 0:E.state.hits,(o,k)=>(i(),m(G,{key:o.id},[k?(i(),m("hr",Ae)):w("",!0),h("div",{class:ye(["flex md:items-center gap-3 md:gap-6 md:flex-row flex-col",!!t(p)[o.id]&&"pointer-events-none"])},[d(f,{to:("useLocaleRoute"in e?e.useLocaleRoute:t(U))()(`/users/${o.id}`),class:"hover:opacity-80 transition-opacity md:basis-[250px] shrink",target:"_blank"},{default:$(()=>{var l,T;return[d(g,{title:("getFullName"in e?e.getFullName:t(H))(o)+(((T=(l=t(c))==null?void 0:l.profile)==null?void 0:T.id)===o.id?" "+e.$t("companies.member_you"):""),size:"lg",src:("getAvatar"in e?e.getAvatar:t(be))(o),text:o.job||void 0},null,8,["title","src","text"])]}),_:2},1032,["to"]),d(ee,{modelValue:o.company_roles,"onUpdate:modelValue":l=>o.company_roles=l,name:"companyRoles",options:t(Q),class:"grow w-full md:w-auto text-black md:basis-[300px] shrink-0",disabled:!!t(p)[o.id],placeholder:e.$t("companies.member_role_placeholder"),multiple:"","show-clear-button":!1,onChange:l=>X(o.id,o.company_roles||[])},null,8,["modelValue","onUpdate:modelValue","options","disabled","placeholder","onChange"]),d(te,{size:"xs",theme:"destructive",class:"ml-auto md:ml-0",disabled:!!t(p)[o.id],onClick:l=>Y(o)},{default:$(()=>
1[C(y(e.$t("companies.delete_member_button")),1)]),_:2},1032,["disabled","onClick"])],2)],64))),128)),(j=(O=t(s))==null?void 0:O.state)!=null&&j.hits.length?w("",!0):(i(),m("div",Se,[d(n)])),(I=(z=t(s))==null?void 0:z.state)!=null&&I.loaded&&!((P=t(s))!=null&&P.allRecordsLoaded)?(i(),q(oe,{key:(K=t(s))==null?void 0:K.state.hits.length,onChange:W})):w("",!0)])]),d(we,{ref_key:"deleteConfirm",ref:v,onConfirmed:Z},{default:$(({confirmData:o})=>[C(y(e.$t("companies.confirm_delete_member_text",{name:("getFullName"in e?e.getFullName:t(H))(o)})),1)]),_:1},512)]))])}}});export{Ie as default}; 2//# sourceMappingURL=company-members.CLI5BqpL.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.