File: /home/dmstechonline/whatsapp.dmstech.online/public/build/assets/UserTable-d658bd0d.js
import{T as M,r as C,O as z,o as d,c as w,a as r,w as D,v as L,u as p,b as m,d as j,j as a,g as t,h as o,t as n,f as h,F as T,e as F,n as O,l as U}from"./app-884e4ce3.js";import{d as E}from"./debounce-42603f74.js";import{_ as H}from"./AlertModal-7204a9e7.js";import{u as I}from"./useAlertModal-e78cf661.js";/* empty css */import{_ as Z}from"./Table-fa2f41f4.js";import{T as q,a as P,_ as u}from"./TableHeaderRowItem-d8a183bc.js";import{T as G,a as J,_ as c}from"./TableBodyRowItem-145e00f8.js";import{_ as K}from"./Dropdown-5f5db5e5.js";import{_ as Q,a as $}from"./DropdownItem-ce580ecd.js";const W={class:"md:bg-white flex items-center border border-primary md:border-none md:shadow-sm h-12 md:h-10 md:w-80 rounded-[0.5rem] mb-6 text-xl md:text-sm"},X=["placeholder"],Y={key:1,class:"pr-2"},ee={class:""},te={class:"float-right"},ae={class:"py-1 rounded-[5px] text-xs px-3 bg-[#ddebf7] text-slate-700"},se={class:"float-right"},we={__name:"UserTable",props:{rows:{type:Object,required:!0},filters:{type:Object},type:{type:String},showDeleteBtn:{type:Boolean,default:!0},showRole:{type:Boolean,default:!1}},emits:["delete"],setup(i,{emit:le}){const b=i,{isOpenAlert:y,openAlert:x,confirmAlert:B}=I(),N=M({test:null}),V=e=>{N.delete(b.type==="admin"?"/admin/team/users/"+e:"/admin/users/"+e)},f=C({search:b.filters.search}),v=C(!1),S=()=>{f.value.search=null,_()},A=e=>e===b.rows.data.length-1,g=E(()=>{v.value=!0,_()},1e3),R=e=>e===1?"Active":e===0?"Inactive":e,_=()=>{const e=window.location.pathname;z.visit(e,{method:"get",data:f.value})};return(e,s)=>(d(),w(T,null,[r("div",W,[s[6]||(s[6]=r("span",{class:"pl-3"},[r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24"},[r("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m15 15l6 6m-11-4a7 7 0 1 1 0-14a7 7 0 0 1 0 14Z"})])],-1)),D(r("input",{onInput:s[0]||(s[0]=(...l)=>p(g)&&p(g)(...l)),"onUpdate:modelValue":s[1]||(s[1]=l=>f.value.search=l),type:"text",class:"outline-none px-4 w-full bg-inherit",placeholder:e.$t("Search users")},null,40,X),[[L,f.value.search]]),v.value===!1&&f.value.search?(d(),w("button",{key:0,onClick:S,type:"button",class:"pr-2"},s[4]||(s[4]=[r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},[r("path",{fill:"currentColor",d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10s10-4.5 10-10S17.5 2 12 2zm3.7 12.3c.4.4.4 1 0 1.4c-.4.4-1 .4-1.4 0L12 13.4l-2.3 2.3c-.4.4-1 .4-1.4 0c-.4-.4-.4-1 0-1.4l2.3-2.3l-2.3-2.3c-.4-.4-.4-1 0-1.4c.4-.4 1-.4 1.4 0l2.3 2.3l2.3-2.3c.4-.4 1-.4 1.4 0c.4.4.4 1 0 1.4L13.4 12l2.3 2.3z"})],-1)]))):m("",!0),v.value?(d(),w("span",Y,s[5]||(s[5]=[j('<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="3.5" r="1.5" fill="currentColor" opacity="0"><animateTransform attributeName="transform" calcMode="discrete" dur="2.4s" repeatCount="indefinite" type="rotate" values="0 12 12;90 12 12;180 12 12;270 12 12"></animateTransform><animate attributeName="opacity" dur="0.6s" keyTimes="0;0.5;1" repeatCount="indefinite" values="1;1;0"></animate></circle><circle cx="12" cy="3.5" r="1.5" fill="currentColor" opacity="0"><animateTransform attributeName="transform" begin="0.2s" calcMode="discrete" dur="2.4s" repeatCount="indefinite" type="rotate" values="30 12 12;120 12 12;210 12 12;300 12 12"></animateTransform><animate attributeName="opacity" begin="0.2s" dur="0.6s" keyTimes="0;0.5;1" repeatCount="indefinite" values="1;1;0"></animate></circle><circle cx="12" cy="3.5" r="1.5" fill="currentColor" opacity="0"><animateTransform attributeName="transform" begin="0.4s" calcMode="discrete" dur="2.4s" repeatCount="indefinite" type="rotate" values="60 12 12;150 12 12;240 12 12;330 12 12"></animateTransform><animate attributeName="opacity" begin="0.4s" dur="0.6s" keyTimes="0;0.5;1" repeatCount="indefinite" values="1;1;0"></animate></circle></svg>',1)]))):m("",!0)]),a(Z,{rows:i.rows},{default:t(()=>[a(q,null,{default:t(()=>[a(P,null,{default:t(()=>[a(u,{position:"first"},{default:t(()=>[o(n(e.$t("Name")),1)]),_:1}),a(u,{class:"hidden sm:table-cell"},{default:t(()=>[o(n(e.$t("Email")),1)]),_:1}),a(u,{class:"hidden sm:table-cell"},{default:t(()=>[o(n(e.$t("Phone")),1)]),_:1}),i.type==="admin"||i.showRole===!0?(d(),h(u,{key:0,class:"hidden sm:table-cell"},{default:t(()=>[o(n(e.$t("Role")),1)]),_:1})):m("",!0),a(u,null,{default:t(()=>[r("span",ee,n(e.$t("Status")),1)]),_:1}),a(u,{class:"hidden sm:table-cell"},{default:t(()=>[r("span",te,n(e.$t("Last updated")),1)]),_:1}),a(u,{position:"last"})]),_:1})]),_:1}),a(G,null,{default:t(()=>[(d(!0),w(T,null,F(i.rows.data,(l,k)=>(d(),h(J,{key:k,class:O(A(k)?"":"border-b")},{default:t(()=>[a(c,{position:"first",class:"capitalize"},{default:t(()=>[o(n(l.full_name),1)]),_:2},1024),a(c,{class:"hidden sm:table-cell"},{default:t(()=>[o(n(l.email),1)]),_:2},1024),a(c,{class:"hidden sm:table-cell"},{default:t(()=>[o(n(l.phone??e.$t("N/A")),1)]),_:2},1024),i.type==="admin"||i.showRole===!0?(d(),h(c,{key:0,class:"hidden sm:table-cell capitalize"},{default:t(()=>[o(n(l.role),1)]),_:2},1024)):m("",!0),a(c,{class:"capitalize"},{default:t(()=>[r("span",ae,n(R(l.status)),1)]),_:2},1024),a(c,{class:"hidden sm:table-cell"},{default:t(()=>[r("span",se,n(l.updated_at),1)]),_:2},1024),a(c,{position:"last"},{default:t(()=>[l.role!="admin"?(d(),h(K,{key:0,align:"right",class:"mt-2"},{items:t(()=>[a(Q,null,{default:t(()=>[a($,{href:i.type==="admin"?"/admin/team/users/"+l.id:"/admin/users/"+l.id},{default:t(()=>[o(n(e.$t("View/edit")),1)]),_:2},1032,["href"]),i.showDeleteBtn?(d(),h($,{key:0,as:"button",onClick:re=>p(x)(l.id)},{default:t(()=>[o(n(e.$t("Delete")),1)]),_:2},1032,["onClick"])):m("",!0)]),_:2},1024)]),default:t(()=>[s[7]||(s[7]=r("button",{class:"inline-flex w-full justify-center rounded-md text-sm font-medium text-black hover:bg-opacity-30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75"},[r("span",{class:"hover:bg-[#F6F7F9] hover:rounded-full w-[fit-content] p-2"},[r("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24"},[r("path",{fill:"currentColor",d:"M12 16a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2m0-6a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2Z"})])])],-1))]),_:2},1024)):m("",!0)]),_:2},1024)]),_:2},1032,["class"]))),128))]),_:1})]),_:1},8,["rows"]),a(H,{modelValue:p(y),"onUpdate:modelValue":s[2]||(s[2]=l=>U(y)?y.value=l:null),onConfirm:s[3]||(s[3]=()=>p(B)(V)),label:e.$t("Delete row"),description:e.$t("Are you sure you want to delete this row? This action can not be undone")},null,8,["modelValue","label","description"])],64))}};export{we as _};