import{r as x,a as r,j as a,F as w}from"./main.6.7.js";import{r as u}from"./react-vendor-0bea0611.js";import{a as D,u as R}from"./@tanstack/react-query-cb8e8166.js";import{F as y,T as _,l as q,h as S,R as L,S as v,B as K,n as F}from"./antd-b03f4406.js";import"./@emotion/react-f59bf8e1.js";import"./react-router-dom-551725bc.js";import"./@tanstack/react-query-devtools-28f31d30.js";function N(){const{mutateAsync:e,isLoading:s}=D(async t=>x({action:"logs/delete",data:{ids:t}}));return{deleteLog:t=>e(t),isLogDeleting:s}}function $(e){var l,g,d,c;const s=`logs-${e.pageNo}`,{data:t,isLoading:i,isFetching:o,refetch:h}=R({refetchOnWindowFocus:!1,queryKey:["all_logs",s],queryFn:async()=>x({action:"logs/all",data:e})});return{isLoading:i,refetch:h,isLogsFetching:o,logs:((l=t==null?void 0:t.data)==null?void 0:l.logs)??[],total:((g=t==null?void 0:t.data)==null?void 0:g.count)??0,current:((d=t==null?void 0:t.data)==null?void 0:d.current)??0,pages:((c=t==null?void 0:t.data)==null?void 0:c.pages)??0}}const b=[{title:"Id",dataIndex:"id",key:"id"},{title:"User",dataIndex:"user",key:"user",render:e=>(e==null?void 0:e.display_name)??""},{title:"Command",dataIndex:"command",key:"command"},{title:"Details",dataIndex:"details",key:"details",render:(e,s,t)=>{var i;return r(v,{children:[a(L,{children:a(S,{children:(e==null?void 0:e.driver)&&`Driver: ${e==null?void 0:e.driver}`})}),a("hr",{}),a(L,{children:a(S,{children:(e==null?void 0:e.files)&&r(w,{children:[a("span",{children:"Files:"}),a("li",{children:(i=e==null?void 0:e.files)==null?void 0:i.map(o=>a("ol",{children:o==null?void 0:o.path},`${t}-${o==null?void 0:o.path}`))})]})})})]})}},{title:"Created",dataIndex:"created_at",key:"created_at"}];function O(){const[e,s]=u.useState({pageNo:1,limit:20}),{isLoading:t,isLogsFetching:i,logs:o,total:h,refetch:l}=$(e),{isLogDeleting:g,deleteLog:d}=N(),[c,m]=u.useState([]),C=()=>{d(c).then(n=>{n.code==="SUCCESS"?(m([]),l(),F.success({message:(n==null?void 0:n.message)||"Log deleted successfully"})):F.error({message:(n==null?void 0:n.message)||"Failed to delete logs"})})},f={selectedRowKeys:c,onChange:n=>{m(n)}},p=c.length>0,I=(n,k)=>{s({pageNo:n,limit:k})};return r(y,{gap:"middle",vertical:!0,children:[r(y,{align:"center",gap:"middle",children:[a(K,{type:"primary",onClick:C,disabled:!p,loading:g,children:"Delete"}),p?r(_,{children:["Selected ",c.length," items"]}):null]}),a(q,{rowKey:"id",columns:b,rowSelection:f,dataSource:o,loading:t||i,pagination:{current:e.pageNo,total:h,pageSize:e.limit,onChange:I,position:["bottomRight","topLeft"]}})]})}export{O as default};
