PageSourceSearch

https://startup-gate.net/assets/AdminAuditLogPage-Dv8Nk9QF.js

js startup-gate.net collected 2026-10-08 16:27:10 UTC 9,913 bytes, 1 lines download raw bytes

1import{r as a,j as e}from"./vendor-radix-DLGwGdby.js";import{J as H,C as k,b as q,c as z,d as B,I as g,v as F,w as V,x as Q,y as J,z as P,B as c,e as K,s as X,q as Y,h as G,A as W}from"./index-Cz1Nuibl.js";import{T as Z,a as ee,b as w,c as m,d as te,e as o}from"./table-DxmE8Wef.js";import{E as se}from"./empty-state-CXub9qrl.js";import{A as ae}from"./AdminPagination-6qEaDgP-.js";import{P as de}from"./PageHeader-DadO5fKg.js";import{aT as ie,f as re,aU as ne,a2 as oe,_ as le,u as ce}from"./vendor-lucide-BWW0XcuW.js";import{f as x,s as R,c as me}from"./vendor-datefns-CU7NMMYW.js";import"./vendor-recharts-dzgay_RI.js";const ue="00000000-0000-0000-0000-000000000000",D={user_deactivated:"User Deactivated",user_activated:"User Activated",user_edited:"User Edited",user_role_added:"Role Added",user_role_removed:"Role Removed",user_impersonated:"Impersonation Started",user_impersonation_ended:"Impersonation Ended",entity_edited:"Entity Edited",mentor_edited:"Mentor Edited",service_listing_edited:"Listing Edited",service_provider_approved:"Provider Approved",service_provider_rejected:"Provider Rejected",service_provider_visibility_changed:"Provider Visibility Changed",service_request_status_changed:"Request Status Changed",community_comment_deleted:"Comment Deleted",community_post_deleted:"Post Deleted",push_broadcast:"Push Notification Broadcast",platform_setting_changed:"Platform Setting Changed",ai_assessment_triggered:"AI Assessment Run",dropdown_option_created:"Dropdown Option Created",dropdown_option_updated:"Dropdown Option Updated",dropdown_option_deleted:"Dropdown Option Deleted",role_approved:"Role Approved",role_auto_approved:"Role Auto-Approved",role_rejected:"Role Rejected"},pe={user_deactivated:"destructive",user_activated:"default",user_impersonated:"destructive",user_impersonation_ended:"secondary",user_role_removed:"secondary",community_comment_deleted:"destructive",community_post_deleted:"destructive",dropdown_option_deleted:"destructive",service_provider_rejected:"destructive",push_broadcast:"default",ai_assessment_triggered:"secondary",role_approved:"default",role_auto_approved:"secondary",role_rejected:"destructive"};function he(u,p,s,r,l,d){return Y({queryKey:["admin-audit-logs",u,s,r,l,d],queryFn:async()=>{const i=new URLSearchParams({page:String(u),per_page:String(p)});return s&&s!=="all"&&i.set("action",s),r&&i.set("search",r),l&&i.set("from",l),d&&i.set("to",d),G.get(`${W}/admin/audit-logs?${i}`)}})}function Se(){const u=H(),[p,s]=a.useState(1),[r,l]=a.useState("all"),[d,i]=a.useState(""),[E,I]=a.useState(""),[h,_]=a.useState(""),[j,v]=a.useState("");a.useEffect(()=>{const t=setTimeout(()=>{I(d),s(1)},300);return()=>clearTimeout(t)},[d]);const[S,M]=a.useState(null),A=20,L=h||j,f=t=>{const n=new Date,$=t==="last7"?R(n,6):t==="last30"?R(n,29):me(n);_(x($,"yyyy-MM-dd")),v(x(n,"yyyy-MM-dd")),s(1)},{data:C,isLoading:O,isError:U,dataUpdatedAt:y}=he(p,A,r,E,h,j),b=C?.logs||[],N=C?.total||0,T=Math.ceil(N/A);return a.useEffect(()=>{y&&M(new Date(y))},[y]),e.jsxs("div",{className:"p-4 sm:p-6 space-y-6",children:[e.jsx(de,{title:"Audit Log",description:"Track all administrative actions on the platform"}),e.jsxs(k,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{children:[e.jsxs(z,{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-5 w-5"})," Activity Log"]}),e.jsxs(B,{children:[N," total entries",S?` · updated ${x(S,"HH:mm:ss")}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative",children:[e.jsx(re,{className:"absolute start-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}),e.jsx(g,{type:"text",placeholder:"Search logs…",value:d,onChange:t=>i(t.target.value),className:"ps-8 w-[200px] text-sm","data-testid":"input-search"})]}),e.jsxs(F,{value:r,onValueChange:t=>{l(t),s(1)},children:[e.jsx(V,{className:"w-[200px]","data-testid":"select-action-filter",children:e.jsx(Q,{placeholder:"Filter by action"})}),e.jsxs(J,{children:[e.jsx(P,{value:"all",children:"All Actions"}),Object.entries(D).map(([t,n])=>e.jsx(P,{value:t,children:n},t))]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(g,{type:"date",value:h,onChange:t=>{_(t.target.value),s(1)},className:"w-[150px] text-sm","data-testid":"input-date-from",title:"From date"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"–"}),e.jsx(g,{type:"date",value:j,min:h||void 0,onChange:t=>{v(t.target.value),s(1)},className:"w-[150px] text-sm","data-testid":"input-date-to",title:"To date"}),L&&e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>{_(""),v(""),s(1)},"data-testid":"button-clear-dates",title:"Clear date filter",children:e.jsx(oe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(c,{variant:"outline",size:"sm",onClick:()=>f("last7"),"data-testid":"button-date-preset-last-7-days",children:"Last 7 days"}),e.jsx(c,{variant:"outline",size:"sm",onClick:()=>f("last30"),"data-testid":"button-date-preset-last-30-days",children:"Last 30 days"}),e.jsx(c,{variant:"outline",size:"sm",onClick:()=>f("thisMonth"),"data-testid":"button-date-preset-this-month",children:"This month"})]}),e.jsx(c,{variant:"outline",size:"icon",onClick:()=>u.invalidateQueries({queryKey:["admin-audit-logs"]}),"data-testid":"button-refresh",children:e.jsx(le,{className:"h-4 w-4"})})]})]})}),e.jsx(K,{children:O?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading audit logs..."}):U?e.jsx(se,{icon:ce,title:"Failed to load audit logs",description:"An error occurred while fetching the audit log. Please try again."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Z,{children:[e.jsx(ee,{children:e.jsxs(w,{children:[e.jsx(m,{children:"Time"}),e.jsx(m,{children:"Admin"}),e.jsx(m,{children:"Action"}),e.jsx(m,{children:"Target"}),e.jsx(m,{className:"hidden lg:table-cell",children:"Details"})]})}),e.jsxs(te,{children:[b.map(t=>e.jsxs(w,{children:[e.jsx(o,{className:"text-sm text-muted-foreground whitespace-nowrap",children:x(new Date(t.created_at),"MMM d, yyyy HH:mm")}
1),e.jsx(o,{className:"font-medium text-sm",children:t.admin_user_id===ue?e.jsx("span",{className:"text-muted-foreground italic",children:"System (auto)"}):t.admin_name}),e.jsx(o,{children:e.jsx(X,{variant:pe[t.action]||"outline",children:D[t.action]||t.action})}),e.jsxs(o,{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:t.target_type}),t.details?.target_email&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t.details.target_email}),t.details?.target_name&&e.jsx("div",{className:"text-xs text-muted-foreground",children:t.details.target_name})]}),e.jsx(o,{className:"hidden lg:table-cell text-xs text-muted-foreground max-w-[300px]",children:t.action==="role_auto_approved"?e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("span",{className:"font-medium text-foreground",children:["Auto-approved",t.details?.completeness_score!==void 0&&e.jsxs(e.Fragment,{children:[" (score: ",t.details.completeness_score,"%)"]})]}),t.details?.role&&e.jsxs("div",{children:["Role:"," ",e.jsx("span",{className:"text-foreground capitalize",children:String(t.details.role).replace(/_/g," ")})]})]}):t.action==="user_impersonation_ended"?e.jsxs("div",{className:"space-y-0.5",children:[t.details?.target_email&&e.jsxs("div",{children:["Session as ",e.jsx("span",{className:"font-medium text-foreground",children:t.details.target_email})]}),t.details?.duration_seconds!=null?e.jsxs("div",{children:["Duration:"," ",t.details.duration_seconds<60?`${t.details.duration_seconds}s`:t.details.duration_seconds<3600?`${Math.floor(t.details.duration_seconds/60)}m ${t.details.duration_seconds%60}s`:`${Math.floor(t.details.duration_seconds/3600)}h ${Math.floor(t.details.duration_seconds%3600/60)}m`]}):null]}):t.action==="user_impersonated"?e.jsxs("div",{className:"space-y-0.5",children:[t.details?.target_email&&e.jsxs("div",{children:["Target: ",e.jsx("span",{className:"font-medium text-foreground",children:t.details.target_email})]}),t.details?.target_name&&e.jsx("div",{children:t.details.target_name})]}):t.action==="community_post_deleted"?e.jsxs("div",{className:"space-y-0.5","data-testid":`details-post-deleted-${t.id}`,children:[e.jsxs("span",{className:"font-medium not-italic text-foreground",children:['"',t.details?.headline||"(no headline)",'"']}),(t.details?.post_author_name||t.details?.post_author_email)&&e.jsxs("div",{children:["by ",t.details.post_author_name||t.details.post_author_email,t.details.post_author_name&&t.details.post_author_email&&e.jsxs("span",{className:"ms-1",children:["(",t.details.post_author_email,")"]})]}),!t.details?.post_author_name&&!t.details?.post_author_email&&t.details?.post_author_id&&e.jsxs("div",{children:["author: ",t.details.post_author_id]})]}):t.details?.comment_preview?e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("span",{className:"italic",children:['"',t.details.comment_preview,'"']}),t.target_id&&e.jsxs("div",{className:"not-italic",children:["comment: ",t.target_id]}),t.details.post_id&&e.jsxs("div",{children:["post: ",t.details.post_id]}),t.details.comment_owner_id&&e.jsxs("div",{children:["owner: ",t.details.comment_owner_id]})]}):t.details&&Object.keys(t.details).length>0?e.jsx("span",{className:"truncate block",children:JSON.stringify(t.details)}):"—"})]},t.id)),b.length===0&&e.jsx(w,{children:e.jsx(o,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No audit logs found"})})]})]})}),T>1&&e.jsx(ae,{page:p,totalPages:T,total:N,totalLabel:"entries",onPageChange:s,prevTestId:"button-pagination-prev",nextTestId:"button-pagination-next"})]})})]})]})}export{Se as default};

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.