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