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-c1429e77.js";import{o as P}from"./yup-0d492cec.js";import{u as B}from"./index.esm-e372dd1f.js";import{C as _}from"./CustomDatepicker-9a80af6c.js";import{C as $}from"./RadioGroup-46aeb0c5.js";import"./index-938f4514.js";import"./ScrollableList-85f6c22b.js";import{c as X,a as K,b as S}from"./index.esm-85841cf7.js";import"./SectionDivider-0f38a779.js";import{G as W}from"./GoBack-8fdc2295.js";import{T as H}from"./index-50437a1d.js";import{C as M}from"./CardContent-195cd99b.js";import"./floating-ui.dom-cd6c919d.js";import"./OutlinedInput-7d44f8dd.js";import"./useFormControl-674270c6.js";import"./isHostComponent-73d6e646.js";import"./InputAdornment-7b2a78bf.js";import"./index-6d8a6cf3.js";import"./index-10a98b8b.js";import"./useMediaQuery-6763b70c.js";import"./useControlled-f1a5b61d.js";import"./InputLabel-e729048c.js";import"./FormControl-63806889.js";import"./RadioGroup-09b0ccf8.js";import"./SwitchBase-89be1310.js";import"./createSvgIcon-74b4ff5d.js";import"./FormControlLabel-9a892c17.js";import"./TableCell-f7ad5597.js";import"./TableRow-18e2a4e3.js";import"./resolveProps-3c56301c.js";import"./composeClasses-b42b2e69.js";import"./toPropertyKey-d8419463.js";import"./typeof-7fd5df1e.js";import"./popper-f3391c26.js";import"./styled-54544d88.js";import"./List-7dd83a15.js";import"./LoadingButton-a5f23242.js";import"./index-0710c981.js";import"./TableHead-89a0b6da.js";import"./TablePagination-8b574091.js";import"./Toolbar-d8e3299a.js";import"./Select-ea3744da.js";import"./Menu-3e8761c1.js";import"./Grow-67aedb5f.js";import"./useSlotProps-8fc8da82.js";import"./MenuItem-352b4536.js";import"./dividerClasses-91c74733.js";import"./listItemTextClasses-7e80198b.js";import"./KeyboardArrowRight-e84473c8.js";import"./LastPage-931a2b6d.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};
