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-60a3c753.js";import{T as U}from"./index-7e55cf46.js";import{P as V}from"./Menu-d1b7e1c3.js";import"./TableContainer-414c12e0.js";import"./TableRow-0b33776c.js";import"./Skeleton-98c353d9.js";import"./index-a99c9f65.js";import"./useMediaQuery-dba48e3b.js";import"./TableHead-f864c753.js";import"./createSvgIcon-de433e5f.js";import"./TablePagination-218dde38.js";import"./Select-99fc0d84.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./List-f567f8e4.js";import"./useControlled-194ef007.js";import"./MenuItem-2f410bd2.js";import"./dividerClasses-3fa67596.js";import"./listItemTextClasses-36afdb92.js";import"./KeyboardArrowRight-b2645aed.js";import"./Grow-68442588.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};
