import{d as G,a as P,a0 as T,r as V,j as e,a2 as C,S as d,R as b,af as A,ag as c,ah as I,M as m}from"./index-aa25c5ff.js";import{o as y}from"./yup-72cc4918.js";import{c as B,a as $,b as _,u as X}from"./index.esm-a7f661dc.js";import{C as S}from"./GenericThumbnailView-e0343bac.js";import{C as W}from"./RadioGroup-c04167de.js";import"./componentStyles-e32842f3.js";import"./ScrollableList-9498bc37.js";import"./TextArea-d1a16eb1.js";import{C as H}from"./index-06082cde.js";import{G as J}from"./GoBack-3be9a532.js";import{C as M}from"./CardContent-879d5aba.js";import{G as i}from"./Grid2-d00e0f6a.js";import"./index-d4b36417.js";import"./createClass-d1bae5ec.js";import"./popper-f3391c26.js";import"./Select-b8388c2f.js";import"./index-e5978b8b.js";import"./Grow-53c7e965.js";import"./InputAdornment-1e7eea92.js";import"./TextField-55b66d20.js";import"./isMuiElement-1b254892.js";import"./RadioGroup-35774d31.js";import"./Radio-8e35c60b.js";import"./SwitchBase-f1314509.js";import"./FormControlLabel-56777c7d.js";import"./TableRow-ee82d902.js";import"./CircularProgress-d6cfca6d.js";import"./TableContainer-150455ba.js";import"./TableHead-7918647e.js";import"./TablePagination-7f533723.js";import"./KeyboardArrowRight-207c2b3b.js";import"./LastPage-cc741249.js";import"./Toolbar-aae1a453.js";import"./MenuItem-6f39aa2e.js";import"./dividerClasses-ce522944.js";import"./listItemTextClasses-88140258.js";import"./listItemIconClasses-31a870c1.js";import"./LoadingButton-bec71809.js";import"./composeClasses-b42b2e69.js";const Gt=()=>{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 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(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(i,{container:!0,spacing:2,children:[e.jsx(i,{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(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(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{Gt as default};
