import{d as G,a as P,O as T,r as V,j as e,R as C,S as p,z as b,a0 as A,a1 as c,a2 as I,w as m}from"./index-c5c88b67.js";import{o as y}from"./yup-41605283.js";import{c as B,a as $,b as _,u as X}from"./index.esm-81620445.js";import{C as S}from"./GenericThumbnailView-43782201.js";import{C as O}from"./RadioGroup-7081afd6.js";import"./componentStyles-a5e5a830.js";import"./ScrollableList-21ab2b9c.js";import"./TextArea-aad9dffe.js";import{C as W}from"./index-e101df4a.js";import{G as H}from"./GoBack-18f006a8.js";import{C as w}from"./CardContent-5f043396.js";import{G as s}from"./Grid2-0ff60c92.js";import"./index-c98d1d89.js";import"./createClass-fb49042e.js";import"./popper-f3391c26.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./Menu-e7d2b2ee.js";import"./Grow-7345f8ea.js";import"./InputAdornment-d66117f3.js";import"./TextField-78388962.js";import"./isMuiElement-b3c21f38.js";import"./RadioGroup-1ba0c7fd.js";import"./FormControlLabel-d6955dc8.js";import"./TableRow-2b359fa8.js";import"./CircularProgress-13afa056.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./MenuItem-81e44793.js";import"./dividerClasses-6bc0ca72.js";import"./listItemTextClasses-88792089.js";import"./LoadingButton-3a5d0643.js";import"./composeClasses-b42b2e69.js";const Et=()=>{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:J,handleSubmit:R,control:l,getValues:K,reset:F,watch:k}=X({resolver:y(z)}),u=()=>{F({file_format:5,start_date:"",end_date:""}),o(A())};V.useEffect(()=>{u()},[]);const d=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:i})=>{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:i?m(i).format("YYYY-MM-DD"):""}})):o(c({objData:j,ParamsData:{start_date:r?m(r).format("YYYY-MM-DD"):"",end_date:i?m(i).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(H,{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:R(q),children:e.jsxs(s,{container:!0,spacing:2,children:[e.jsx(s,{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(s,{size:{xs:12,md:4,lg:2},children:e.jsx(p,{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(s,{size:{xs:12,md:4,lg:2},children:e.jsx(p,{flex:1,children:e.jsx(S,{control:l,name:"end_date",hideAddon:!0,disabled:!d,dateFormat:"DD-MM-YYYY",showTimeSelect:!1,timeFormat:"h:mm a",timeCaption:"time",inputClass:"form-input",minDate:d?new Date(d):void 0,label:"End Date",tI:1,helperText:"select start date before selecting end date"})})}),e.jsx(s,{size:{xs:12},children:e.jsxs(p,{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(W,{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{Et as default};
