import{a,y as o,j as e}from"./BulkImageUpload-DGPbX05r.js";import{A as p}from"./Authenticated-DQno4VYw.js";import{P as b}from"./PageTitle-feHaMeNG.js";import{P as k}from"./Panel-CCKAj23D.js";import{P as y}from"./Pagination-C_2iCAT4.js";import{S as u}from"./sweetalert2.all-CGGHY7K6.js";import{u as S,p as x}from"./pickBy-DfvVpiMz.js";import"./bootstrap.esm-e_F80uXB.js";const I=t=>{a.useState(t.package);const[i,d]=a.useState(t.users.data),[P,h]=a.useState(""),[m,j]=a.useState(t.users.links),[r,f]=a.useState({pack:"",key:""}),v=S(r);a.useEffect(()=>{if(v){const s=Object.keys(x(r)).length?x(r):{remember:"forget"};o.get(route(route().current()),s,{replace:!0,preserveState:!0})}},[r]),a.useEffect(()=>{t.update!="noupdate"&&(d(t.users.data),j(t.users.links)),t.users.links&&t.users.links.map(s=>{s.active&&h(parseInt(s.label))})},[t.users]);function N(s){const c=s.target.name,l=s.target.value;f(n=>({...n,[c]:l}))}const g=s=>()=>{u.fire({title:"Are you sure want to Delete?",icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, delete!"}).then(c=>{c.isConfirmed&&o.delete(route("remove-user",s),{onSuccess:()=>{d(l=>l.filter(n=>n.id!=s)),u.fire("Deleted!","User Removed Successfully","success")},preserveState:!0})})};return e.jsxs(p,{auth:t.auth,errors:t.errors,current:t.current,children:[e.jsx(b,{title:"Manage Users",path:"Users",pathurl:""}),e.jsxs(k,{title:"Manage Users",md:"12",children:[e.jsxs("div",{className:"row pt-2 pb-2 form-group m-0",children:[e.jsx("div",{className:"col-md-3 pe-1"}),e.jsx("div",{className:"col-md-3 pe-1"}),e.jsx("div",{className:"col-md-3 pe-1"}),e.jsx("div",{className:"col-md-3 pe-2",children:e.jsx("input",{type:"text",onChange:N,value:r.key,placeholder:"Search User",name:"key",className:"form-control"})})]}),e.jsx("div",{className:"table-responsive-md",children:e.jsx("table",{className:"table mb-0 ",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("th",{className:"slno text-center",children:"ID"}),e.jsx("th",{children:"Image"}),e.jsx("th",{children:"User Name"}),e.jsx("th",{children:"Email Address"}),e.jsx("th",{className:"text-center",children:"Mobile Number"}),e.jsx("th",{className:"center",children:"Active Plan"}),e.jsx("th",{className:"text-center",children:"Action"})]}),i&&i.map((s,c)=>e.jsxs("tr",{children:[e.jsx("td",{className:"text-center",children:s.id}),e.jsx("td",{children:e.jsx("img",{className:"rounded",style:{width:"40px"},src:"./../../assets/admin/images/person.jpg",alt:""})}),e.jsx("td",{children:s.name}),e.jsx("td",{children:s.email}),e.jsx("td",{className:"text-center",children:s.mobile}),e.jsx("td",{className:"text-center",children:s.plan}),e.jsx("td",{className:"text-center",children:e.jsxs("button",{disabled:s.role=="admin",onClick:g(s.id),className:"btn btn-danger me-2 btn-xs",children:[e.jsx("i",{className:"bi bi-trash3"})," Delete"]})})]},c))]})})}),m.length===3?"":e.jsx("div",{className:"card-footer",children:e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-md-6 pt-2"}),e.jsx("div",{className:"col-md-6",children:e.jsx(y,{links:m})})]})})]})]})};export{I as default};
