(() => { const { Card, Badge, Chip, Icon, Avatar, EmptyState, Button, StatCard, Modal, Field, Input, Select } = window.TaskFlowDesignSystem_dd53c2; function AuditTrail({ entries = ACTIVITY, users = USERS, meId, onPurge }) { const bp = useBreakpoint(); const [who, setWho] = React.useState(meId != null ? meId : null); const [kind, setKind] = React.useState("all"); const wk = weekRange(); const [range, setRange] = React.useState(wk); const [q, setQ] = React.useState(""); const [purge, setPurge] = React.useState(null); // {from,to} rentang log yang akan dihapus const picked = meId != null || who != null; const target = meId != null ? meId : who; const scoped = React.useMemo(() => (picked ? entries.filter((e) => (target === "all" ? true : e.user === target) && stampInRange(e.at, range.from, range.to)) : []), [entries, picked, target, range.from, range.to]); const allList = React.useMemo(() => { const s = q.trim().toLowerCase(); return scoped.filter((e) => (kind === "all" || e.kind === kind) && (!s || String(e.title).toLowerCase().includes(s) || String(e.detail || "").toLowerCase().includes(s))); }, [scoped, kind, q]); const [shown, setShown] = React.useState(30); React.useEffect(() => { setShown(30); }, [kind, who, q, range.from, range.to]); const list = allList.slice(0, shown); const nameOf = (id) => (id === 0 ? "Direktur Klinik" : userById(id).name); const KINDS = [["all", "Semua"], ["submit", "Kirim bukti"], ["accept", "Accept"], ["revision", "Revisi"], ["create", "Task baru"], ["comment", "Diskusi"], ["login", "Login"]]; return (
{picked &&
e.kind === "submit").length} icon="upload" tone="mint" /> e.kind === "revision").length} icon="rotate-ccw" tone="coral" /> e.kind === "accept").length} icon="shield-check" tone="leaf" />
} {meId == null && (
Pilih user

Log dimuat per user

{who != null && } {onPurge && }
setWho("all")} /> e.user === 0).length} active={who === 0} onClick={() => setWho(0)} /> {users.map((u) => ( e.user === u.id).length} active={who === u.id} onClick={() => setWho(u.id)} /> ))}
)} {picked &&
Audit trail

{meId != null ? "Log Activity Saya" : who === "all" ? "Semua User" : nameOf(who)}

{KINDS.map(([id, label]) => ( ))}
setQ(e.target.value)} />
{allList.length} dari {scoped.length} aktivitas pada rentang ini
{list.length === 0 ? ( ) : (
{list.map((e, i) => (
{i < list.length - 1 && } {nameOf(e.user)} {e.kind} {e.at} {e.title} {e.detail && {e.detail}}
))} {allList.length > list.length && (
Menampilkan {list.length} dari {allList.length} aktivitas
)}
)}
} {purge && onPurge && ( setPurge(null)} title="Hapus / Arsipkan Log" description="Log lama dihapus permanen agar penyimpanan tetap ringan. Sebaiknya export dulu bila diperlukan untuk audit." footer={<> }>
setPurge({ ...purge, from: e.target.value })} /> setPurge({ ...purge, to: e.target.value })} />