1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2496],{32453:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/audit-logs",function(){return a(8378)}])},39200:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(63759).Z)("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},60493:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(63759).Z)("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},61258:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(63759).Z)("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]])},4307:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(63759).Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},18289:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(63759).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},44976:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(63759).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},36127:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(63759).Z)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},9475:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});let s=(0,a(63759).Z)("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},8378:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return v}});var s=a(85893),l=a(67294),i=a(9008),r=a.n(i),d=a(11163),n=a(85412),c=a(67694),o=a(60493),u=a(9475),x=a(39200),m=a(92761),h=a(73416),p=a(44976),b=a(36127),g=a(18289),y=a(61258),f=a(4307);let j={success:{icon:o.Z,color:"text-emerald-500",bg:"bg-emerald-500/10"},failure:{icon:u.Z,color:"text-red-500",bg:"bg-red-500/10"},denied:{icon:x.Z,color:"text-amber-500",bg:"bg-amber-500/10"}};function v(){let{theme:e}=(0,c.F)(),t=(0,d.useRouter)(),[a,i]=(0,l.useState)([]),[o,u]=(0,l.useState)(!1),[x,v]=(0,l.useState)(""),[N,w]=(0,l.useState)(null),[k,Z]=(0,l.useState)([null]),[C,S]=(0,l.useState)(""),[_,A]=(0,l.useState)(""),[q,T]=(0,l.useState)(""),[E,I]=(0,l.useState)(""),[L,M]=(0,l.useState)(""),[P,R]=(0,l.useState)(""),O="dark"===e,z=(0,l.useCallback)(async e=>{u(!0),v("");try{let t=new URLSearchParams;C&&t.set("action",C),_&&t.set("actorEmail",_),q&&t.set("outcome",q),E&&t.set("from",new Date(E).toISOString()),L&&t.set("to",new Date(L).toISOString());let a=P.trim();a.length>=4&&t.set("requestId",a),e&&t.set("cursor",e),t.set("limit","50");let s=await fetch("/api/admin/audit-logs?".concat(t.toString()),{credentials:"include"});if(!s.ok)throw Error("HTTP ".concat(s.status));let l=await s.json();i(l.logs||[]),w(l.nextCursor||null)}catch(e){v((null==e?void 0:e.message)||"Failed to load audit logs")}finally{u(!1)}},[C,_,q,E,L,P]);(0,l.useEffect)(()=>{z(null),Z([null])},[]);let D=e=>{try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch(t){return e}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(r(),{children:[(0,s.jsx)("title",{children:"Audit Logs â Admin \xb7 TrueResume"}),(0,s.jsx)("meta",{name:"robots",content:"noindex,nofollow"})]}),(0,s.jsxs)("div",{className:"min-h-screen pt-14 sm:pt-16 ".concat(O?"bg-slate-950 text-slate-100":"bg-slate-50 text-slate-900"),"data-testid":"admin-audit-logs-page",children:[(0,s.jsx)(n.Z,{}),(0,s.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("button",{onClick:()=>t.push("/admin"),className:"flex items-center gap-2 text-sm opacity-70 hover:opacity-100 mb-2","data-testid":"admin-audit-back-btn",children:[(0,s.jsx)(m.Z,{className:"w-4 h-4"})," Back to Admin"]}),(0,s.jsxs)("h1",{className:"text-3xl font-bold flex items-center gap-3",children:[(0,s.jsx)(h.Z,{className:"w-8 h-8 text-brand-500"}),"Audit Logs"]}),(0,s.jsxs)("p",{className:"text-sm opacity-70 mt-1",children:["Append-only audit trail. SOC 2 / GDPR Article 30 compliant. Use Trace to match the"," ",(0,s.jsx)("code",{className:"text-xs opacity-90",children:"x-request-id"})," response header from the browser network tab."]})]}),(0,s.jsxs)("button",{onClick:()=>z(k[k.length-1]),disabled:o,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-brand-500 hover:bg-brand-600 text-white disabled:opacity-50 transition","data-testid":"admin-audit-refresh-btn",children:[(0,s.jsx)(p.Z,{className:"w-4 h-4 ".concat(o?"animate-spin":"")}),"Refresh"]})]}),(0,s.jsxs)("div",{className:"rounded-xl border p-4 mb-6 ".concat(O?"bg-slate-900 border-slate-800":"bg-white border-slate-200"),children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-3",children:[(0,s.jsx)("input",{type:"text",placeholder:"Action (e.g. auth.login.failed)",value:C,onChange:e=>S(e.target.value),className:"px-3 py-2 rounded-lg border text-sm ".concat(O?"bg-slate-800 border-slate-700":"bg-slate-50 border-slate-300"),"data-testid":"admin-audit-filter-action"}),(0,s.jsx)("input",{type:"text",placeholder:"Actor email contains...",value:_,onCh
1ange:e=>A(e.target.value),className:"px-3 py-2 rounded-lg border text-sm ".concat(O?"bg-slate-800 border-slate-700":"bg-slate-50 border-slate-300"),"data-testid":"admin-audit-filter-email"}),(0,s.jsxs)("select",{value:q,onChange:e=>T(e.target.value),className:"px-3 py-2 rounded-lg border text-sm ".concat(O?"bg-slate-800 border-slate-700":"bg-slate-50 border-slate-300"),"data-testid":"admin-audit-filter-outcome",children:[(0,s.jsx)("option",{value:"",children:"Any outcome"}),(0,s.jsx)("option",{value:"success",children:"success"}),(0,s.jsx)("option",{value:"failure",children:"failure"}),(0,s.jsx)("option",{value:"denied",children:"denied"})]}),(0,s.jsx)("input",{type:"datetime-local",value:E,onChange:e=>I(e.target.value),className:"px-3 py-2 rounded-lg border text-sm ".concat(O?"bg-slate-800 border-slate-700":"bg-slate-50 border-slate-300"),"data-testid":"admin-audit-filter-from","aria-label":"From date"}),(0,s.jsx)("input",{type:"datetime-local",value:L,onChange:e=>M(e.target.value),className:"px-3 py-2 rounded-lg border text-sm ".concat(O?"bg-slate-800 border-slate-700":"bg-slate-50 border-slate-300"),"data-testid":"admin-audit-filter-to","aria-label":"To date"}),(0,s.jsx)("input",{type:"text",placeholder:"Trace ID (x-request-id, exact)",value:P,onChange:e=>R(e.target.value),className:"px-3 py-2 rounded-lg border text-sm xl:col-span-2 ".concat(O?"bg-slate-800 border-slate-700":"bg-slate-50 border-slate-300"),"data-testid":"admin-audit-filter-request-id"})]}),(0,s.jsx)("div",{className:"mt-3 flex justify-end",children:(0,s.jsxs)("button",{onClick:()=>{Z([null]),z(null)},disabled:o,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-slate-900 hover:bg-slate-700 text-white disabled:opacity-50 transition dark:bg-slate-100 dark:text-slate-900 dark:hover:bg-white","data-testid":"admin-audit-search-btn",children:[(0,s.jsx)(b.Z,{className:"w-4 h-4"})," Search"]})})]}),x&&(0,s.jsx)("div",{className:"mb-4 p-3 rounded-lg bg-red-500/10 text-red-500 text-sm","data-testid":"admin-audit-error",children:x}),(0,s.jsxs)("div",{className:"rounded-xl border overflow-hidden ".concat(O?"bg-slate-900 border-slate-800":"bg-white border-slate-200"),children:[(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm","data-testid":"admin-audit-table",children:[(0,s.jsx)("thead",{className:O?"bg-slate-800":"bg-slate-100",children:(0,s.jsxs)("tr",{className:"text-left",children:[(0,s.jsx)("th",{className:"px-4 py-3 font-semibold",children:"When"}),(0,s.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Action"}),(0,s.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Outcome"}),(0,s.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Actor"}),(0,s.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Target"}),(0,s.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Trace"}),(0,s.jsx)("th",{className:"px-4 py-3 font-semibold",children:"IP"})]})}),(0,s.jsxs)("tbody",{children:[0===a.length&&!o&&(0,s.jsx)("tr",{children:(0,s.jsx)("td",{colSpan:7,className:"px-4 py-8 text-center opacity-60",children:"No audit logs found."})}),a.map(e=>{var t,a,l,i;let r=j[e.outcome]||j.success,d=r.icon;return(0,s.jsxs)("tr",{className:"border-t ".concat(O?"border-slate-800":"border-slate-200"),"data-testid":"admin-audit-row-".concat(e._id),children:[(0,s.jsx)("td",{className:"px-4 py-3 whitespace-nowrap text-xs opacity-80",children:D(e.createdAt)}),(0,s.jsx)("td",{className:"px-4 py-3 font-mono text-xs",children:e.action}),(0,s.jsx)("td",{className:"px-4 py-3",children:(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs ".concat(r.bg," ").concat(r.color),children:[(0,s.jsx)(d,{className:"w-3 h-3"})," ",e.outcome]})}),(0,s.jsx)("td",{className:"px-4 py-3",children:(0,s.jsxs)("div",{className:"text-xs",children:[(0,s.jsx)("div",{children:(null===(t=e.actor)||void 0===t?void 0:t.email)||(0,s.jsx)("span",{className:"opacity-60",children:"â"})}),(null===(a=e.actor)||void 0===a?void 0:a.role)&&"user"!==e.actor.role&&(0,s.jsx)("div",{className:"opacity-60",children:e.actor.role})]})}),(0,s.jsx)("td",{className:"px-4 py-3 text-xs",children:(null===(l=e.target)||void 0===l?void 0:l.label)||(null===(i=e.target)||void 0===i?void 0:i.id)?(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{children:e.target.label||e.target.id}),e.target.type&&(0,s.jsx)("div",{className:"opacity-60",children:e.target.type})]}):(0,s.jsx)("span",{className:"opacity-60",children:"â"})}),(0,s.jsx)("td",{className:"px-4 py-2 align-top",children:e.requestId?(0,s.jsxs)("div",{className:"flex items-start gap-2 max-w-[200px]",children:[(0,s.jsx)("span",{className:"font-mono text-[10px] opacity-90 break-all leading-snug",children:e.requestId}),(0,s.jsx)("button",{type:"button",title:"Copy trace id",onClick:()=>navigator.clipboard.writeText(e.requestId),className:"shrink-0 p-1 rounded ".concat(O?"hover:bg-slate-700":"hover:bg-slate-200"),"data-testid":"admin-audit-copy-trace-".concat(e._id),children:(0,s.jsx)(g.Z,{className:"w-3.5 h-3.5 opacity-70"})})]}):(0,s.jsx)("span",{className:"opacity-60 text-xs",children:"â"})}),(0,s.jsx)("td",{className:"px-4 py-3 font-mono text-xs opacity-80",children:e.ip||"â"})]},e._id)})]})]})}),(0,s.jsxs)("div",{className:"px-4 py-3 flex items-center justify-between border-t ".concat(O?"border-slate-800":"border-slate-200"),children:[(0,s.jsxs)("div",{className:"text-xs opacity-70",children:[a.length," entries"]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("button",{onClick:()=>
1{if(k.length<=1)return;let e=k.slice(0,-1);Z(e),z(e[e.length-1])},disabled:k.length<=1||o,className:"flex items-center gap-1 px-3 py-1.5 rounded-lg text-sm transition disabled:opacity-40 ".concat(O?"bg-slate-800 hover:bg-slate-700":"bg-slate-100 hover:bg-slate-200"),"data-testid":"admin-audit-prev-btn",children:[(0,s.jsx)(y.Z,{className:"w-4 h-4"})," Prev"]}),(0,s.jsxs)("button",{onClick:()=>{N&&(Z(e=>[...e,N]),z(N))},disabled:!N||o,className:"flex items-center gap-1 px-3 py-1.5 rounded-lg text-sm transition disabled:opacity-40 ".concat(O?"bg-slate-800 hover:bg-slate-700":"bg-slate-100 hover:bg-slate-200"),"data-testid":"admin-audit-next-btn",children:["Next ",(0,s.jsx)(f.Z,{className:"w-4 h-4"})]})]})]})]})]})]})]})}}},function(e){e.O(0,[4968,1296,5412,2888,9774,179],function(){return e(e.s=32453)}),_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.