PageSourceSearch

https://www.downundervisa.com/assets/index-D8E6Wi9q.js

js downundervisa.com collected 2026-10-09 05:21:49 UTC 9,456 bytes, 1 lines download raw bytes

1import{V as L,u as $,r as o,j as e,L as c,X as M,Y as I,Z as B,_ as V}from"./main-Bo0oayNO.js";import{f as F}from"./index-ThM9GGfP.js";function H(){const{users:j,pagination:n}=L.useLoaderData(),a=L.useSearch(),g=$(),[r,d]=o.useState([]),[u,N]=o.useState(!1),[b,v]=o.useState(!1),[k,w]=o.useState(!1),[f,D]=o.useState("date"),[y,C]=o.useState("desc"),x=a.status==="trash",m=s=>{f===s?C(y==="asc"?"desc":"asc"):(D(s),C("asc"))},h=({field:s})=>e.jsx("span",{className:"ml-1 inline-block",children:f===s?y==="asc"?e.jsx("svg",{className:"w-4 h-4 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})}):e.jsx("svg",{className:"w-4 h-4 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):e.jsx("svg",{className:"w-4 h-4 inline opacity-30",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})})}),p=[...j].sort((s,t)=>{let i,l;switch(f){case"user":i=(s.displayName||s.username).toLowerCase(),l=(t.displayName||t.username).toLowerCase();break;case"email":i=s.email.toLowerCase(),l=t.email.toLowerCase();break;case"role":i=s.role,l=t.role;break;case"status":i=s.deletedAt?2:s.isActive?0:1,l=t.deletedAt?2:t.isActive?0:1;break;case"date":i=new Date(s.createdAt).getTime(),l=new Date(t.createdAt).getTime();break}return i<l?y==="asc"?-1:1:i>l?y==="asc"?1:-1:0}),U=s=>{s.target.checked?d(p.map(t=>t.id)):d([])},T=s=>{d(t=>t.includes(s)?t.filter(i=>i!==s):[...t,s])},S=async()=>{if(r.length===0)return;const s=x?`Permanently delete ${r.length} users? This cannot be undone.`:`Move ${r.length} users to trash?`;if(confirm(s)){N(!0);try{x?await I({data:r}):await B({data:r}),d([]),g({to:"/admin/users",search:a})}finally{N(!1)}}},R=async()=>{if(r.length!==0&&confirm(`Restore ${r.length} users from trash?`)){v(!0);try{await M({data:r}),d([]),g({to:"/admin/users",search:a})}finally{v(!1)}}},E=async()=>{if(confirm("Permanently delete all users in trash? This cannot be undone.")){w(!0);try{await V(),g({to:"/admin/users",search:a})}finally{w(!1)}}},P=s=>{s.preventDefault();const t=new FormData(s.currentTarget);g({to:"/admin/users",search:{...a,search:t.get("search"),page:1}})},A={administrator:"bg-red-100 text-red-800",editor:"bg-purple-100 text-purple-800",author:"bg-blue-100 text-blue-800",contributor:"bg-green-100 text-green-800",subscriber:"bg-gray-100 text-gray-800"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Users"}),e.jsx("p",{className:"text-gray-600",children:"Manage user accounts"})]}),e.jsxs(c,{to:"/admin/users/new",className:"btn-primary",children:[e.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add New User"]})]}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{className:"flex gap-2",children:["active","trash"].map(s=>e.jsx(c,{to:"/admin/users",search:{...a,status:s,role:"all",page:1},className:`px-3 py-1.5 text-sm font-medium rounded-lg transition-colors ${a.status===s?s==="trash"?"bg-red-100 text-red-700":"bg-primary-100 text-primary-700":"text-gray-600 hover:bg-gray-100"}`,children:s.charAt(0).toUpperCase()+s.slice(1)},s))}),!x&&e.jsx("div",{className:"flex gap-2",children:["all","administrator","editor","author","contributor","subscriber"].map(s=>e.jsx(c,{to:"/admin/users",search:{...a,role:s,page:1},className:`px-3 py-1.5 text-sm font-medium rounded-lg transition-colors ${a.role===s?"bg-primary-100 text-primary-700":"text-gray-600 hover:bg-gray-100"}`,children:s.charAt(0).toUpperCase()+s.slice(1)},s))})]}),e.jsxs("form",{onSubmit:P,className:"flex gap-2",children:[e.jsx("input",{type:"text",name:"search",defaultValue:a.search,placeholder:"Search users...",className:"input w-64"}),e.jsx("button",{type:"submit",className:"btn-secondary",children:"Search"})]})]})}),r.length>0&&e.jsxs("div",{className:"card p-4 bg-gray-50 flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[r.length," selected"]}),x?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,disabled:b,className:"btn-secondary text-sm",children:b?"Restoring...":"Restore Selected"}),e.jsx("button",{onClick:S,disabled:u,className:"btn-danger text-sm",children:u?"Deleting...":"Delete Permanently"})]}):e.jsx("button",{onClick:S,disabled:u,className:"btn-danger text-sm",children:u?"Moving...":"Move to Trash"}),e.jsx("button",{onClick:()=>d([]),className:"text-sm text-gray-600 hover:text-gray-900",children:"Clear selection"})]}),x&&j.length>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:E,disabled:k,className:"btn-danger text-sm",children:k?"Emptying...":"Empty Trash"})}),e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-12 px-6 py-3",children:e.jsx("input",{type:"checkbox",checked:r.length===p.length&&p.length>0,onChange:U,className:"h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded-sm"})}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>m("user"),children:["User",e.jsx(h,{field:"user"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>m("email"),children:["Email",e.jsx(h,{field:"email"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>m("role"),children:["Role",e.jsx(h,{field:"role"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>m("status"),children:["Status",e.jsx(h,{field:"status"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>m("date"),children:["Registered",e.jsx(h,{field:"date"})]}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:p.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-12 text-center text-gray-500",children:"No users found."})}):p.map(s=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("input",{type:"checkbox",checked:r.includes(s.id
1),onChange:()=>T(s.id),className:"h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded-sm"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"w-8 h-8 bg-gray-200 rounded-full flex items-center justify-center overflow-hidden",children:s.avatarUrl?e.jsx("img",{src:s.avatarUrl,alt:s.displayName||s.username,className:"w-8 h-8 rounded-full object-cover"}):e.jsx("span",{className:"text-sm font-medium text-gray-600",children:s.displayName?.[0]?.toUpperCase()||s.username[0].toUpperCase()})}),e.jsxs("div",{className:"ml-3",children:[e.jsx(c,{to:"/admin/users/$id",params:{id:s.id},className:"text-gray-900 font-medium hover:text-primary-600",children:s.displayName||s.username}),e.jsxs("p",{className:"text-sm text-gray-500",children:["@",s.username]})]})]})}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:s.email}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full capitalize ${A[s.role]||A.subscriber}`,children:s.role})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${s.deletedAt?"bg-red-100 text-red-800":s.isActive?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:s.deletedAt?"Deleted":s.isActive?"Active":"Inactive"})}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:F(s.createdAt)}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx(c,{to:"/admin/users/$id",params:{id:s.id},className:"text-primary-600 hover:text-primary-900 text-sm font-medium",children:"Edit"})})]},s.id))})]})}),n.totalPages>1&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Page ",n.page," of ",n.totalPages," (",n.total," users)"]}),e.jsxs("div",{className:"flex gap-2",children:[n.page>1&&e.jsx(c,{to:"/admin/users",search:{...a,page:n.page-1},className:"btn-secondary",children:"Previous"}),n.page<n.totalPages&&e.jsx(c,{to:"/admin/users",search:{...a,page:n.page+1},className:"btn-secondary",children:"Next"})]})]})]})}export{H as component};

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.