import{x as b,o as p,N as h,J as D,a as V,j as $,u as l,ao as U,ap as A,e as B,X as M,c as C,t as E,a5 as N,$ as T,b as w,a9 as S,a8 as L,a1 as R,d as y,s as P,w as j}from"./app-583c7dce.js";import{u as q}from"./useSubmitForm-184dcd88.js";import{A as z}from"./Avatar-173886ec.js";import{u as G}from"./useDeleteModal-484b00a2.js";import{u as K}from"./useEmitter-7699a4d3.js";const x={class:"mb-4"},J={class:"mb-4"},O={__name:"UserInviteModal",props:{modalId:String,tableId:String},emits:["close"],setup(n,{emit:d}){const t=n,c=d,{preloader:_,formData:s,errors:r,save:f,closeModal:g}=q(t,c,"no"),k=()=>{f(A,s.value)};return(o,m)=>{const v=b("app-input"),e=b("app-modal");return p(),h(e,{"modal-id":n.modalId,"modal-size":"large",title:o.$t("invite_user"),preloader:l(_),onSubmit:k,onClose:l(g)},{body:D(()=>[V("div",x,[$(v,{type:"email",id:"email",label:o.$t("email"),"label-required":"",placeholder:o.$t("email"),modelValue:l(s).email,"onUpdate:modelValue":m[0]||(m[0]=a=>l(s).email=a),errors:o.$errors(l(r),"email")},null,8,["label","placeholder","modelValue","errors"])]),V("div",J,[$(v,{type:"advance-search-select",id:"role",listValueField:"name","list-key-field":"id",label:o.$t("role"),"label-required":"",modelValue:l(s).role,"onUpdate:modelValue":m[1]||(m[1]=a=>l(s).role=a),"loading-length":10,"fetch-url":`${l(U)}`,"choose-label":o.$t("choose_a_role"),errors:o.$errors(l(r),"role")},null,8,["label","modelValue","fetch-url","choose-label","errors"])])]),_:1},8,["modal-id","title","preloader","onClose"])}}},X={class:"d-flex align-items-center"},H={class:"name mx-2 fw-semibold"},Q={__name:"UserAvatarComponent",props:{rowData:{}},setup(n){const d=n,t=B(()=>{if(d.rowData.profile_picture)return M(d.rowData.profile_picture.path)});return(c,_)=>{var s,r;return p(),C("div",X,[$(z,{image:t.value,name:n.rowData.full_name,active:(r=(s=n.rowData)==null?void 0:s.status)==null?void 0:r.class},null,8,["image","name","active"]),V("div",H,E(n.rowData.full_name),1)])}}},W={class:"content-wrapper"},le={__name:"UserList",setup(n){const{canAccess:d}=N(),{t}=T(),c=w("user-table"),_=w(!1),s=w({url:S,pageSize:5,rowLimit:10,orderBy:"desc",showGridView:!1,actionType:"dropdown",paginationType:"pagination",enableRowSelect:!1,enableBulkSelect:!1,showSearch:!0,showFilter:!0,columns:[{title:t("name"),type:"component",key:"full_name",componentName:L(Q)},{title:t("email"),type:"text",key:"email"},{title:t("role"),type:"object",key:"role",modifier:e=>e?e.name:"-"},{title:t("status"),type:"custom-html",key:"status",modifier:e=>`<span class="badge bg-${e.class}">${e.translated_name}</span>`},{title:t("action"),type:"action",align:"right"}],filters:[{label:t("status"),type:"search-select",key:"status",options:[{id:1,name:t("active")},{id:2,name:t("de_activate")},{id:3,name:t("status_invited")}],listKeyField:"id",listValueField:"name",showSearch:!1,permission:!0},{type:"advance-search-select",key:"role",label:"role",listKeyField:"id",listValueField:"name",rowPerLoad:10,fetchUrl:`${U}`,permission:!0}],actions:[{title:t("active"),icon:"bi bi-record-circle-fill",type:"active",modifier:e=>!e.is_admin&&e.status.name!=="status_invited"&&e.status.name!="status_active"},{title:t("inactive"),icon:"bi bi-slash-circle-fill",type:"de_activate",modifier:e=>!e.is_admin&&e.status.name!=="status_invited"&&e.status.name!="status_inactive"},{title:t("delete"),icon:"bi bi-trash3",type:"delete",modifier:e=>!e.is_admin}]}),{deleteUrl:r,isDeleteModal:f,cancelled:g}=G(),k=(e,a)=>{a.type==="active"?v(e,"status_active"):a.type==="de_activate"?v(e,"status_inactive"):a.type==="delete"&&(f.value=!0,r.value=`${S}/${e.id}`)},o=K(),m=R(),v=(e,a)=>{P.patch(`${S}/${e.id}`,{status_name:a}).then(i=>{var u;m.success((u=i==null?void 0:i.data)==null?void 0:u.message),o.emit("reload-"+c.value)}).catch(({response:i})=>{var u;i.status===403&&m.error((u=i==null?void 0:i.data)==null?void 0:u.message)})};return(e,a)=>{const i=b("app-breadcrumb"),u=b("app-datatable"),I=b("app-delete-modal");return p(),C("div",W,[$(i,{"page-title":e.$t("users_management")},{"breadcrumb-actions":D(()=>[l(d)("manage_user_invite")?(p(),C("button",{key:0,onClick:a[0]||(a[0]=j(F=>_.value=!0,["prevent"])),class:"btn btn-primary text-white"},E(e.$t("invite_user")),1)):y("",!0)]),_:1},8,["page-title"]),l(d)("view_users")?(p(),h(u,{key:0,id:c.value,options:s.value,onAction:k},null,8,["id","options"])):y("",!0),_.value?(p(),h(O,{key:1,"modal-id":"user-invite-modal","table-id":c.value,onClose:a[1]||(a[1]=F=>_.value=!1)},null,8,["table-id"])):y("",!0),l(f)?(p(),h(I,{key:2,"table-id":c.value,"selected-url":l(r),onCancelled:l(g)},null,8,["table-id","selected-url","onCancelled"])):y("",!0)])}}};export{le as default};
