1import{en as Ae,e1 as Oe,e2 as qe,ei as W,ac as i,e3 as Je,dw as a,ej as We,d_ as _,e8 as _e,f4 as Ye,eJ as $e,ef as Ve,dJ as ze,ed as Ke}from"./vendor-DKdbt11B.js";import{B as He,fy as Ue,c as Ze,ah as Qe,aj as Y,j as Xe,r as et,k as tt,cZ as at,c$ as st,ar as rt,d0 as $,d1 as V,fv as nt,bc as it,bI as lt,u as ot,fJ as ct,bi as dt,aL as z,l as K,c_ as mt,eW as ut}from"./startApp-CTN2hsPb.js";import"./vendor-azure-Dv2cCLQn.js";import"./vendor-charts-DqDj4X3p.js";import"./index-CFLxD1jK.js";import"./vendor-quill-B9f5GEcW.js";let x="",S=[],o="";const Nt=H=>{const d=He(),{classes:m,cx:n}=Ue(),{classes:t}=Ze(),D=Ae(),U=Oe(),P=qe(),Z=W(e=>e.authReducer.roleEntitlement),Q=W(e=>e.authReducer.tenantRoute),{resolvedPreference:X,isLoaded:M,savePreference:ee,tenantId:R}=Qe(Y.GRID_KEY_CPMETERREADING),[te,ae]=i.useState(!1),[u,b]=i.useState([]),[y,se]=i.useState([]),[re,ne]=i.useState(1),g=Xe(et.MeterReading,Z)==tt.fullAccess,{enqueueSnackbar:I}=Je(),[l,h]=i.useState(),[C,ie]=i.useState(),[E,B]=i.useState(""),[T,k]=i.useState(!0),[le,L]=i.useState(!1),[oe,w]=i.useState(!1),[ce,de]=i.useState(""),[me,v]=i.useState(""),[ue,G]=i.useState([]),{JSONPERSIST_KEY_FILTER:f,JSONPERSIST_KEY_SELECT:j}=Y,F=e=>{ee(e??o)},ge=()=>{const e=localStorage.getItem("customers");if(e===null)return;const s=JSON.parse(e);if(G(s),s.length>0){v(s[0].id);const r={...o,[f]:{...o[f],[j]:s[0].id}};o=r,F(r),x=s[0].id}},he=()=>{const e=JSON.parse(localStorage.getItem("customers"));if(G(e),e.filter(r=>r.id==o[f][j]).length>0){const r=parseInt(o[f][j]);v(r),x=r}else{v(e[0].id);const r={...o,[f]:{...o[f],[j]:e[0].id}};o=r,F(r),x=e[0].id}},fe=()=>{o=X,o[f][j]===""?ge():he(),Ie()};i.useEffect(()=>{M&&fe()},[M]);function pe(e){v(e.target.value),S=[],x=e.target.value;let s={};s["Parameters.PageNumber"]=1,s["Parameters.PageSize"]=10,s["Parameters.TenantId"]=R,O(s)}const A=()=>S!==void 0&&S.length>0,xe=()=>A()?S.toString():x,je=e=>{if(e.length>0){let s=[];for(const r of e)s[r.meterId]={reading:"",error:""};h(s)}},Ne=e=>{if(ne(re+1),e?.data?.data){b(e?.data?.data);let s=e?.data?.data[0].meters;se(s),je(s)}else b([])},ve=e=>{b([]),mt(e,I)},Se=e=>{k(!1),e&&(e.status===200&&Ne(e),e.status!==200&&ve(e))},O=e=>{e["Parameters.CustomerId"]=x,e["Parameters.LocationId"]=xe(),e["Parameters.MasterMode"]=!A(),k(!0),z.getduemeterreading(e,K.meterReading).then(s=>Se(s)).catch(s=>console.error("(2) Inside error:",s))},q=()=>JSON.parse(localStorage.getItem("EAutomateCustomerIds"))[0].toString(),Re=e=>e?.length?e:q(),be=(e,s)=>e?.length?e:s?.length?s:q(),Ie=()=>{let e={},s=P?.state?.customerId,r=P?.state?.locationId;e["Parameters.CustomerId"]=Re(s),e["Parameters.LocationId"]=be(r,s),e["Parameters.TenantId"]=R,e["Parameters.Op"]=1,e["Parameters.OperandText"]=D.id,e["Parameters.MasterMode"]=!0,O(e)},Ce=at(),Be=()=>d.mobile?100:Ce>=1300?H.type===1?90:115:30,p=()=>d.mobile?t.displayFlex:"",N=()=>d.mobile?m.mobileCol:"";function De(e,s){ie(e),B("")}function Pe(e,s){let r={...l};r[s].reading=e.replace(",",""),h({...r})}const Me=()=>C===""||C===void 0?(B("This field is required"),!1):(B(""),!0),ye=(e,s,r)=>e===""?(r[s].error="This field is required",h(r),!1):isNaN(e)?(r[s].error="Please input numeric characters only",h(r),!1):!0,Ee=(e,s,r)=>ut(e)===!1?(r[s].error="Please input numeric characters only",h(r),!1):parseInt(e)>2147483647?(r[s].error="Please Enter valid meter reading",h(r),!1):(r[s].error="",!0),Te=e=>{for(const s of y){let r=e[s.meterId].reading.trim();if(r=r.replace(/,/g,""),!ye(r,s.meterId,e)||!Ee(r,s.meterId,e))return!1}return!0};function ke(){if(Me()){if(l!==void 0){let e={...l};if(!Te(e))return;h(e)}J(!1)}}function J(e){let s=[];if(l)for(const c of Object.keys(l))s.push({meterId:c,display:parseFloat(l[c].reading.replace(/,/g,""))});let r={equipmentId:u[0].equipmentId,readingDate:C,isConfirmed:e!==void 0?e:!0,meterReadings:s,tenantId:R};L(!0),!le&&z.addmeterreading(r,K.meterReading).then(c=>{L(!1),c.status!==200?c.data.errors?.length>0?(w(!0),de("The meter reading provided is unusually high or less than the previous reading. Please verify the accuracy and proceed accordingly.")):I(c.data.message,{variant:"error"}):(U(`/${Q}/copier/MeterReading`),I(c.data.message,{variant:"success"}))}).catch(c=>{console.log(c)})}function Le(){w(!1)}const we=()=>E!==""?E:"",Ge=()=>g?"":t.viewOnly,Fe=e=>!l||!l[e]||l[e]?.error===void 0||l[e]?.error===""?"":l[e].error;return a.jsx(a.Fragment,{children:a.jsxs(We,{maxWidth:!1,disableGutters:!0,className:t.pdTop15,children:[a.jsx(_,{item:!0,xl:12,lg:12,md:12,sm:12,className:n(t.white,t.displayFlex,d.mobile?t.pd8:t.pd16,t.justifyContentBetween,t.marginBottom1,t.alignItemCenter),children:a.jsxs("div",{className:n(d.mobile?t.dis
1playBlock:t.displayFlex,t.alignItemsCenter,d.mobile?t.fontExact15:""),children:[a.jsx(_e,{className:n(t.fontGothamMedium,t.fontBlack,t.fontExact15,t.noWrap,t.marginRight2),children:"Select"}),a.jsx(Ye,{variant:"standard",fullWidth:!0,disabled:T,children:a.jsx($e,{variant:"standard",labelId:"demo-simple-select-label",id:"demo-simple-select","data-testid":"demo-simple-select",value:""+me,onChange:pe,className:d.mobile?m.mobileSelect:"",children:ue.map((e,s)=>a.jsxs(Ve,{className:t.whiteSpaceNoraml,"data-testid":"menu-item",value:""+e.id,children:[`${e.name} - ${e.address}`," "]},`${e?.name}-${e?.id??s}`))})})]})}),a.jsx(st,{title:"Due Meter Reading Details"}),T?a.jsxs("div",{className:n(t.pdTop15,t.pdBottom15),children:[" ",a.jsx(rt,{rowCount:8,height:25,width:100})," "]}):a.jsx("div",{className:n(m.cardContainer,d.mobile?t.displayBlock:""),children:a.jsxs(_,{xl:8,lg:8,md:8,xs:12,children:[a.jsx("div",{className:n(t.padding10Firstchild,t.height100),children:a.jsx("div",{className:"tablelist",children:u.length!==0&&a.jsxs($,{children:[" ",a.jsx(V,{cardTitle:"Equipment Details",children:a.jsx(nt,{type:1,id:D.id,showContractNumber:te,setShowContractNumber:ae,data:u[0],from:"Meter Reading"})})," "]})})}),a.jsx("div",{className:n(t.padding10Firstchild,t.height100),children:a.jsx("div",{className:"tablelist",children:a.jsx($,{children:a.jsx(V,{cardTitle:"Meter Reading",children:u.length===0?a.jsx(a.Fragment,{children:a.jsx("p",{children:"Congratulations, no due meter for selected location!"})}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:n("col1",p()),children:a.jsxs("div",{className:"item",children:[a.jsx("p",{className:n("title",t.fontBlack,t.fontGothamBold,t.marginBottom0),children:"Meter Instructions"}),a.jsx("p",{className:n("value",t.colorBlack,t.marginTop3px),children:u.length>0&&a.jsx(it,{maxLength:Be(),value:u[0].modelMeterInstructions})})]})}),a.jsx("div",{className:n("col1",p(),N()),children:a.jsxs("div",{className:"item",children:[a.jsx("p",{className:n("title",t.fontBlack,t.fontGothamBold,t.marginBottom0),children:"Status"}),a.jsx("p",{className:n("value",t.colorBlack,t.marginTop3px),children:"Pending"})]})}),a.jsx("div",{className:n("col1",p(),N()),children:a.jsxs("div",{className:n("item",m.labelWidth),children:[a.jsx("p",{className:n("title",t.fontBlack,t.fontGothamBold,t.marginBottom0),children:"Enter Meter Reading Date"}),a.jsx("p",{className:n("value",t.colorBlack,t.marginTop3px),children:a.jsx(lt,{classes:n(m.inputTextbox,g?"":t.disabledIcon),handleDateChange:e=>g?De(e):"",disableToolbar:!g,emptyLabel:"MM/DD/YYYY",format:"MM/dd/yyyy",minDate:!0,maxDate:!0,maxDateValue:new Date,minDateValue:ze(new Date,30),testId:"dateInput"})}),a.jsx("p",{className:t.error,children:we()})]})}),u.length>0&&y.map(e=>a.jsxs(a.Fragment,{children:[a.jsx("div",{className:n("col1",p(),N()),children:a.jsxs("div",{className:"item",children:[a.jsx("p",{className:n("title",t.fontBlack,t.fontGothamBold,t.marginBottom0),children:"Meter Type"}),a.jsx("p",{className:n("value",t.colorBlack,t.marginTop3px),children:e.meterType})]})}),a.jsxs("div",{className:n("col1",p(),N()),children:[a.jsxs("div",{className:"item",children:[a.jsx("p",{className:n("title",t.fontBlack,t.fontGothamBold,t.marginBottom0),children:"Last Reading Date"}),a.jsx("p",{className:n("value",t.colorBlack,t.marginTop3px),children:ot.converDateFormatWithoutTime(e.lastMeterDate)})]}),a.jsxs("div",{className:"item",children:[a.jsx("p",{className:n("title",t.fontBlack,t.fontGothamBold,t.marginBottom0),children:"Last Reading"}),a.jsx("p",{className:n("value",t.colorBlack,t.marginTop3px),children:e.lastMeterDisplay.toLocaleString("en-US")})]})]}),a.jsx("div",{className:n("col1",p(),N()),children:a.jsxs("div",{className:n("item",m.labelWidthReading),children:[a.jsx("p",{className:n("title",t.fontBlack,t.fontGothamBold,t.marginBottom0),children:"New Reading"}),a.jsx("p",{className:n("value",t.colorBlack,t.marginTop3px),children:a.jsx(ct,{dueMeterReadingAccess:g,id:"outlined-basic",placeholder:"New Reading",variant:"outlined",meterId:e.meterId,handleReadingChange:Pe,className:g?"":t.disabledIcon,dataTestId:"searchInput"})}),a.jsx("p",{className:t.error,children:Fe(e.meterId)})]})})]})),a.jsx(Ke,{variant:"contained",color:"primary",disableRipple:!0,className:n(m.marginRight8,t.fontExact14,t.fontGothamBook,t.marginLeftAuto,t.boxShadow,t.bRadius8,t.displayFlex,Ge()),onClick:()=>g?ke():"","data-testid":"submitBtn",children:"Submit"})]})})})})})]})}),oe&&a.jsx(dt,{handleClose:Le,actions:!0,dialogTitle:"Confirm submission",closeButton:!0,warning:!1,showTitle:!0,textAlign:"center",closeButtonTitle:"Change",actionButtonTitle:"Confirm",handleDelete:()=>J(),children:ce})]})})};export{Nt 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.