import{d as G,k as L,r as h,a as M,lE as $,b as q,lF as r,j as t,B as H,y as J,T as x,z as y,w as f,bi as K,lG as Q}from"./index-4dfc510b.js";import{T as U}from"./index-2560e6e6.js";import{P as V}from"./Menu-0f556e12.js";import{G as C}from"./Grid2-713975b3.js";import"./TableRow-bee40746.js";import"./useMediaQuery-75ea24f6.js";import"./TableContainer-3d0f0f18.js";import"./TableHead-c19aff48.js";import"./Grow-a7315f12.js";import"./TablePagination-faf46d98.js";import"./KeyboardArrowRight-605c8352.js";import"./Toolbar-1cf142b4.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./MenuItem-9737e3d9.js";import"./dividerClasses-26c2a6d6.js";import"./listItemTextClasses-e85f7ff0.js";import"./isMuiElement-7be61a21.js";const ue=()=>{const i=G(),j=L(),[u,g]=h.useState(null),v=!!u,[n,S]=h.useState(null),{scheduleReport:{scheduleReports:l,loading:R,listCount:z,pageParams:a},system:{userAccessList:o}}=M(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)=>{S(s),g(e.currentTarget)},p=()=>{g(null)},B=e=>{i(Q({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 k=l==null?void 0:l.map((e,s)=>{const c=(a.page-1)*a.page_size+(s+1),d=t.jsx(H,{sx:{display:"flex",gap:2},children:(o==null?void 0:o.indexOf("Reports.delete_scheduledemail"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(J,{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)}),E=(e,s)=>{i(r({...a,search:"",page:s+1}))},T=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(K,{}),"Schedule Reports"]}),t.jsx(U,{count:z,columns:D,rows:k,loading:R,page:a.page,pageSize:a.page_size,handleChangePage:E,handleChangeRowsPerPage:T})]})})})};export{ue as default};
