import{b as L,F as M,r as h,a as $,tw as q,h as G,tx as r,j as t,B as K,v as Q,T as x,K as y,t as f,Q as C,e2 as H,ty as J}from"./index-43bf7a1c.js";import{T as U}from"./index-2d303f1d.js";import{P as V}from"./Menu-362130d3.js";import"./TableContainer-b977c6cc.js";import"./TableRow-86264944.js";import"./Skeleton-ed4df299.js";import"./index-5757b954.js";import"./useMediaQuery-d6627623.js";import"./TableHead-fb4972c5.js";import"./createSvgIcon-f118be02.js";import"./TablePagination-9147f93d.js";import"./Select-44fd3147.js";import"./OutlinedInput-6bcf3cf8.js";import"./useFormControl-2c5d60c2.js";import"./List-6fcc4821.js";import"./useControlled-ab567149.js";import"./MenuItem-58b8887e.js";import"./dividerClasses-497df10c.js";import"./listItemTextClasses-0ea25cee.js";import"./KeyboardArrowRight-8bd7c13f.js";import"./Grow-ca573f65.js";const ye=()=>{const i=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(()=>{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(J({id:e})),i(r({...a,search:"",page:1,page_size:10})),p()};function T(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 b=o==null?void 0:o.map((e,s)=>{const c=(a.page-1)*a.page_size+(s+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(Q,{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 T(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)}),k=(e,s)=>{i(r({...a,search:"",page:s+1}))},E=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(H,{}),"Schedule Reports"]}),t.jsx(U,{count:z,columns:D,rows:b,loading:R,page:a.page,pageSize:a.page_size,handleChangePage:k,handleChangeRowsPerPage:E})]})})})};export{ye as default};
