import{d as G,a as P,a0 as T,r as V,j as e,a2 as C,S as p,R as b,ab as A,ac as c,ad as I,M as m}from"./index-ba11e6ab.js";import{o as y}from"./yup-902af9ab.js";import{c as B,a as $,b as _,u as X}from"./index.esm-39ef576a.js";import{C as S}from"./GenericThumbnailView-511a7e33.js";import{C as W}from"./RadioGroup-d6d0768b.js";import"./componentStyles-cc6f218d.js";import"./ScrollableList-b4fc4d99.js";import"./TextArea-1c46e0e4.js";import{C as H}from"./index-5081f854.js";import{G as J}from"./GoBack-4cf208d4.js";import{C as M}from"./CardContent-9c57d232.js";import{G as s}from"./Grid2-12794a3c.js";import"./index-33824b7d.js";import"./popper-f3391c26.js";import"./Select-f9434f8a.js";import"./index-e5978b8b.js";import"./Grow-1038181b.js";import"./InputAdornment-0f07311f.js";import"./TextField-16337ecc.js";import"./isMuiElement-f8265807.js";import"./RadioGroup-98a3c81a.js";import"./Radio-67def7ee.js";import"./SwitchBase-7d4e0bc8.js";import"./FormControlLabel-8048035a.js";import"./TableRow-e1616615.js";import"./CircularProgress-509803a6.js";import"./TableContainer-9178cc85.js";import"./TableHead-5a0d8cfc.js";import"./TablePagination-3b5112dd.js";import"./KeyboardArrowRight-36117cc9.js";import"./Toolbar-c7a1b81e.js";import"./MenuItem-e4578955.js";import"./dividerClasses-ab944802.js";import"./listItemTextClasses-a4497781.js";import"./LoadingButton-a3eae003.js";import"./composeClasses-b42b2e69.js";const Et=()=>{var D,h,f,x;const o=G(),{mini:{},reports:{reportsDataCount:w,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:K,handleSubmit:R,control:l,getValues:N,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(J,{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:R(q),children:e.jsxs(s,{container:!0,spacing:2,children:[e.jsx(s,{size:{xs:12},children:e.jsx(W,{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(M,{sx:{borderTop:"1px solid lightgray"},children:n&&e.jsx(H,{count:w,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};
