1import{x as _,u as T,r as s,j as e,L as v,g as F,F as h,_ as O,ad as U,z as l,k as $}from"./index-Az_DQIbU.js";import{d as z,e as B,a as H}from"./event.api-Bzg_TdGc.js";import{g as I}from"./tables-Cf8u45YR.js";import{d as b,C as M}from"./DashboardTables.module-CERQwAZJ.js";import{d as W}from"./ic_outline-delete-C6vRH9U2.js";import{w as Y}from"./withRole-Dp1BazmZ.js";import"./delete-DiCZjEHf.js";import"./useSlot-vT4fBxqC.js";import"./createSvgIcon-CnS1uEzs.js";import"./DialogTitle-C7ANbwEw.js";const q=()=>{const w=_(),i=T(t=>t.authSlice.user),[o,d]=s.useState(w.state?.fromPage||1),[y,S]=s.useState([]),[r,p]=s.useState(""),[E,C]=s.useState(0),[N,u]=s.useState(!1),[x,f]=s.useState(""),L=10,P=I(i?.role),g=async(t=o,a=r)=>{try{u(!0),f("add_blur");const c=await B(t,L,a?{search:a}:{});c&&(S(c.events),C(c.total))}catch(n){l.error(n.message),console.error("Failed to fetch data",n)}finally{u(!1),f("")}};s.useEffect(()=>{g(o,r)},[o,r]);const D=t=>{p(t.target.value),d(1)},R=()=>{p(""),d(1)},k=async t=>{d(t)},A=async t=>{try{const a=await H(t);l.success(a.message),await g(o,r)}catch(a){l.error(a.message),console.error("Error deleting field:",a)}};return e.jsx("div",{style:{position:"relative"},className:"dsp",children:e.jsxs("div",{className:`${b.datatablemainwrap} ${x?b[x]:""} colorAction`,children:[e.jsxs("div",{className:"search-wrap",children:[e.jsx("div",{className:"button-holder-wrap",children:i?.role==="admin"?e.jsx(v,{to:"/event/add",children:e.jsx("button",{className:"custom-button",children:"Add Event"})}):""}),e.jsxs("div",{className:"searchwrap",style:{marginBottom:"20px",display:"flex",justifyContent:"flex-start",position:"relative",marginTop:"20px"},children:[e.jsx("input",{type:"text",placeholder:"Search...",value:r,onChange:D,style:{padding:"8px 12px",borderRadius:"10px",border:"1px solid #ccc",maxWidth:"350px",height:"50px",width:"100%",marginLeft:"auto"}}),r&&e.jsx("button",{onClick:R,style:{position:"absolute",right:"10px",top:"50%",transform:"translateY(-50%)",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#999"},children:"Ã"})]})]}),e.jsx("div",{className:"usertabledata",children:N?e.jsx(F,{}):e.jsx(M,{title:"Event",columns:P,bodyData:y,dataCurrentPage:o,changePage:k,totalData:E,deleteMessage:"Are you sure to delete this event?",handleDelete:A,renderActions:t=>i?.role==="admin"?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:e.jsx(v,{to:`/event/update/${t._id}`,children:e.jsx(h,{icon:O,className:"icon-themes"})})}),e.jsx("p",{children:e.jsx("a",{href:"#",onClick:async a=>{a.preventDefault();try{const n=await z(t._id),c=new Blob([n],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),j=window.URL.createObjectURL(c),m=document.createElement("a");m.href=j,m.download=`game_statistics_${t._id}.xlsx`,m.click(),window.URL.revokeObjectURL(j)}catch{l.error("Failed to download Excel file")}},className:"action-anch",children:e.jsx(h,{icon:U,className:"icon-themes"})})}),e.jsx("p",{"data-title":"delete","data-id":t._id,children:e.jsx("span",{children:e.jsx("img",{src:W,alt:"Delete"})})})]}):e.jsx("p",{children:e.jsx("a",{href:"#",className:"action-anch",children:e.jsx(h,{icon:$,className:"icon-themes"})})})})})]})})},se=Y(q,["admin"]);export{se as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.