| Current Path : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/ |
| Current File : /home/users/unlimited/www/admin.medimeet.codeskitter.site/assets/Index-C5n0xcQU.js |
import{J as R,y as v,r as c,Q as z,j as e,B as u,x as U,C as D,F as b}from"./index-f5FVPPWf.js";import{F as L}from"./index-NjlW3JBs.js";import{e as Q}from"./index-D-rZ_zLU.js";import{u as k}from"./SettingData-HUsgVeqA.js";import{u as q,N as G,S as r,D as N,P as W}from"./Dashboard-QYea_GjR.js";import{u as C}from"./HasPermission-D75jcuOi.js";import{u as K}from"./index.esm-CxKpqEdJ.js";import{F as m,I as O}from"./input-aKY8cD2r.js";import{R as V,a as y}from"./radio-88K8k4LS.js";import{I as _}from"./index-B8iLT9XL.js";import"./image-DDwLQVjO.js";import"./tr-SHTCPR9-.js";import"./use-clickable-DJbYv-Vn.js";import"./visually-hidden.style-BrEqndXz.js";import"./split-CzYrjwZo.js";const H=async()=>(await R(v.token,"get_roles")).data,J=()=>{const{isLoading:t,data:s,error:a}=k({queryKey:["Roles"],queryFn:H});return{rolesData:s,rolesLoading:t,rolesError:a}},P=50,X=(t,s)=>{const a=(t-1)*s,n=a+s-1;return{startIndex:a,endIndex:n}},Z=t=>t==null?void 0:t.map(s=>{const{id:a,f_name:n,l_name:i,phone:l,gender:j,dob:h,email:p,image:x,wallet_amount:g,created_at:f}=s;return{id:a,image:x,name:`${n} ${i}`,Phone:`${l}`,Gender:j,DateOfBirth:D(h).format("DD MMM YYYY"),Email:p,"Wallet Balance":g,CreatedAt:D(f).format("DD MMM YYYY hh:mm a")}});function pe(){const[t,s]=c.useState(),a=z(),{hasPermission:n}=C(),i=K(),[l,j]=c.useState(1),[h,p]=c.useState(""),x=q(h,1e3),{startIndex:g,endIndex:f}=X(l,P),E=c.useRef(null),{rolesData:I,rolesLoading:A}=J(),[w,Y]=c.useState(""),F=async()=>{const o=await R(v.token,`get_users/page?start=${g}&end=${f}&search=${x}&role_id=${w}`);return{data:o.data,total_record:o.total_record}},{isLoading:M,data:d,error:S}=k({queryKey:["users",l,x,w],queryFn:F}),$=o=>{j(o)},B=Math.ceil((d==null?void 0:d.total_record)/P),T=o=>(s(o),t);return c.useEffect(()=>{E.current&&E.current.scrollIntoView({behavior:"smooth",block:"start"})},[l]),c.useEffect(()=>{S&&!i.isActive("Errortoast")&&i({id:"Errortoast",title:"Oops!",description:"Something bad happened.",status:"error",duration:2e3,isClosable:!0,position:"top"})},[S,i]),n("USER_VIEW")?e.jsxs(u,{children:[M||!d||A?e.jsxs(u,{children:[e.jsxs(m,{mb:5,justify:"space-between",children:[e.jsx(r,{w:400,h:8}),e.jsx(r,{w:200,h:8})]}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2}),e.jsx(r,{h:10,w:"100%",mt:2})]}):e.jsxs(u,{children:[e.jsxs(m,{mb:5,justify:"space-between",align:"center",children:[e.jsx(O,{size:"md",placeholder:"Search",w:400,maxW:"50vw",onChange:o=>p(o.target.value),value:h}),e.jsx(u,{children:e.jsx(U,{isDisabled:!n("USER_ADD"),size:"sm",colorScheme:"blue",onClick:()=>{a("/users/add")},children:"Add New"})})]}),e.jsx(u,{my:2,children:e.jsx(V,{onChange:Y,value:w,children:e.jsxs(m,{direction:"row",gap:4,wrap:"wrap",children:[e.jsx(y,{value:"",children:"All"}),I.map(o=>e.jsx(y,{value:o.id.toString(),children:o.name},o.id))]})})}),e.jsx(N,{minPad:"1px 20px",data:Z(d.data),onActionClick:e.jsx(ee,{onClick:T,navigate:a})})]}),e.jsx(m,{justify:"center",mt:4,children:e.jsx(W,{currentPage:l,onPageChange:$,totalPages:B})})]}):e.jsx(G,{})}const ee=({onClick:t,rowData:s,DeleteonOpen:a,navigate:n})=>{const{hasPermission:i}=C();return e.jsxs(m,{justify:"center",children:[e.jsx(_,{isDisabled:!i("USER_UPDATE"),size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{t(s),n(`/user/update/${s.id}`)},icon:e.jsx(Q,{fontSize:18,color:b.colors.blue[500]})}),e.jsx(_,{isDisabled:!i("USER_DELETE"),size:"sm",variant:"ghost",_hover:{background:"none"},onClick:()=>{t(s),a()},icon:e.jsx(L,{fontSize:18,color:b.colors.red[500]})})]})};export{pe as default};