1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3271],{15261:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>g});var a=s(3576),r=s(62701),l=s(37876),n=s(14232),i=s(23946),d=s(47043),c=s(11629),o=s(48306),x=s(21677),m=s(54196),u=s(20118);let g=()=>{let[e,t]=(0,n.useState)([]),[s,g]=(0,n.useState)(!0),[h,p]=(0,n.useState)({}),[b,y]=(0,n.useState)({modules:[],actions:[],admins:[]}),[f,v]=(0,n.useState)({page:1,limit:20,adminId:"",module:"",action:"",startDate:"",endDate:"",search:"",sortBy:"createdAt",sortOrder:"desc"}),[j,N]=(0,n.useState)(!1),w=async()=>{g(!0);try{let e=new URLSearchParams;Object.entries(f).forEach(t=>{let[s,a]=t;a&&e.append(s,a)});let s=localStorage.getItem("admin_token").replaceAll('"',""),a=await fetch("".concat(m.Qs,"admin-log/get?").concat(e),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(s)}}),r=await a.json();console.log(r),r.status&&(t(r.data.logs),p(r.data.pagination),y(r.data.filters))}catch(e){console.error("Error fetching logs:",e)}finally{g(!1)}};(0,n.useEffect)(()=>{w()},[f]);let A=(e,t)=>{v(s=>(0,r._)((0,a._)({},s),{[e]:t,page:1}))},k=e=>{v(t=>(0,r._)((0,a._)({},t),{page:e}))},_=e=>{let t=f.sortBy===e&&"desc"===f.sortOrder?"asc":"desc";v(s=>(0,r._)((0,a._)({},s),{sortBy:e,sortOrder:t}))};return(0,l.jsx)(u.default,{children:(0,l.jsx)("div",{className:"pt-5 px-5 overflow-x-auto h-full bg-BG1 bg-cover",children:(0,l.jsx)("div",{className:"min-h-full bg-gray-50 p-6",children:(0,l.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,l.jsxs)("div",{className:"mb-8",children:[(0,l.jsx)("h1",{className:"text-3xl font-bold text-gray-900",children:"Admin Activity Logs"}),(0,l.jsx)("p",{className:"text-gray-600 mt-2",children:"Monitor and track all administrative activities"})]}),(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 mb-6",children:[(0,l.jsx)("div",{className:"p-4 border-b border-gray-200",children:(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,l.jsxs)("button",{onClick:()=>N(!j),className:"flex items-center space-x-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:[(0,l.jsx)(i.A,{className:"w-4 h-4"}),(0,l.jsx)("span",{children:"Filters"})]}),(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)(d.A,{className:"w-5 h-5 absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"}),(0,l.jsx)("input",{type:"text",placeholder:"Search ...",value:f.search,onChange:e=>A("search",e.target.value),className:"pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent w-64"})]})]}),(0,l.jsxs)("button",{onClick:()=>{v({page:1,limit:20,adminId:"",module:"",action:"",startDate:"",endDate:"",search:"",sortBy:"createdAt",sortOrder:"desc"})},className:"flex items-center space-x-2 px-4 py-2 text-gray-600 hover:text-gray-800 border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[(0,l.jsx)(c.A,{className:"w-4 h-4"}),(0,l.jsx)("span",{children:"Clear All"})]})]})}),j&&(0,l.jsx)("div",{className:"p-4 bg-gray-50 border-t border-gray-200",children:(0,l.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Module"}),(0,l.jsxs)("select",{value:f.module,onChange:e=>A("module",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[(0,l.jsx)("option",{value:"",children:"All Modules"}),b.modules.map(e=>(0,l.jsx)("option",{value:e,children:e},e))]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Action"}),(0,l.jsxs)("select",{value:f.action,onChange:e=>A("action",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[(0,l.jsx)("option",{value:"",children:"All Actions"}),b.actions.map(e=>(0,l.jsx)("option",{value:e,children:e},e))]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Admin"}),(0,l.jsxs)("select",{value:f.adminId,onChange:e=>A("adminId",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[(0,l.jsx)("option",{value:"",children:"All Admins"}),b.admins&&b.admins.map(e=>(0,l.jsxs)("option",{value:e._id,children:[e.name," (",e.email,")"]},e._id))]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Start Date"}),(0,l.jsx)("input",{type:"date",value:f.startDate,onChange:e=>A("startDate",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"End Date"}),(0,l.jsx)("input",{type:"date",value:f.endDate,onChange:e=>A("endDate",e.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]})]})})]}),(0,l.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,l.jsxs)("p",{className:"text-sm text-gray-600",children:["Showing ",e.length," of ",h.totalLogs," results"]}),(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,l.jsx)("label",{className:"text-sm text-gray-600",children:"Show:"}),(0,l.jsxs)("select",{value:f.limit,onChange:e=>A("limit",e.target.value),className:"px-3 py-1 border border-gray-300 rounded text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[(0,l.jsx)("option",{value:"10",children:"10"}),(0,l.jsx)("option",{value:"20",children:"20"}),(0,l.jsx)("option",{value:"50",children:"50"}),(0,l.jsx)("option",{value:"100",children:"100"})]})]})]}),(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden",children:[s?(0,l.jsxs)("div",{className:"p-8 text-center",children:[(0,l.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"}),(0,l.jsx)("p",{className:"text-gray-600 mt-2",children:"Loading logs..."})]}):(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,l.jsx)("thead",{className:"bg-gray-50",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{onClick:()=>_("createdAt"),className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:bg-gray-100",children:(0,l.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,l.jsx)("span",{children:"Timestamp"}),"createdAt"===f.sortBy&&(0,l.jsx)("span",{className:"text-blue-600",children:"desc"===f.sortOrder?"â":"â"})]})}),(0,l.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Admin"}),(0,l.jsx)("th",{onClick:()=>_("module"),className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:bg-gray-100",children:(0,l.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,l.jsx)("span",{children:"Module"}),"module"===f.sortBy&&(0,l.jsx)("span",{className:"text-blue-600",children:"desc"===f.sortOrder?"â":"â"})]})}),(0,l.jsx)("th",{onClick:()=>_("action"),className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:bg-gray-100",children:(0,l.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,l.jsx)("span",{children:"Action"}),"action"===f.sortBy&&(0,l.jsx)("span",{className:"text-blue-600",children:"desc"===f.sortOrder?"â":"â"})]})}),(0,l.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Target"}),(0,l.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Description"}),(0,l.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"IP Address"})]})}),(0,l.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:e.map(e=>{var t,s;return(0,l.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,l.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:new Date(e.createdAt).toLocaleStr
1ing("en-US",{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,l.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap",children:[(0,l.jsx)("div",{className:"text-sm font-medium text-gray-900",children:(null==e||null==(t=e.adminId)?void 0:t.name)||"Unknown"}),(0,l.jsx)("div",{className:"text-sm text-gray-500",children:null==e||null==(s=e.adminId)?void 0:s.email})]}),(0,l.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,l.jsx)("span",{className:"inline-flex px-2 py-1 text-xs font-semibold rounded-full bg-indigo-100 text-indigo-800",children:null==e?void 0:e.module})}),(0,l.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,l.jsx)("span",{className:"inline-flex px-2 py-1 text-xs font-semibold rounded-full ".concat({create:"bg-green-100 text-green-800",edit:"bg-blue-100 text-blue-800",delete:"bg-red-100 text-red-800",login:"bg-purple-100 text-purple-800",generate:"bg-yellow-100 text-yellow-800",view:"bg-gray-100 text-gray-800"}[(null==e?void 0:e.action).toLowerCase()]||"bg-gray-100 text-gray-800"),children:null==e?void 0:e.action})}),(0,l.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:"".concat((null==e?void 0:e.module)==="Login"?"Login Time":null==e?void 0:e.targetLabel," :- ").concat(null==e?void 0:e.targetId)}),(0,l.jsx)("td",{className:"px-6 py-4 text-sm text-gray-900 max-w-xs truncate",title:null==e?void 0:e.description,children:(null==e?void 0:e.description)||"-"}),(0,l.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.ipAddress})]},e._id)})})]})}),!s&&0===e.length&&(0,l.jsx)("div",{className:"p-8 text-center",children:(0,l.jsx)("p",{className:"text-gray-500",children:"No logs found matching your criteria."})})]}),h.totalPages>1&&(0,l.jsxs)("div",{className:"mt-6 flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"text-sm text-gray-700",children:["Page ",h.currentPage," of ",h.totalPages]}),(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,l.jsxs)("button",{onClick:()=>k(h.currentPage-1),disabled:!h.hasPrev,className:"flex items-center px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:[(0,l.jsx)(o.A,{className:"w-4 h-4 mr-1"}),"Previous"]}),(0,l.jsx)("div",{className:"flex items-center space-x-1",children:Array.from({length:Math.min(5,h.totalPages)},(e,t)=>{let s=Math.max(1,h.currentPage-2)+t;return s>h.totalPages?null:(0,l.jsx)("button",{onClick:()=>k(s),className:"px-3 py-2 text-sm font-medium rounded-lg ".concat(s===h.currentPage?"bg-blue-600 text-white":"text-gray-500 bg-white border border-gray-300 hover:bg-gray-50"),children:s},s)})}),(0,l.jsxs)("button",{onClick:()=>k(h.currentPage+1),disabled:!h.hasNext,className:"flex items-center px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",children:["Next",(0,l.jsx)(x.A,{className:"w-4 h-4 ml-1"})]})]})]})]})})})})}},20118:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>c});var a=s(37876),r=s(14232),l=s(35793),n=s(14e3),i=s(14173),d=s(82392);let c=e=>{let{children:t}=e,s=(0,n.usePathname)(),c=(null==s?void 0:s.startsWith("/"))?s.slice(1):s,{hasPermission:o,permissions:x,isSuperAdmin:m,loading:u,adminData:g}=(0,i.A)(),[h,p]=(0,r.useState)(!1),[b,y]=(0,r.useState)(!0),f=(0,n.useRouter)();return((0,r.useEffect)(()=>{if(p(!0),u)return;if(!localStorage.getItem("admin_token"))return void f.replace("/admin");if((null==g?void 0:g.role)==="IPMASTER"||(null==g?void 0:g.email)==="[email protected]")return c.startsWith("admin/ip-management")?void y(!1):void f.push("/admin/ip-management");if(m)return void y(!1);if(!x||0===x.length)return void f.push("/admin/no-access");let e=[...l.W,...l.D].filter(e=>e.href).sort((e,t)=>t.href.length-e.href.length).find(e=>c.startsWith(e.href)),t=e?e.permission||e.name:null;if(e&&t&&o(t,"view"))return void y(!1);if(o("Dashboard","view"))return void f.push("/admin/dashboard");let s=[...l.W,...l.D].find(e=>e.name&&o(e.name,"view"));if(s)return void f.push(s.href);f.push("/admin/no-access")},[u,x,m,c,o,f]),!h||b)?null:(0,a.jsxs)("div",{className:"flex bg-gray-100",children:[(0,a.jsx)(d.default,{}),(0,a.jsx)("div",{className:"pt-16 px-10 overflow-x-auto w-full h-screen",children:(0,a.jsx)("main",{className:"flex-1 overflow-x-hidden overflow-y-auto bg-gray-100",children:t})})]})}},95897:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/admin-logs",function(){return s(15261)}])}},e=>{e.O(0,[4e3,8230,4587,7330,2392,636,6593,8792],()=>e(e.s=95897)),_N_E=e.O()}]);
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.