import{d as L,z as M,r as h,a as G,mD as $,b as q,mE as r,j as t,B as Q,Q as H,T as x,R as y,M as f,by as J,mF as K}from"./index-e972fa8e.js";import{T as U}from"./index-0e298e38.js";import{P as V}from"./Select-a2938be0.js";import{G as C}from"./Grid2-936c64bd.js";import"./TableRow-c60adf0a.js";import"./useMediaQuery-f8b4772b.js";import"./TableContainer-ad9de4b5.js";import"./TableHead-11d85aea.js";import"./Grow-0b3a9797.js";import"./TablePagination-63dde5fc.js";import"./KeyboardArrowRight-4b11e6b9.js";import"./LastPage-69d51b6f.js";import"./Toolbar-fca75f8a.js";import"./MenuItem-fab52ff5.js";import"./dividerClasses-b771f620.js";import"./listItemTextClasses-f7cdafa8.js";import"./listItemIconClasses-bcb38dc7.js";import"./index-e5978b8b.js";import"./isMuiElement-fab695f8.js";const ge=()=>{const i=L(),j=M(),[u,g]=h.useState(null),v=!!u,[n,R]=h.useState(null),{scheduleReport:{scheduleReports:l,loading:S,listCount:z,pageParams:a},system:{userAccessList:o}}=G(e=>({scheduleReport:$(e),system:q(e)}));h.useEffect(()=>{i(r({...a,search:"",page:1,page_size:10}))},[]);const D=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Report Name",width:100},{title:"Email",width:100},{title:"Created By",width:100},{title:"Start Date",width:100},{title:"Time",width:100},{title:"Schedule Repeat",width:100},{title:"Customised Repeat Days",width:100},{title:"Created Date",width:100},{title:"File Format",width:100},{title:"Actions",width:100}],_=(e,s)=>{R(s),g(e.currentTarget)},p=()=>{g(null)},B=e=>{i(K({id:e})),i(r({...a,search:"",page:1,page_size:10})),p()};function b(e,s,c,d,m,F,P,A,I,Y,N,O){return{index:e,code:s,reportname:c,email:d,createdby:m,startdate:F,time:P,schedulereport:A,customisedRepeatDays:I,createdDate:Y,fileformat:N,actions:O}}const E=l==null?void 0:l.map((e,s)=>{const c=(a.page-1)*a.page_size+(s+1),d=t.jsx(Q,{sx:{display:"flex",gap:2},children:(o==null?void 0:o.indexOf("Reports.delete_scheduledemail"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(H,{style:{cursor:"pointer",color:"#fc6f03"},onClick:m=>_(m,e==null?void 0:e.id)}),t.jsx(V,{id:n?String(n):void 0,open:v,anchorEl:u,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(x,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(y,{variant:"contained",type:"submit",color:"primary",onClick:()=>{B(n)},autoFocus:!0,children:"Yes"}),t.jsx(y,{variant:"outlined",size:"small",onClick:p,style:{marginLeft:"20px"},children:"No"})]})})]})});return b(c,e==null?void 0:e.code,e==null?void 0:e.reportname,e==null?void 0:e.email,e.created_by.username,e.startdate,e.time?f(e.time).format("hh:mm"):null,e.frequency_name,e.repeatdays?e.repeatdays>1?`${e.repeatdays} days`:`${e.repeatdays} day`:null,f(e.createdon).format("YYYY-MM-DD"),e.fileformat_name,d)}),T=(e,s)=>{i(r({...a,search:"",page:s+1}))},k=e=>{i(r({...a,search:"",page:1,page_size:parseInt(e.target.value)}))};return t.jsx(t.Fragment,{children:t.jsx(C,{container:!0,spacing:2,children:t.jsxs(C,{size:{xs:12},children:[t.jsxs(x,{variant:"h4",sx:{display:"flex",alignItems:"center",gap:2,cursor:"pointer",marginBottom:"20px"},onClick:()=>{j("/pages/settings",{relative:"path"})},children:[t.jsx(J,{}),"Schedule Reports"]}),t.jsx(U,{count:z,columns:D,rows:E,loading:S,page:a.page,pageSize:a.page_size,handleChangePage:T,handleChangeRowsPerPage:k})]})})})};export{ge as default};
