VirtualPR/frontend/dist/assets/index-CS4iYGQK.js

2 lines
1.9 KiB
JavaScript

import{r as t,j as s,C as m,d as x}from"./index-DGCPJq4z.js";import{P as u}from"./PageBreadcrumb-zFeQijFR.js";import{b as j}from"./dates-DzZ1gfzQ.js";import{C as p,a as b}from"./Card-D1j94NWu.js";import{T as N}from"./Table-DqFE0W6i.js";import"./PageMetaData-B-bWCH8Q.js";function S(){const[r,c]=t.useState([]),[l,d]=t.useState(0),[a,n]=t.useState(1),[i,o]=t.useState(""),h=async()=>{const e=await x(`/api/audit?page=${a}&limit=25`);c(e.items||[]),d(e.total||0)};return t.useEffect(()=>{h().catch(e=>o(e.message))},[a]),s.jsxs(m,{fluid:!0,children:[s.jsx(u,{title:"Audit log",subtitle:"Administration"}),i?s.jsx("div",{className:"alert alert-danger",children:i}):null,s.jsx(p,{children:s.jsxs(b,{children:[s.jsx("p",{className:"text-muted",children:"Read-only access events. Patient names and mobiles are never stored here."}),s.jsxs(N,{responsive:!0,size:"sm",className:"mb-0",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"When"}),s.jsx("th",{children:"Actor"}),s.jsx("th",{children:"Action"}),s.jsx("th",{children:"Resource"}),s.jsx("th",{children:"IP"})]})}),s.jsxs("tbody",{children:[r.map(e=>s.jsxs("tr",{children:[s.jsx("td",{className:"small",children:j(e.at)}),s.jsx("td",{children:e.actor?`${e.actor.firstName} ${e.actor.lastName}`:"—"}),s.jsx("td",{children:e.action}),s.jsx("td",{className:"small",children:[e.resourceType,e.resourceId].filter(Boolean).join(" ")}),s.jsx("td",{className:"small",children:e.ip||"—"})]},e.id)),r.length?null:s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-muted",children:"No audit events yet."})})]})]}),l>25?s.jsxs("div",{className:"d-flex gap-2 mt-3",children:[s.jsx("button",{type:"button",className:"btn btn-sm btn-light",disabled:a<=1,onClick:()=>n(e=>e-1),children:"Previous"}),s.jsx("button",{type:"button",className:"btn btn-sm btn-light",disabled:a*25>=l,onClick:()=>n(e=>e+1),children:"Next"})]}):null]})})]})}export{S as default};