1import{u as de,h as pe,r as o,B as I,j as l}from"./index-DQkzoM3f.js";import{d as me}from"./debounce-BnuTxgsy.js";import{S as P,c as ue}from"./react-select.esm-mKDw7yak.js";import{b as B,d as u,C as he,e as ge,c as y,a as fe}from"./CTable-Cxlk6ilS.js";import{C as ye,a as be}from"./CRow-zMswK_D2.js";import{C as xe}from"./CForm-DTVlxaqd.js";import{C as ve}from"./CFormInput-Drw58q1J.js";import{a as J}from"./index.esm-DWQZSujt.js";import{C as Ne,a as b}from"./CPaginationItem-Dbn6_Wem.js";import"./isObjectLike-DGAcr2Yn.js";import"./objectWithoutPropertiesLoose-Cv5OCJ0e.js";import"./setPrototypeOf-DgZC2w_0.js";import"./index-CnyDuYXe.js";import"./index-rF0CLpYz.js";import"./CFormControlWrapper-CeLdfEzz.js";import"./CFormControlValidation-CBnlSaHn.js";import"./CFormLabel-BbzezAvw.js";const je="_select_1dsz0_1",Ce="_input_1dsz0_2",Ie="_noOptions_1dsz0_29",Se="_note_1dsz0_34",Fe="_btn_1dsz0_38",t={select:je,input:Ce,"table-background":"_table-background_1dsz0_15","search-form":"_search-form_1dsz0_19","form-group":"_form-group_1dsz0_23","form-group-villa":"_form-group-villa_1dsz0_26",noOptions:Ie,note:Se,btn:Fe},k=s=>{const{noOptionsText:K,children:V}=s;return l.jsx(ue.NoOptionsMessage,{...s,children:l.jsx("span",{className:t.noOptions,children:s.selectProps.noOptionsText||V})})},qe=()=>{const{user:s,loading:K,error:V}=de(),Q=pe(),_=o.useRef(null),[M,h]=o.useState([]),[m,x]=o.useState(1),[S,g]=o.useState(1),[N]=o.useState(40),[c,f]=o.useState({name:"",buildingId:"",buildingName:"Select Building",selectedBuilding:null,flatId:"",flatName:"Select Apartment",selectedFlat:null,selectedVilla:null,villaName:"Select Villa",villaId:""}),[X,z]=o.useState(!1),[Z,$]=o.useState([]),[ee,T]=o.useState([]),[ae,w]=o.useState([]),H=async()=>{try{const a=(await I.get("/society-admin/approved-buildings")).data;if(a.statusCode===200)if(Array.isArray(a.data)&&a.data.length>0){let n=a.data.map(i=>({...i,label:i.buildingName,value:i._id}));$(n)}else $([])}catch(e){$([]),console.error("getAllApprovedBuildings catch error: ",e.message)}},F=async(e=null)=>{try{let a="/society-admin/occupied-flat";e!==null&&(a+=`?buildingId=${e}`);const i=(await I.get(a)).data;if(i.statusCode===200){const r=Array.isArray(i.data)&&i.data.length>0?i.data.map(d=>({value:d._id,label:d.flatNumber,...d})):[];T(r)}}catch(a){console.error("fetchAllOccupiedFlat: ",a.message)}},L=o.useCallback(async()=>{if(s!=null&&s._id)try{const a=(await I.get("/society-admin/occupied-villa")).data;if(a.success){const n=Array.isArray(a.data)&&a.data.length>0?a.data.map(i=>({value:i._id,label:i.villa,...i})):[];w([]),w(n)}}catch(e){w([]),console.error(`fetchAllVillas function catch error: ${e.message}`)}},[Q]),j=o.useCallback(async()=>{z(!0);try{const e=`/society-admin/resident/upcomming-cheque?page=${m}&limit=${N}`,n=(await I.get(e)).data;if(n.statusCode===200){const i=n.data;i.length>0?(h(i),g(n.totalPages)):(h([]),g(1))}else h([]),g(1)}catch(e){h([]),g(1),console.log(`fetchUpcomingPaymentList catch error: ${e.message}`)}finally{z(!1)}},[m,N]);o.useCallback(me(e=>{x(1),j(e)},500),[j]);const le=e=>{const a=e.target.value;f(n=>({...n,name:a}))};o.useEffect(()=>{j()},[j,m]),o.useEffect(()=>{(s==null?void 0:s.societyType)==="multiStorey"&&(H(),F()),(s==null?void 0:s.societyType)==="villa"&&L()},[]);const se=e=>{e?(T([]),f(a=>({...a,buildingId:e.value,buildingName:(e==null?void 0:e.label)||"",selectedBuilding:e,flatId:"",flatName:"Select Apartment",selectedFlat:null})),_.current.value=e.value,F(e.value)):(f(a=>({...a,buildingId:"",buildingName:"Select Building",selectedBuilding:null,flatId:"",flatName:"Select Apartment"})),_.current.value="",T([]),F())},ie=e=>{f(e?a=>({...a,selectedFlat:e,flatId:e.value,flatName:e.label}):a=>({...a,selectedFlat:null,flatId:"",flatName:"Select Apartment"}))},oe=e=>{f(e?a=>({...a,selectedVilla:e,villaId:e.value,villaName:e.label}):a=>({...a,selectedVilla:null,villaId:"",villaName:"villaName"}))},te=async e=>{if(e.preventDefault(),(s==null?void 0:s.societyType)==="multiStorey"){if(c.name===""&&c.buildingId===""&&c.flatId==="")return}else if((s==null?void 0:s.societyType)==="villa"&&c.name===""&&c.villaId==="")return;try{const a=c.name||"",n=c.buildingId||"",i=c.flatId||"",r=c.villaId||"";let d="";d=s.societyType==="multiStorey"?`/society-admin/resident/search-upcomming-cheque?name=${a}&buildingId=${n}&flatId=${i}&page=${m}&limit=${N}`:`/society-admin/resident/search-upcomming-cheque?name=${a}&villaId=${r}&page=${m}&limit=${N}`;const v=(await I.get(d)).data;if(v.statusCode===200){const C=v.data;C.length>0?(h(C),g(v.totalPages)):(h([]),g(1))}else h([]),g(1)}catch(a){h([]),g(1),console.error("searchFormSubmitHandler catch error: ",a.message)}},ne=e=>{e.preventDefault(),f(a=>({...a,name:"",buildingId:"",buildingName:"Select Building",flatId:"",flatName:"Select Flat",selectedFlat:null,selectedVilla:null,villaName:"select Villa",villaId:""})),j(),H(),F(),L()},re=(e,a,n)=>(a-1)*n+e+1,ce=(e,a)=>{const i=[];if(a<=5)for(let r=1;r<=a;r++)i.push(l.jsx(b,{active:e===r,onClick:()=>x(r),children:r},r));else{i.push(l.jsx(b,{active:e===1,onClick:()=>x(1),children:"1"},1)),e>3&&i.push(l.jsx(b,{disabled:!0,children:"..."},"ellipsis-start"));const r=Math.max(2,e-1),d=Math.min(a-1,e+1);for(let p=r;p<=d;p++)i.push(l.jsx(b,{active:e===p,onClick:()=>x(p),children:p},p));
1e<a-2&&i.push(l.jsx(b,{disabled:!0,children:"..."},"ellipsis-end")),i.push(l.jsx(b,{active:e===a,onClick:()=>x(a),children:a},a))}return i};let A;return M.length>0?A=M.map((e,a)=>{var n,i,r,d,p,v,C,U,R,D,E,q,Y,O,G,W;return l.jsxs(B,{children:[l.jsx(u,{className:"poppins-regular",children:re(a,m,N)}),l.jsx(u,{className:"poppins-regular",children:(n=e.residentId)==null?void 0:n.name}),l.jsxs(u,{className:"poppins-regular",children:[(i=e.residentId)==null?void 0:i.dial_code," ",(r=e.residentId)==null?void 0:r.mobile]}),l.jsx(u,{className:"poppins-regular",children:(d=e.residentId)==null?void 0:d.email}),(s==null?void 0:s.societyType)==="multiStorey"&&l.jsxs(o.Fragment,{children:[l.jsx(u,{className:"poppins-regular",children:(v=(p=e.residentId)==null?void 0:p.buildingId)==null?void 0:v.buildingName}),l.jsx(u,{className:"poppins-regular",children:(U=(C=e.residentId)==null?void 0:C.buildingId)!=null&&U.flatPrefix?`${(D=(R=e.residentId)==null?void 0:R.buildingId)==null?void 0:D.flatPrefix}-${(q=(E=e.residentId)==null?void 0:E.flatId)==null?void 0:q.flat}`:(O=(Y=e.residentId)==null?void 0:Y.flatId)==null?void 0:O.flat})]}),(s==null?void 0:s.societyType)==="villa"&&l.jsx(o.Fragment,{children:l.jsx(u,{className:"poppins-regular",children:(W=(G=e.residentId)==null?void 0:G.villaId)==null?void 0:W.villa})}),l.jsx(u,{className:"poppins-regular",children:new Date(e.date).toLocaleDateString("en-GB",{day:"2-digit",month:"long",year:"numeric"})})]},e._id)}):A=l.jsx(B,{children:l.jsx(u,{colSpan:8,children:l.jsx("span",{className:"text-danger poppins-semibold",children:"No Upcoming Payment Available Yet!"})})}),l.jsx(o.Fragment,{children:l.jsx(ye,{children:l.jsxs(be,{xs:12,children:[l.jsx("h3",{className:"mb-2 poppins-semibold",children:(s==null?void 0:s.name)??""}),l.jsx("p",{className:`mb-2 ${t.note} poppins-regular`,children:"You can easily view the list of residents whose payments are due to you in the next 90 days."}),l.jsx("p",{className:`mb-3 ${t.note} poppins-regular`,children:"Automatic payment notification will be sent to users in 30 days, 15 days and 7 days."}),l.jsx("div",{className:"mb-4",children:l.jsxs(xe,{onSubmit:te,className:`d-flex align-items-center justify-content-between ${t["search-form"]}`,children:[l.jsx("div",{className:`${(s==null?void 0:s.societyType)==="multiStorey"?t["form-group"]:t["form-group-villa"]}`,children:l.jsx(ve,{type:"text",className:`${t.input} poppins-regular`,value:c.name,onChange:e=>le(e),placeholder:"Enter Name","aria-busy":X})}),(s==null?void 0:s.societyType)==="multiStorey"&&l.jsxs(o.Fragment,{children:[l.jsx("div",{className:`${t["form-group"]} poppins-regular`,children:l.jsx(P,{ref:_,value:c.selectedBuilding,onChange:se,options:Z,placeholder:"Select Building",isClearable:!0,noOptionsText:"No matching building found. Try a different search!",components:{NoOptionsMessage:k},className:`'poppins-regular' ${t["react-select"]} ${t.select}`,closeMenuOnSelect:!0,styles:{control:(e,a)=>({...e,fontFamily:"Poppins",borderColor:a.isFocused?"#494747":"#808080",boxShadow:a.isFocused?"none":e.boxShadow,"&:hover":{borderColor:a.isFocused?"#494747":"#808080"}}),placeholder:e=>({...e,fontFamily:"Poppins",color:"var(--bs-body-color)"}),menu:e=>({...e,maxWidth:"100%",width:"100%",fontFamily:"Poppins",zIndex:9999}),menuList:e=>({...e,maxHeight:"200px",overflowY:"auto"}),option:(e,a)=>({...e,fontFamily:"Poppins",backgroundColor:a.isSelected?"#1976d2":a.isFocused?"#e6f0ff":e.backgroundColor,color:a.isSelected?"white":e.color,"&:hover":{backgroundColor:a.isSelected?"#1976d2":"#e6f0ff"}})}})}),l.jsx("div",{className:`${t["form-group"]} poppins-regular`,children:l.jsx(P,{value:c.selectedFlat,onChange:ie,options:ee,placeholder:"Select Apartment",isClearable:!0,noOptionsText:"No matching apartment found. Try a different search!",components:{NoOptionsMessage:k},className:`'poppins-regular' ${t["react-select"]} ${t.select}`,styles:{control:(e,a)=>({...e,fontFamily:"Poppins",borderColor:a.isFocused?"#494747":"#808080",boxShadow:a.isFocused?"none":e.boxShadow,"&:hover":{borderColor:a.isFocused?"#494747":"#808080"}}),placeholder:e=>({...e,fontFamily:"Poppins",color:"var(--bs-body-color)"})}})})]}),(s==null?void 0:s.societyType)==="villa"&&l.jsx(o.Fragment,{children:l.jsx("div",{className:`${t["form-group-villa"]} poppins-regular`,children:l.jsx(P,{value:c.selectedVilla,onChange:oe,options:ae,placeholder:"Select Villa",isClearable:!0,noOptionsText:"No matching villa found. Try a different search!",components:{NoOptionsMessage:k},className:`'poppins-regular' ${t["react-select"]} ${t.select}`,styles:{control:(e,a)=>({...e,fontFamily:"Poppins",borderColor:a.isFocused?"#86b7fe":"#808080",boxShadow:a.isFocused?"none":e.boxShadow,"&:hover":{borderColor:a.isFocused?"#86b7fe":"#808080"}}),placeholder:e=>({...e,fontFamily:"Poppins",color:"var(--bs-body-color)"})}})})}),l.jsxs("div",{className:`${(s==null?void 0:s.societyType)==="multiStorey"?t["form-group"]:t["form-group-villa"]}`,children:[l.jsx(J,{type:"submit",color:"primary",className:`${t.btn} poppins-regular`,children:"Search"}),l.jsx(J,{type:"button",color:"secondary",onClick:ne,className:"ms-2 poppins-regular",children:"Reset"})]})]})}),l.jsxs(he,{className:t["table-background"],children:[l.jsx(ge,{children:l.jsxs(B,{children:[l.jsx(y,{scope:"col",className:"poppins-semibold",children:"S.No."}),l.jsx(y,{scope:"col",className:"poppins-semibold",children:"Name"}),l.jsx(y,{scope:"col",className:"poppins-semibold",children:"Mobile"}),l.jsx(y,{scope:"col",className:"poppins-semibold",children:"Email"}),(s==null?void 0:s.societyType)==="multiStorey"&&l.jsxs(o.Fragment,{children:[l.jsx(y,{scope:"col",className:"poppins-semibold",children:"Building"}),l.jsx(y,{scope:"col",className:"poppins-semibold",children:"Apartment"})]}),(s==null?void 0:s.societyType)==="villa"&&l.jsx(o.Fragment,{children:l.jsx(y,{scope:"col",className:"poppins-semibold",children:"Villa"})}),l.jsx(y,{scope:"col",className:"poppins-semibold",children:"Cheque Coming Date"})]})}),l.jsx(fe,{children:A})]}),S>1&&l.jsx(o.Fragment,{children:l.jsxs(Ne,{className:"justify-content-center mt-3","aria-label":"Page navigation example",children:[l.jsx(b,{"aria-label":"Previous",disabled:m===1,onClick:()=>x(e=>Math.max(e-1,1)),children:l.jsx("span",{"aria-hidden":"true",children:"«"})}),ce(m,S),l.jsx(b,{"aria-label":"Next",disabled:m===S,onClick:()=>x(e=>Math.min(e+1,S)),children:l.jsx("span",{"aria-hidden":"true",children:"»"})})]})})]})})})};export{qe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.