import{b as L,E as q,r as h,a as M,tw as $,g as G,tx as r,j as t,B as J,t as H,T as x,J as y,q as f,P as C,e5 as K,ty as Q}from"./index-d2b25495.js";import{T as U}from"./index-75fca24c.js";import{P as V}from"./Menu-337a466b.js";import"./TableContainer-dd7cf0ce.js";import"./TableRow-74f9cf3b.js";import"./Skeleton-1012c2e6.js";import"./index-1249dfe4.js";import"./useMediaQuery-b1fbc166.js";import"./TableHead-fac214d3.js";import"./createSvgIcon-e39ae511.js";import"./TablePagination-2c2a1682.js";import"./Select-ef36a2b2.js";import"./OutlinedInput-86f3ec98.js";import"./useFormControl-2b068664.js";import"./useControlled-8d737f13.js";import"./MenuItem-2bdddad4.js";import"./List-863f013e.js";import"./dividerClasses-02a44d89.js";import"./listItemTextClasses-cadd4b00.js";import"./KeyboardArrowRight-7e978a8a.js";import"./Grow-8719411b.js";const ye=()=>{const i=L(),j=q(),[u,g]=h.useState(null),v=!!u,[n,S]=h.useState(null),{scheduleReport:{scheduleReports:o,loading:R,listCount:z,pageParams:a},system:{userAccessList:l}}=M(e=>({scheduleReport:$(e),system:G(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 E(e,s,c,d,m,k,A,F,I,Y,N,O){return{index:e,code:s,reportname:c,email:d,createdby:m,startdate:k,time:A,schedulereport:F,customisedRepeatDays:I,createdDate:Y,fileformat:N,actions:O}}const P=o==null?void 0:o.map((e,s)=>{const c=(a.page-1)*a.page_size+(s+1),d=t.jsx(J,{sx:{display:"flex",gap:2},children:(l==null?void 0:l.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 E(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}))},b=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:P,loading:R,page:a.page,pageSize:a.page_size,handleChangePage:T,handleChangeRowsPerPage:b})]})})})};export{ye as default};
