import{c as V,a as q,a0 as y,r as A,j as e,w as C,K as i,M as d,E as b,ac as G,a6 as c,ad as I,y as m}from"./index-5768b108.js";import{o as P}from"./yup-7ddf262a.js";import{u as B}from"./index.esm-4803c918.js";import{C as _}from"./CustomDatepicker-c97efda4.js";import{C as $}from"./RadioGroup-1138b29c.js";import"./index-42cce9d5.js";import"./ScrollableList-c8e84a4e.js";import{c as X,a as K,b as S}from"./index.esm-85e2fec5.js";import"./SectionDivider-bc494fef.js";import{G as W}from"./GoBack-3005b0aa.js";import{T as H}from"./index-fcf73630.js";import{C as M}from"./CardContent-4b37116a.js";import"./floating-ui.dom-cd6c919d.js";import"./OutlinedInput-8a98392b.js";import"./useFormControl-e91ce3d1.js";import"./isHostComponent-73d6e646.js";import"./InputAdornment-82d0c147.js";import"./index-c58b1ae1.js";import"./index-4ca9e290.js";import"./useMediaQuery-493fa36e.js";import"./useControlled-821282b7.js";import"./InputLabel-bfa922b7.js";import"./FormControl-47bb025d.js";import"./RadioGroup-b694c34a.js";import"./SwitchBase-6c1eb44c.js";import"./createSvgIcon-51b522b8.js";import"./FormControlLabel-a8ce6f4f.js";import"./TableCell-73fa51e5.js";import"./TableRow-3593e946.js";import"./resolveProps-5b0bdb14.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-9a8473c9.js";import"./List-2cd167d2.js";import"./LoadingButton-b684247e.js";import"./index-bed7b08c.js";import"./TableHead-1c4bab1f.js";import"./TablePagination-e6e264e7.js";import"./Toolbar-96b35f70.js";import"./Select-3950b24e.js";import"./Menu-7988a333.js";import"./Grow-c21b912f.js";import"./useSlotProps-ed538db1.js";import"./MenuItem-51065bfa.js";import"./dividerClasses-a2ef427b.js";import"./listItemTextClasses-3e91d186.js";import"./KeyboardArrowRight-56dea4db.js";import"./LastPage-f21d7153.js";const Kt=()=>{var D,f,h,x;const o=V(),{mini:{},reports:{reportsDataCount:v,reportDataList:n,pageParams:t,columnsList:w}}=q(a=>y(a)),R=X({file_format:K().required("file format is required"),start_date:S().notRequired(),end_date:S().notRequired()}),{register:J,handleSubmit:z,control:p,getValues:F,reset:k}=B({resolver:P(R)}),u=()=>{k({file_format:5,start_date:"",end_date:""}),o(G())};A.useEffect(()=>{u()},[]);const l=F("start_date"),E=(a,r)=>{o(c({...t,ParamsData:{...t.ParamsData,page:r+1}}))},L=a=>{o(c({...t,ParamsData:{...t.ParamsData,page:1,page_size:parseInt(a.target.value)}}))},T=({file_format:a,start_date:r,end_date:s})=>{var Y,g;var j={file_format:a,model_name:"Lead"};a!=5?o(I({objData:j,ParamsData:{start_date:r?m(r).format("YYYY-MM-DD"):"",end_date:s?m(s).format("YYYY-MM-DD"):""}})):o(c({objData:j,ParamsData:{start_date:r?m(r).format("YYYY-MM-DD"):"",end_date:s?m(s).format("YYYY-MM-DD"):"",page:(Y=t==null?void 0:t.ParamsData)==null?void 0:Y.page,page_size:(g=t==null?void 0:t.ParamsData)==null?void 0:g.page_size}}))};return e.jsxs(W,{is_goback:!0,go_back_url:"/reports",title:"Lead Report",showSaveButton:!1,loading:!1,children:[e.jsx(C,{sx:{mt:1},children:e.jsx(M,{children:e.jsx("form",{action:"",onSubmit:z(T),children:e.jsxs(i,{container:!0,spacing:2,children:[e.jsx(i,{size:{xs:12},children:e.jsx($,{control:p,name:"file_format",label:"File Format",row:!0,options:[{label:"CSV",value:0},{label:"XLSX",value:2},{label:"VIEW",value:5}],defaultValue:5})}),e.jsx(i,{size:{xs:12,md:4,lg:2},children:e.jsx(d,{flex:1,children:e.jsx(_,{control:p,name:"start_date",hideAddon:!0,dateFormat:"DD-MM-YYYY",showTimeSelect:!1,timeFormat:"h:mm a",timeCaption:"time",maxDate:new Date,inputClass:"form-input",label:"Start Date",tI:1})})}),e.jsx(i,{size:{xs:12,md:4,lg:2},children:e.jsx(d,{flex:1,children:e.jsx(_,{control:p,name:"end_date",hideAddon:!0,disabled:!l,dateFormat:"DD-MM-YYYY",showTimeSelect:!1,timeFormat:"h:mm a",timeCaption:"time",inputClass:"form-input",minDate:l?new Date(l):void 0,label:"End Date",tI:1,helperText:"select start date before selecting end date"})})}),e.jsx(i,{size:{xs:12},children:e.jsxs(d,{direction:"row",spacing:2,justifyContent:"end",children:[e.jsx(b,{variant:"outlined",onClick:u,children:"Clear"}),e.jsx(b,{variant:"contained",type:"submit",children:"Schedule Report"})]})})]})})})}),e.jsx(C,{children:e.jsx(M,{sx:{borderTop:"1px solid lightgray"},children:n&&e.jsx(H,{count:v,columns:w,rows:n||[],loading:!1,page:(D=t==null?void 0:t.ParamsData)!=null&&D.page?(f=t==null?void 0:t.ParamsData)==null?void 0:f.page:1,pageSize:(h=t==null?void 0:t.ParamsData)!=null&&h.page_size?(x=t==null?void 0:t.ParamsData)==null?void 0:x.page_size:10,handleChangePage:E,handleChangeRowsPerPage:L})})})]})};export{Kt as default};
