1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[456],{76354:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/accounts/charge-points/assign-charge-point",function(){return n(74764)}])},74764:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return m}});var i=n(85893),r=n(67294),s=n(43303),a=n(58046),l=n(99514),o=n(78447),u=n(7111),c=n(73173),d=n(94018),h=n(68157),g=n(36034),v=n(14416),f=n(52619),x=n(37453),p=n(11163);let b="/accounts/charge-points",j=e=>{if(Array.isArray(e))return{value:e[0],label:e[1]};let t=[null==e?void 0:e.email,null==e?void 0:e.mobile].filter(Boolean).join(" | ");return{value:null==e?void 0:e.id,label:t?"".concat(null==e?void 0:e.name," | ").concat(t):null==e?void 0:e.name}};var y=()=>{var e,t,n,y;let[m,_]=(0,r.useState)(!1),[Z,w]=(0,r.useState)(0),[S,C]=(0,r.useState)(null),[A,k]=(0,r.useState)([]),[P,q]=(0,r.useState)(null),[E,F]=(0,r.useState)([]),I=(0,v.I0)(),N=(0,p.useRouter)(),O="string"==typeof(null===(e=N.query)||void 0===e?void 0:e.count)?N.query.count:Array.isArray(null===(t=N.query)||void 0===t?void 0:t.count)?N.query.count[0]:"",B="string"==typeof(null===(n=N.query)||void 0===n?void 0:n.chargerIds)?N.query.chargerIds:Array.isArray(null===(y=N.query)||void 0===y?void 0:y.chargerIds)?N.query.chargerIds[0]:"",G=async()=>{try{var e,t;let n=await (0,h.vP)(),i=(null==n?void 0:n.data)||{},r=(null==i?void 0:null===(e=i.stations_with_ids)||void 0===e?void 0:e.map(j))||[],s=(null==i?void 0:null===(t=i.users_with_distributor_roles)||void 0===t?void 0:t.map(j))||[];k(r),F(s)}catch(e){console.error("Failed to fetch filter data",e)}};(0,r.useEffect)(()=>{G()},[]);let T=()=>{window.history.replaceState(window.history.state,"",b)},W=async()=>{if(!B)return;let e=null==B?void 0:B.split(","),t=1===Z,n=t?P:S;if(!n)return;let i=t?{charge_point_ids:[...e],user_id:(null==n?void 0:n.value)||""}:{charge_point_ids:[...e],station_id:(null==n?void 0:n.value)||""},r=t?h.hY:h.Hg;I((0,f.VO)());try{let e=await r(i);if(I((0,f.Gx)()),e.success)return T(),_(!0);return I((0,x.G5)((null==e?void 0:e.errors)||"Something went wrong.","warning"))}catch(e){I((0,f.Gx)()),console.error("Something went wrong.",e)}},D=1===Z,R=D?P:S;return(0,r.useEffect)(()=>{!N.isReady||m||B||N.replace({pathname:b})},[B,m,N]),(0,i.jsx)(s.Z,{sx:{p:4,minHeight:"100vh",backgroundColor:"#F9FAFB"},children:m?(0,i.jsx)(d.Z,{text:D?"The Charge Points has been assigned to the distributor successfully":"The Charge Points has been assigned successfully"}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.Z,{fontSize:"32px",fontWeight:700,mb:3,children:"Assign Charge Points"}),(0,i.jsxs)(s.Z,{sx:{backgroundColor:"#ffffff",boxShadow:2,borderRadius:2,p:4},children:[(0,i.jsxs)(l.ZP,{container:!0,alignItems:"center",spacing:2,mb:4,children:[(0,i.jsx)(l.ZP,{item:!0,children:(0,i.jsx)("img",{src:"/assets/Group 151381.png",alt:"tick",height:"50px"})}),(0,i.jsx)(l.ZP,{item:!0,children:(0,i.jsx)(a.Z,{variant:"h5",fontWeight:700,children:O})}),(0,i.jsx)(l.ZP,{item:!0,children:(0,i.jsx)(a.Z,{variant:"body1",children:"charge points selected"})})]}),(0,i.jsx)(s.Z,{sx:{borderBottom:1,borderColor:"divider",mb:3},children:(0,i.jsxs)(o.Z,{value:Z,onChange:(e,t)=>
1{w(t)},"aria-label":"assign target tabs",children:[(0,i.jsx)(u.Z,{label:"Stations"}),(0,i.jsx)(u.Z,{label:"Distributors"})]})}),D?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.Z,{variant:"h6",fontWeight:500,mb:1,children:"Select Distributor to Assign"}),(0,i.jsx)(g.Z,{placeholder:"Select Distributor",options:E,value:P,selectedOption:P,onChange:e=>q(e)})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.Z,{variant:"h6",fontWeight:500,mb:1,children:"Select Station to Assign"}),(0,i.jsx)(g.Z,{placeholder:"Select Station",options:A,value:S,selectedOption:S,onChange:e=>C(e)})]}),(0,i.jsxs)(s.Z,{sx:{display:"flex",justifyContent:"flex-end",mt:5},children:[(0,i.jsx)(c.Z,{variant:"outlined",sx:{mr:2},onClick:()=>{N.push({pathname:b})},children:"Back"}),(0,i.jsx)(c.Z,{variant:"contained",onClick:W,disabled:!R,children:"Assign Chargers"})]})]})]})})};function m(){return(0,i.jsx)(y,{})}}},function(e){e.O(0,[9514,9331,3157,4703,2888,9774,179],function(){return e(e.s=76354)}),_N_E=e.O()}]);
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.