import{r as a,j as e}from"./app-BeXbqfQ0.js";import{A as h}from"./AppLayout-DFlN-unB.js";function j({auditLogs:r,loginLogs:d}){const[t,c]=a.useState("audit"),[n,l]=a.useState(null);return e.jsx(h,{title:"لاگ‌های مدرسه",children:e.jsxs("div",{className:"page-stack",children:[e.jsx("section",{className:"section-header",children:e.jsxs("div",{children:[e.jsx("h2",{children:"لاگ‌های مدرسه"}),e.jsx("p",{children:"سابقه فعالیت‌ها و ورودهای کاربران این مدرسه."})]})}),e.jsxs("div",{className:"tab-bar",children:[e.jsxs("button",{className:`tab-btn${t==="audit"?" active":""}`,type:"button",onClick:()=>c("audit"),children:[e.jsx("i",{className:"bi bi-journal-check"})," فعالیت‌ها (",r.length,")"]}),e.jsxs("button",{className:`tab-btn${t==="login"?" active":""}`,type:"button",onClick:()=>c("login"),children:[e.jsx("i",{className:"bi bi-box-arrow-in-right"})," لاگ ورود (",d.length,")"]})]}),t==="audit"&&e.jsx("section",{className:"panel-card",children:r.length===0?e.jsx("p",{style:{color:"var(--color-text-muted)"},children:"هیچ فعالیتی ثبت نشده است."}):e.jsx("div",{className:"table-wrap",children:e.jsxs("table",{className:"data-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"کاربر"}),e.jsx("th",{children:"نقش"}),e.jsx("th",{children:"عملیات"}),e.jsx("th",{children:"موجودیت"}),e.jsx("th",{children:"IP"}),e.jsx("th",{children:"زمان"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:r.map(s=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:s.userName}),e.jsx("td",{style:{fontSize:"0.8rem",color:"var(--color-text-muted)"},children:s.userRole}),e.jsx("td",{children:e.jsx("code",{style:{fontSize:"0.8rem",background:"var(--color-surface-muted)",padding:"0.1rem 0.4rem",borderRadius:"4px"},children:s.action})}),e.jsxs("td",{style:{fontSize:"0.85rem",color:"var(--color-text-muted)"},children:[s.entityType??"—",s.entityId?` #${s.entityId}`:""]}),e.jsx("td",{style:{fontFamily:"monospace",fontSize:"0.8rem"},children:s.ip??"—"}),e.jsx("td",{style:{fontSize:"0.85rem",color:"var(--color-text-muted)"},children:s.createdAt}),e.jsx("td",{children:(s.oldValue||s.newValue)&&e.jsx("button",{className:"btn btn-ghost btn-sm",type:"button",onClick:()=>l(n===s.id?null:s.id),children:e.jsx("i",{className:`bi bi-chevron-${n===s.id?"up":"down"}`})})})]},s.id),n===s.id&&e.jsx("tr",{children:e.jsxs("td",{colSpan:7,style:{background:"var(--color-bg-soft)",padding:"0.75rem 1rem"},children:[s.oldValue&&e.jsxs("div",{style:{marginBottom:"0.5rem"},children:[e.jsx("strong",{style:{color:"var(--color-danger)",marginLeft:"0.5rem"},children:"قبل:"}),e.jsx("code",{style:{fontSize:"0.8rem",wordBreak:"break-all"},children:s.oldValue})]}),s.newValue&&e.jsxs("div",{children:[e.jsx("strong",{style:{color:"var(--color-success)",marginLeft:"0.5rem"},children:"بعد:"}),e.jsx("code",{style:{fontSize:"0.8rem",wordBreak:"break-all"},children:s.newValue})]})]})})]}))})]})})}),t==="login"&&e.jsx("section",{className:"panel-card",children:d.length===0?e.jsx("p",{style:{color:"var(--color-text-muted)"},children:"هیچ لاگ ورودی ثبت نشده است."}):e.jsx("div",{className:"table-wrap",children:e.jsxs("table",{className:"data-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"نام کاربری"}),e.jsx("th",{children:"وضعیت"}),e.jsx("th",{children:"IP"}),e.jsx("th",{children:"زمان"})]})}),e.jsx("tbody",{children:d.map((s,i)=>e.jsxs("tr",{children:[e.jsx("td",{children:s.username}),e.jsx("td",{children:e.jsx("span",{className:`badge ${s.status==="success"?"badge-success":"badge-danger"}`,children:s.status==="success"?"موفق":"ناموفق"})}),e.jsx("td",{style:{fontFamily:"monospace",fontSize:"0.85rem"},children:s.ip??"—"}),e.jsx("td",{style:{fontSize:"0.85rem",color:"var(--color-text-muted)"},children:s.createdAt})]},i))})]})})})]})})}export{j as default};
