import{c as L,l as M,r as h,a as $,tm as q,h as G,tn as r,j as t,B as K,A as H,T as x,E as y,y as f,K as C,by as J,to as Q}from"./index-c1429e77.js";import{T as U}from"./index-50437a1d.js";import{P as V}from"./Menu-3e8761c1.js";import"./TableCell-f7ad5597.js";import"./TableRow-18e2a4e3.js";import"./index-0710c981.js";import"./useMediaQuery-6763b70c.js";import"./TableHead-89a0b6da.js";import"./createSvgIcon-74b4ff5d.js";import"./TablePagination-8b574091.js";import"./Toolbar-d8e3299a.js";import"./Select-ea3744da.js";import"./OutlinedInput-7d44f8dd.js";import"./useFormControl-674270c6.js";import"./isHostComponent-73d6e646.js";import"./useControlled-f1a5b61d.js";import"./MenuItem-352b4536.js";import"./List-7dd83a15.js";import"./dividerClasses-91c74733.js";import"./listItemTextClasses-7e80198b.js";import"./KeyboardArrowRight-e84473c8.js";import"./LastPage-931a2b6d.js";import"./Grow-67aedb5f.js";import"./useSlotProps-8fc8da82.js";const je=()=>{const s=L(),j=M(),[u,g]=h.useState(null),v=!!u,[n,S]=h.useState(null),{scheduleReport:{scheduleReports:o,loading:R,listCount:z,pageParams:a},system:{userAccessList:l}}=$(e=>({scheduleReport:q(e),system:G(e)}));h.useEffect(()=>{s(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,i)=>{S(i),g(e.currentTarget)},p=()=>{g(null)},B=e=>{s(Q({id:e})),s(r({...a,search:"",page:1,page_size:10})),p()};function E(e,i,c,d,m,A,P,F,I,Y,N,O){return{index:e,code:i,reportname:c,email:d,createdby:m,startdate:A,time:P,schedulereport:F,customisedRepeatDays:I,createdDate:Y,fileformat:N,actions:O}}const T=o==null?void 0:o.map((e,i)=>{const c=(a.page-1)*a.page_size+(i+1),d=t.jsx(K,{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)}),b=(e,i)=>{s(r({...a,search:"",page:i+1}))},k=e=>{s(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:T,loading:R,page:a.page,pageSize:a.page_size,handleChangePage:b,handleChangeRowsPerPage:k})]})})})};export{je as default};
