import{d as G,a as P,a1 as T,r as V,j as e,a3 as C,S as d,U as b,ag as A,ah as c,ai as I,O as m}from"./index-60657852.js";import{o as y}from"./yup-75ad371b.js";import{c as B,a as $,b as _,u as X}from"./index.esm-509a598d.js";import{C as S}from"./GenericThumbnailView-f8b17afa.js";import{C as O}from"./RadioGroup-18aadacb.js";import"./componentStyles-19763afb.js";import"./ScrollableList-ef4c85dc.js";import"./TextArea-d897dbf9.js";import{C as U}from"./index-61d7dc47.js";import{G as W}from"./GoBack-bb4a2941.js";import{C as w}from"./CardContent-f8a5d460.js";import{G as i}from"./Grid2-09163d35.js";import"./index-980acb6c.js";import"./createClass-2b895736.js";import"./popper-f3391c26.js";import"./Select-7d2a5359.js";import"./Grow-a21bdd26.js";import"./InputAdornment-12fc79ce.js";import"./TextField-6b778b78.js";import"./isMuiElement-82a67859.js";import"./RadioGroup-1ebb1249.js";import"./Radio-8a9e9740.js";import"./SwitchBase-3b306fc6.js";import"./FormControlLabel-95d4d7bb.js";import"./TableRow-0ab1e69a.js";import"./LastPage-71f2133b.js";import"./KeyboardArrowRight-450d5bb8.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./dividerClasses-590294d7.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";import"./LoadingButton-c619bdb5.js";const qt=()=>{var D,h,f,x;const o=G(),{mini:{},reports:{reportsDataCount:M,reportDataList:n,pageParams:t,columnsList:v}}=P(a=>T(a)),z=B({file_format:$().required("file format is required"),start_date:_().required("Start Date is required"),end_date:_().required("End Date is required")}),{register:H,handleSubmit:F,control:l,getValues:J,reset:R,watch:k}=X({resolver:y(z)}),u=()=>{R({file_format:5,start_date:"",end_date:""}),o(A())};V.useEffect(()=>{u()},[]);const p=k("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)}}))},q=({file_format:a,start_date:r,end_date:s})=>{var j,Y;var g={file_format:a,model_name:"Lead"};a!=5?o(I({objData:g,ParamsData:{start_date:r?m(r).format("YYYY-MM-DD"):"",end_date:s?m(s).format("YYYY-MM-DD"):""}})):o(c({objData:g,ParamsData:{start_date:r?m(r).format("YYYY-MM-DD"):"",end_date:s?m(s).format("YYYY-MM-DD"):"",page:(j=t==null?void 0:t.ParamsData)==null?void 0:j.page,page_size:(Y=t==null?void 0:t.ParamsData)==null?void 0:Y.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(w,{children:e.jsx("form",{action:"",onSubmit:F(q),children:e.jsxs(i,{container:!0,spacing:2,children:[e.jsx(i,{size:{xs:12},children:e.jsx(O,{control:l,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(S,{control:l,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(S,{control:l,name:"end_date",hideAddon:!0,disabled:!p,dateFormat:"DD-MM-YYYY",showTimeSelect:!1,timeFormat:"h:mm a",timeCaption:"time",inputClass:"form-input",minDate:p?new Date(p):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:"Generate"})]})})]})})})}),e.jsx(C,{children:e.jsx(w,{sx:{borderTop:"1px solid lightgray"},children:n&&e.jsx(U,{count:M,columns:v,rows:n||[],loading:!1,page:(D=t==null?void 0:t.ParamsData)!=null&&D.page?(h=t==null?void 0:t.ParamsData)==null?void 0:h.page:1,pageSize:(f=t==null?void 0:t.ParamsData)!=null&&f.page_size?(x=t==null?void 0:t.ParamsData)==null?void 0:x.page_size:10,handleChangePage:E,handleChangeRowsPerPage:L,showPagination:!0})})})]})};export{qt as default};
