1 line
51 KiB
JavaScript
1 line
51 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[9592],{855:(e,t,a)=>{a.d(t,{A:()=>l});var s=a(7208),n=a(76475),o=a(44414);function l(e){var t,a;let l,i,{children:r,type:c="scale",direction:d="right",offset:u=10,scale:p={hover:1.05,tap:.95}}=e;switch(d){case"up":case"left":l=u,i=0;break;default:l=0,i=u}const[m,h]=(0,s.Y)(l,i),[x,g]=(0,s.Y)(l,i);switch(c){case"rotate":return(0,o.jsx)(n.P.div,{animate:{rotate:360},transition:{repeat:1/0,repeatType:"loop",duration:2,repeatDelay:0},children:r});case"slide":return"up"===d||"down"===d?(0,o.jsx)(n.P.div,{animate:{y:void 0!==x?x:""},onHoverEnd:()=>g(),onHoverStart:()=>g(),children:r}):(0,o.jsx)(n.P.div,{animate:{x:void 0!==m?m:""},onHoverEnd:()=>h(),onHoverStart:()=>h(),children:r});default:return"number"===typeof p&&(p={hover:p,tap:p}),(0,o.jsx)(n.P.div,{whileHover:{scale:null===(t=p)||void 0===t?void 0:t.hover},whileTap:{scale:null===(a=p)||void 0===a?void 0:a.tap},children:r})}}},20466:(e,t,a)=>{a.d(t,{k:()=>n});var s=a(8881);const n=(e,t,a)=>(0,s.M8)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:a||2e3})},42041:()=>{},80987:(e,t,a)=>{a.r(t),a.d(t,{default:()=>me});var s=a(89379),n=a(9950),o=a(47223),l=a(16491),i=a(48089),r=a(82053),c=a(77922),d=a(29925),u=a(60899),p=a(82223),m=a(2046),h=a(25333),x=a(16497),g=a(93038),A=a(93230),f=a(37324),v=a(46639),j=a(40033),b=a(25979),y=a(2660),k=a(74745),S=a(28170),N=a(79739),w=a(96319),P=a(13838),C=a(54826),_=a(85527),I=a(43302),z=a(7762),D=a(28429),Y=a(63057),M=a(26910),L=a(14857),R=a(99459),W=a(52351),H=(a(172),a(50027),a(30633)),E=a(81831),F=a(95359),T=a(96583),O=a(4159),B=a.n(O),U=a(8881),q=a(60767),K=a(81419),V=a(3911),$=a(47738),Z=a(9845),G=a(87942),Q=a(76746),X=a(20466),J=a(98007),ee=a(99810),te=a(49029),ae=a(47113),se=a(82215),ne=a(2527),oe=a.n(ne),le=(a(55392),a(42041),a(855)),ie=a(44414),re=a(36220);B().extend(re);const ce="undefined"!==typeof window?new(oe().Icon)({iconUrl:"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-blue.png",shadowUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]}):null,de="undefined"!==typeof window?new(oe().Icon)({iconUrl:"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png",shadowUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]}):null,ue=e=>{let{startPoint:t,endPoint:a}=e;const s=(0,J.ko)();return(0,n.useEffect)((()=>{const e=[],n=parseFloat(null===t||void 0===t?void 0:t.latitude),o=parseFloat(null===t||void 0===t?void 0:t.longitude),l=parseFloat(null===a||void 0===a?void 0:a.latitude),i=parseFloat(null===a||void 0===a?void 0:a.longitude);isNaN(n)||isNaN(o)||0===n||0===o||e.push([n,o]),isNaN(l)||isNaN(i)||0===l||0===i||e.push([l,i]),1===e.length?s.setView(e[0],14):2===e.length&&s.fitBounds(e,{padding:[50,50]})}),[null===t||void 0===t?void 0:t.latitude,null===t||void 0===t?void 0:t.longitude,null===a||void 0===a?void 0:a.latitude,null===a||void 0===a?void 0:a.longitude,s]),null},pe=e=>{let{startPoint:t,endPoint:a,appLocaLat:s,appLocaLng:o}=e;const l=[parseFloat(s)||11.0168,parseFloat(o)||76.9558],i=(null===t||void 0===t?void 0:t.latitude)&&(null===t||void 0===t?void 0:t.longitude)&&0!==parseFloat(t.latitude),r=(null===a||void 0===a?void 0:a.latitude)&&(null===a||void 0===a?void 0:a.longitude)&&0!==parseFloat(a.latitude),c=i?[parseFloat(t.latitude),parseFloat(t.longitude)]:null,d=r?[parseFloat(a.latitude),parseFloat(a.longitude)]:null,[u,p]=n.useState([]);return n.useEffect((()=>{if(!i||!r)return void p([]);(async()=>{const e="https://router.project-osrm.org/route/v1/driving/".concat(t.longitude,",").concat(t.latitude,";").concat(a.longitude,",").concat(a.latitude,"?overview=full&geometries=geojson");try{var s;const t=await fetch(e),a=await t.json();if(null!==(s=a.routes)&&void 0!==s&&s.length){const e=a.routes[0].geometry.coordinates.map((e=>{let[t,a]=e;return[a,t]}));p(e)}else p([c,d])}catch(n){console.error("OSRM Error:",n),p([c,d])}})()}),[t.latitude,t.longitude,a.latitude,a.longitude,i,r]),(0,ie.jsx)("div",{style:{position:"relative",width:"100%",height:"100%"},children:(0,ie.jsxs)(ee.W,{center:l,zoom:12,style:{width:"100%",height:"100%"},zoomControl:!0,children:[(0,ie.jsx)(te.e,{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"\xa9 OpenStreetMap contributors"}),i&&(0,ie.jsx)(ae.p,{position:c,icon:ce}),r&&(0,ie.jsx)(ae.p,{position:d,icon:de}),u.length>0?(0,ie.jsx)(se.R,{positions:u,color:"#662582",weight:4}):i&&r&&(0,ie.jsx)(se.R,{positions:[c,d],color:"#662582",weight:4}),(0,ie.jsx)(ue,{startPoint:t,endPoint:a})]})})};const me=()=>{R.A.setApiKey("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8");const e=n.useRef(!1),t=(0,D.Zp)(),a=(0,L.A)(),O=(0,o.A)(a.breakpoints.down("md")),J=(0,n.useRef)(null),ee=(0,n.useRef)(null),[te,ae]=n.useState(""),[se,ne]=n.useState(""),[oe,re]=(0,n.useState)(localStorage.getItem("locationid")),[ce,de]=(0,n.useState)(!1),ue=(0,n.useRef)(null),me=(0,n.useRef)(null),he=(0,n.useRef)(null),[xe,ge]=(0,n.useState)(0),[Ae,fe]=(0,n.useState)(!1),[ve,je]=(0,n.useState)([]),[be,ye]=(0,n.useState)(B()().format("MM-DD-YYYY")),[ke,Se]=(0,n.useState)(),[Ne,we]=(0,n.useState)(),[Pe,Ce]=(0,n.useState)([]),[_e,Ie]=(0,n.useState)(""),[ze,De]=(0,n.useState)(!1),[Ye,Me]=(0,n.useState)(!1),[Le,Re]=(0,n.useState)(!1),[We,He]=(0,n.useState)(""),[Ee,Fe]=(0,n.useState)(),[Te,Oe]=(0,n.useState)({}),[Be,Ue]=(0,n.useState)(""),[qe,Ke]=(0,n.useState)([]),[Ve,$e]=(0,n.useState)({latitude:0,longitude:0}),[Ze,Ge]=(0,n.useState)({latitude:0,longitude:0}),[Qe,Xe]=(0,n.useState)(!1),[Je,et]=(0,n.useState)(0),[tt,at]=(0,n.useState)(0),[st,nt]=(0,n.useState)(0),[ot,lt]=(0,n.useState)(0),[it,rt]=(0,n.useState)(0),[ct,dt]=(0,n.useState)([]),[ut,pt]=(0,n.useState)("Select "),[mt,ht]=(0,n.useState)(0),[xt,gt]=(0,n.useState)(""),[At,ft]=(0,n.useState)(0),[vt,jt]=(0,n.useState)(0),[bt,yt]=(0,n.useState)(null),[kt,St]=(0,n.useState)(!1),[Nt,wt]=(0,n.useState)(""),[Pt,Ct]=(0,n.useState)([]),[_t,It]=(0,n.useState)(null),[zt,Dt]=(0,n.useState)(null),[Yt,Mt]=(0,n.useState)(null),[Lt,Rt]=(0,n.useState)(0),[Wt,Ht]=(0,n.useState)(0),[Et,Ft]=(0,n.useState)(0),[Tt,Ot]=(0,n.useState)([]),[Bt,Ut]=(0,n.useState)(),[qt,Kt]=(0,n.useState)(),[Vt,$t]=(0,n.useState)(),[Zt,Gt]=(0,n.useState)("Select Location"),Qt=localStorage.getItem("userid"),[Xt,Jt]=(0,n.useState)(0),[ea,ta]=(0,n.useState)(0),[aa,sa]=(0,n.useState)(0),[na,oa]=(0,n.useState)(0),[la,ia]=(0,n.useState)(),[ra,ca]=(0,n.useState)(),[da,ua]=(0,n.useState)(!1),[pa,ma]=(0,n.useState)(!1),[ha,xa]=(0,n.useState)(0),[ga,Aa]=(0,n.useState)(0),[fa,va]=(0,n.useState)(1),[ja,ba]=(0,n.useState)(null),[ya,ka]=(0,n.useState)(null),[Sa,Na]=(0,n.useState)(null),[wa,Pa]=(0,n.useState)(null),[Ca,_a]=(0,n.useState)(1),Ia=!!(null!==zt&&void 0!==zt&&zt.firstname&&null!==zt&&void 0!==zt&&zt.contactno&&10===String(zt.contactno).length&&null!==zt&&void 0!==zt&&zt.doorno&&null!==zt&&void 0!==zt&&zt.suburb&&null!==zt&&void 0!==zt&&zt.postcode);(0,n.useEffect)((()=>{console.log("pickupSlotsList",Sa),console.log("pickupSlot",wa)}),[Sa,wa]),"undefined"===typeof window||e.current||(document.querySelector("#google-maps")||function(e,t,a){if(!t)return;const s=document.createElement("script");s.setAttribute("async",""),s.setAttribute("id",a),s.src=e,t.appendChild(s)}("https://maps.googleapis.com/maps/api/js?key=".concat("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8","&libraries=places&location=10.3656,77.9690&radius=50000&components=country:IN&strictbounds=true"),document.querySelector("head"),"google-maps"),e.current=!0);(0,n.useEffect)((()=>{(async()=>{try{const e=await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(Qt));console.log("fetchAppLocations",e.data.details),Gt(e.data.details)}catch(e){console.log("locationRes",e)}})()}),[]);(0,n.useEffect)((()=>{xe&&(async()=>{Me(!0),await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenants/?applocationid=").concat(xe,"&status=active")).then((e=>{if(console.log(e),e.data.status){let t=[];e.data.details.map((e=>{t.push((0,s.A)((0,s.A)({},e),{},{label:"".concat(e.tenantname)}))})),Ke(t)}Me(!1)})).catch((e=>{console.log(e),Me(!1)}))})()}),[xe]);(0,n.useEffect)((()=>{console.log("startPoint",Ve),console.log("endPoint",Ze),0!=Ve.latitude&&0!=Ve.longitude&&0!=Ze.latitude&&0!=Ze.longitude&&za(Ve,Ze)}),[Ve,Ze]);const za=async(e,t)=>{try{const a=(1.3*((e,t,a,s)=>{const n=e=>e*Math.PI/180,o=n(a-e),l=n(s-t),i=Math.sin(o/2)*Math.sin(o/2)+Math.cos(n(e))*Math.cos(n(a))*Math.sin(l/2)*Math.sin(l/2);return 2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i))*6371})(e.latitude,e.longitude,t.latitude,t.longitude)).toFixed(2);console.log("distance in km ",a);const s=Math.round(a);if(console.log("roundedDistance",s),et(s),s<ot)rt(tt);else{console.log("minKm",ot),console.log("pricePerKm",st),console.log("basePrice",tt);const e=(s-ot)*st+tt;console.log("total",e),rt(e)}Xe(!0),s>Vt&&(Xe(!0),fe(!0));const n=40,o=Math.round(s/n*60);console.log("Distance: ".concat(s,", Duration: ").concat(o))}catch(a){console.error("Error calculating distance:",a)}};(0,n.useEffect)((()=>{At&&Ma()}),[(null===Nt||void 0===Nt?void 0:Nt.length)>3,""==Nt,At]),(0,n.useEffect)((()=>{if(Pe[0]){let e=[];Pe.map((t=>{B()().diff(B()("".concat(B()(be).format("MM-DD-YYYY")," ").concat(B()(t).format("HH:mm:ss"))),"m")<=0&&e.push(t)}))}}),[Pe]);(0,n.useEffect)((()=>{At&&(async()=>{Me(!0),console.log("tenantid",At),await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantinfo/?tenantid=").concat(At)).then((e=>{console.log("fetchtenantinfo",e),e.data.status&&(Oe(e.data.details),Da(),pt(e.data.details.subcategoryname),ht(e.data.details.subcategoryid)),Me(!1)})).catch((e=>{console.log(e),Me(!1)}))})()}),[At]);(0,n.useEffect)((()=>{(async()=>{await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getsubcategories/?moduleid=6")).then((e=>{console.log("subcateRes",e.data.details),e.data.status&&dt(e.data.details)})).catch((e=>{console.log(e)}))})()}),[]);(0,n.useEffect)((()=>{xe&&(async()=>{Me(!0),await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocations/?applocationid=").concat(xe)).then((e=>{console.log("fetchTiming",e);const{opentime:t,closetime:a,latitude:s,longitude:n,radius:o}=e.data.details[0];if(e.data.status){Ut(s),Kt(n),$t(o),console.log("radius",o),Se("".concat(B()().format("MM-DD-YYYY")," ").concat(t)),we("".concat(B()().format("MM-DD-YYYY")," ").concat(a)),console.log("starttime","".concat(B()().format("MM-DD-YYYY")," ").concat(t)),console.log("endtime","".concat(B()().format("MM-DD-YYYY")," ").concat(a," "));let e=[];for(let s="".concat(B()().format("MM-DD-YYYY")," ").concat(t),n=0;B()("".concat(B()().format("MM-DD-YYYY")," ").concat(a," ")).diff(s,"m")>=0;n++,s=B()(s).add(30,"m"))e.push(s);console.log("setTimeslotarr",e),Ce(e)}Me(!1)})).catch((e=>{console.log(e),Me(!1)}))})()}),[xe]);const Da=async()=>{Me(!0),await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocationconfig/?applocationid=").concat(xe)).then((e=>{const t=e.data.details.applocationadmins.map((e=>e.userfcmtokem));e.data.status&&Fe(t),Me(!1)})).catch((e=>{console.log(e),Me(!1)}))};(0,n.useEffect)((()=>{ke&&Ne&&Da()}),[ke,Ne]);const Ya=(e,t,a)=>{(0,U.M8)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:a||1500}),console.log(We)},Ma=async()=>{De(!0);try{let e=""==Nt?"".concat("https://jupiter.nearle.app/live/api/v1","/customers/gettenantcustomers/?tenantid=").concat(At,"&pageno=1&pagesize=30"):"".concat("https://jupiter.nearle.app/live/api/v1","/customers/search/?tenantid=").concat(At,"&keyword=").concat(Nt);await M.A.get(e).then((e=>{e.data.status&&(console.log("clientdetails",e.data.details),je(e.data.details),Ct(e.data.details)),De(!1)})).catch((e=>{console.log(e),De(!1),Ya("server error","warning")}))}catch(e){console.log(e),De(!1)}},La=async()=>{Me(!0),await M.A.post("".concat("https://jupiter.nearle.app/live/api/v1","/utils/sendnotifications"),{priority:"high",registration_ids:Ee,data:{accessid:"AAAAILMpCEU:APA91bEavuOllBI6sFgYtxXAgNmAVwNA-MnCMHLGlR4_t7UqpLajAkdn3T0CZr_zaLBknLyim9ytFLMZgbeXmKqTad_PKCbqlYjHpaizVrLXtecxqyEy4UktIacK2UvHVUATHL-7VQQk"},notification:{title:"Nearle Merchant",body:"An Order has been placed successfully,kindly process the same",sound:"ring"}}).then((e=>{console.log(e),"Success"==e.data.message&&(0,U.M8)("Notification sent Successfully",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),Me(!1)})).catch((e=>{console.log(e),(0,U.M8)(e.message,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),Me(!1)}))};(0,n.useEffect)((()=>{if(te){const e=document.getElementById("addressAuto1"),t=new window.google.maps.places.Autocomplete(e,{strictBounds:!0,bounds:new window.google.maps.Circle({center:new window.google.maps.LatLng(Bt,qt),radius:1e3*Vt}).getBounds()});t.addListener("place_changed",(()=>{const e=t.getPlace();ae("".concat(e.name,", ").concat(e.formatted_address)),console.log("new place",e),console.log(" pick (new place) lat lng",{lat:e.geometry.location.lat(),lng:e.geometry.location.lng()}),$e({latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}),Dt((0,s.A)((0,s.A)({},zt),{},{address:"".concat(e.name," ").concat(e.formatted_address)}));const a={address:"".concat(e.name," ").concat(e.formatted_address),street_number:"",route:"",locality:"",sublocality_level_1:"",administrative_area_level_3:"",administrative_area_level_1:"",country:"",postal_code:""};e.address_components.forEach((e=>{e.types.forEach((t=>{switch(t){case"street_number":a.street_number=e.long_name;break;case"route":a.route=e.long_name;break;case"locality":a.locality=e.long_name;break;case"sublocality_level_1":a.sublocality_level_1=e.long_name;break;case"administrative_area_level_3":a.administrative_area_level_3=e.long_name;break;case"administrative_area_level_1":a.administrative_area_level_1=e.long_name;break;case"country":a.country=e.long_name;break;case"postal_code":a.postal_code=e.long_name}}))})),Dt((0,s.A)((0,s.A)({},zt),{},{address:a.address,doorno:"".concat(a.street_number," ").concat(a.route),suburb:a.sublocality_level_1,city:a.locality,postcode:a.postal_code,latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()})),console.log("Pick Address:",a)}))}}),[te]),(0,n.useEffect)((()=>{if(se){const e=document.getElementById("addressAuto2"),t=new window.google.maps.places.Autocomplete(e,{strictBounds:!0,bounds:new window.google.maps.Circle({center:new window.google.maps.LatLng(Bt,qt),radius:1e3*Vt}).getBounds()});t.addListener("place_changed",(()=>{const e=t.getPlace();ne("".concat(e.name,", ").concat(e.formatted_address)),console.log("new place",e),console.log("drop (new place) lat lng",{lat:e.geometry.location.lat(),lng:e.geometry.location.lng()}),Ge({latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}),Mt((0,s.A)((0,s.A)({},Yt),{},{address:"".concat(e.name," ").concat(e.formatted_address)}));const a={address:"".concat(e.name," ").concat(e.formatted_address),street_number:"",route:"",locality:"",sublocality_level_1:"",administrative_area_level_3:"",administrative_area_level_1:"",country:"",postal_code:""};e.address_components.forEach((e=>{e.types.forEach((t=>{switch(t){case"street_number":a.street_number=e.long_name;break;case"route":a.route=e.long_name;break;case"locality":a.locality=e.long_name;break;case"sublocality_level_1":a.sublocality_level_1=e.long_name;break;case"administrative_area_level_3":a.administrative_area_level_3=e.long_name;break;case"administrative_area_level_1":a.administrative_area_level_1=e.long_name;break;case"country":a.country=e.long_name;break;case"postal_code":a.postal_code=e.long_name}}))})),Mt((0,s.A)((0,s.A)({},Yt),{},{address:a.address,doorno:"".concat(a.street_number," ").concat(a.route),suburb:a.sublocality_level_1,city:a.locality,postcode:a.postal_code,latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()})),console.log("Drop Address:",a)}))}}),[se]);return(0,ie.jsxs)(ie.Fragment,{children:[Ye&&(0,ie.jsx)(W.A,{}),ze&&(0,ie.jsx)(W.A,{}),(0,ie.jsxs)(l.A,{className:"orders-workspace-bg",sx:{p:0,m:0,minHeight:"auto",display:"flex",flexDirection:"column"},children:[(0,ie.jsxs)(i.A,{className:"orders-card page-header-row",sx:{mb:{xs:1.5,sm:2},display:"flex",flexDirection:{xs:"column",lg:"row"},alignItems:{xs:"stretch",lg:"center"},justifyContent:"space-between",gap:{xs:1.25,lg:2},px:{xs:1.75,sm:2},py:{xs:.75,sm:.9},flexShrink:0},children:[(0,ie.jsx)(l.A,{className:"header-title-block",sx:{display:"flex",flexDirection:"column",gap:0,minWidth:0,flex:{lg:"1 1 auto"}},children:(0,ie.jsx)(l.A,{sx:{display:"flex",alignItems:"center",gap:1},children:(0,ie.jsx)(r.A,{sx:{fontWeight:700,color:"#1e293b",lineHeight:1.15,fontSize:{xs:"17px",sm:"19px"}},children:"Create New Order"})})}),(0,ie.jsxs)(l.A,{className:"header-configurators",sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:{xs:"stretch",sm:"center"},justifyContent:{xs:"stretch",lg:"flex-end"},gap:1,p:0,width:{xs:"100%",lg:"auto"},flexShrink:0},children:[(0,ie.jsx)(l.A,{sx:{width:{xs:"100%",sm:180,md:200,xl:220}},children:(0,ie.jsx)(c.A,{fullWidth:!0,autoFocus:!0,size:"small",ref:J,options:Zt||[],getOptionLabel:e=>"".concat(e.locationname),className:"header-compact-input",onChange:(e,t,a)=>{"clear"===a?(ge(0),ft(0),ba(null),Ke([]),jt(0),ka(null),Ot([]),Dt(null),Mt(null)):(ge(t.applocationid),Dt(null),Mt(null),ft(0),ba(null),jt(0),ka(null),Ot([]))},renderInput:e=>(0,ie.jsx)(d.A,(0,s.A)((0,s.A)({},e),{},{size:"small",placeholder:"Choose Location",label:"Location",InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:(0,s.A)((0,s.A)({},e.InputProps),{},{startAdornment:(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(I.sIY,{style:{color:"#94a3b8",fontSize:12,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})}),(0,ie.jsx)(l.A,{sx:{width:{xs:"100%",sm:180,md:200,xl:220}},children:(0,ie.jsx)(c.A,{fullWidth:!0,size:"small",className:"header-compact-input",options:qe||[],value:ja,onOpen:e=>{xe||(e.preventDefault(),(0,X.k)("Please select a your location first!","warning",3e3),setTimeout((()=>{var e;null===(e=J.current)||void 0===e||e.focus()}),0))},onChange:(e,t,a)=>{"clear"==a?(ft(0),ba(null),jt(0),ka(null),Ot([]),Dt(null),Mt(null)):(ft((null===t||void 0===t?void 0:t.tenantid)||0),ba(t),jt(0),ka(null),(async e=>{try{const t=await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantpricing/?tenantid=").concat(e));console.log("pricingResponse",t.data.details),at(t.data.details.baseprice),nt(t.data.details.priceperkm),lt(t.data.details.minkm)}catch(t){console.log("fetchTenantPricing error",t)}})(t.tenantid),(async e=>{try{const t=await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantlocations/?tenantid=").concat(e));console.log("gettenantlocations",t.data.details),1==t.data.details.length?(Ot(t.data.details),It(t.data.details[0]),jt(t.data.details[0].locationid),ka(t.data.details[0].locationid),Na(t.data.details[0].slots)):Ot(t.data.details)}catch(t){console.log("gettenantlocations",t)}})(t.tenantid),Mt(null))},renderInput:e=>(0,ie.jsx)(d.A,(0,s.A)((0,s.A)({},e),{},{size:"small",placeholder:"Choose Client",label:"Client",inputRef:ee,InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:(0,s.A)((0,s.A)({},e.InputProps),{},{startAdornment:(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(I.x$1,{style:{color:"#94a3b8",fontSize:11,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})}),(0,ie.jsx)(l.A,{sx:{width:{xs:"100%",sm:200,md:220,xl:240}},children:1==Tt.length?(0,ie.jsx)(d.A,{variant:"outlined",fullWidth:!0,size:"small",label:"Business Location",value:Tt[0].locationname,InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:{style:{color:a.palette.primary.main},startAdornment:(0,ie.jsx)(G.A,{style:{color:"#94a3b8",fontSize:14,marginRight:6,flexShrink:0}})}}):(0,ie.jsx)(c.A,{fullWidth:!0,size:"small",className:"header-compact-input",value:ya,options:Tt||[],getOptionLabel:e=>"".concat(e.locationname," (").concat(e.suburb,")")||0,onOpen:e=>{xe||At?At||(e.preventDefault(),(0,X.k)("Please select a your Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=ee.current)||void 0===e||e.focus()}),0)):(e.preventDefault(),(0,X.k)("Please select Location and Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=J.current)||void 0===e||e.focus()}),0))},onChange:(e,t,a)=>{"clear"===a?(jt(0),ka(null),Dt(null)):(jt(t.locationid||0),ka(t),It(t),Na(null===t||void 0===t?void 0:t.slots))},renderInput:e=>(0,ie.jsx)(d.A,(0,s.A)((0,s.A)({},e),{},{size:"small",placeholder:"Select Business Locations",label:"Business Location",color:"primary",InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:(0,s.A)((0,s.A)({},e.InputProps),{},{startAdornment:(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(G.A,{style:{color:"#94a3b8",fontSize:14,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})})]})]}),(0,ie.jsxs)(u.Ay,{container:!0,spacing:{xs:2.5,sm:3,lg:4},children:[(0,ie.jsxs)(u.Ay,{item:!0,xs:12,lg:7.5,sx:{display:"flex",flexDirection:"column",gap:{xs:1.5,sm:1.75,lg:2}},children:[(0,ie.jsxs)(i.A,{className:"orders-card",sx:{p:{xs:1.25,sm:1.5,lg:1.5}},children:[(0,ie.jsxs)(l.A,{className:"route-stepper",children:[(0,ie.jsxs)(l.A,{className:"route-step ".concat(1===Ca?"is-active":""," ").concat(Ia?"is-done":""," step-pickup"),onClick:()=>_a(1),role:"button",tabIndex:0,children:[(0,ie.jsx)(l.A,{className:"route-step-index",children:Ia&&1!==Ca?(0,ie.jsx)(C.CMH,{}):"1"}),(0,ie.jsxs)(l.A,{className:"route-step-text",children:[(0,ie.jsx)(r.A,{className:"route-step-title",children:"Pickup"}),(0,ie.jsx)(r.A,{className:"route-step-sub",children:"Where to collect"})]})]}),(0,ie.jsxs)(l.A,{className:"route-step-connector ".concat(Ia?"is-done":""),children:[(0,ie.jsx)(l.A,{className:"route-step-line"}),(0,ie.jsx)(l.A,{className:"route-step-line-arrow",children:(0,ie.jsx)(C.Z0P,{})})]}),(0,ie.jsxs)(l.A,{className:"route-step ".concat(2===Ca?"is-active":""," step-drop ").concat(Ia?"":"is-locked"),onClick:()=>{Ia?_a(2):Ya("Please complete Pickup details first","warning",2e3)},role:"button",tabIndex:0,children:[(0,ie.jsx)(l.A,{className:"route-step-index",children:"2"}),(0,ie.jsxs)(l.A,{className:"route-step-text",children:[(0,ie.jsx)(r.A,{className:"route-step-title",children:"Drop"}),(0,ie.jsx)(r.A,{className:"route-step-sub",children:"Where to deliver"})]})]})]}),(0,ie.jsxs)(l.A,{className:"route-flow",children:[(0,ie.jsxs)(l.A,{className:"location-panel pickup-panel",sx:{display:1===Ca?"block":"none"},children:[(0,ie.jsxs)(l.A,{className:"lp-header",children:[(0,ie.jsxs)(l.A,{className:"lp-header-title",children:[(0,ie.jsx)(l.A,{className:"lp-badge",children:(0,ie.jsx)(I.sIY,{})}),(0,ie.jsxs)(l.A,{children:[(0,ie.jsx)(r.A,{className:"lp-title",children:"Pickup"}),(0,ie.jsx)(r.A,{className:"lp-subtitle",children:"Where to collect the parcel"})]})]}),(0,ie.jsx)(l.A,{className:"lp-header-actions",children:(0,ie.jsx)(p.A,{className:"lp-action-btn",size:"small",disabled:!vt,startIcon:(0,ie.jsx)(q.A,{style:{fontSize:13}}),onClick:()=>{xe||At||vt?xe||At?xe?(St(!0),Rt(1),Dt(null),ae(""),wt("")):(0,X.k)("Please select Location!","warning",3e3):(0,X.k)("Please select Location and Tenant!","warning",3e3):(0,X.k)("Please select Location, Tenant and Business!","warning",3e3)},children:"From Saved"})})]}),(0,ie.jsx)(r.A,{className:"field-group-caption",children:"Contact"}),(0,ie.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{inputRef:ue,fullWidth:!0,size:"small",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(I.x$1,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Contact Name",value:(null===zt||void 0===zt?void 0:zt.firstname)||"",onChange:e=>{Dt((0,s.A)((0,s.A)({},zt),{},{firstname:e.target.value}))}})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{error:da,inputRef:me,fullWidth:!0,size:"small",type:"number",InputProps:{inputProps:{maxLength:10},startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(C.dRU,{style:{color:da?"#ef4444":"#64748b"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Contact Number",value:(null===zt||void 0===zt?void 0:zt.contactno)||"",onChange:e=>{e.target.value.length<=10&&Dt((0,s.A)((0,s.A)({},zt),{},{contactno:e.target.value})),la==e.target.value?sa(0):sa(1),e.target.value.length<10?ua(!0):ua(!1)}})})]}),(0,ie.jsx)(r.A,{className:"field-group-caption",sx:{mt:2},children:"Address Lookup"}),0==Wt?(0,ie.jsx)(d.A,{id:"addressAuto1",fullWidth:!0,size:"small",placeholder:"Search Google Maps for an address...",variant:"outlined",value:te||"",onChange:e=>ae(e.target.value),helperText:"Start typing to auto-fill the address details below",FormHelperTextProps:{className:"address-search-helper pickup-helper"},InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(q.A,{style:{fontSize:15,color:"#662582"}})}),endAdornment:(0,ie.jsx)(h.A,{onClick:()=>{ae(""),Dt((0,s.A)((0,s.A)({},zt),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Xe(!1),$e({latitude:0,longitude:0})},size:"small",children:(0,ie.jsx)(w.A,{fontSize:"small"})}),style:{borderRadius:"10px",background:"#fff"}}}):(0,ie.jsx)(d.A,{variant:"outlined",fullWidth:!0,size:"small",helperText:"Saved address selected \xb7 clear to search again",FormHelperTextProps:{className:"address-search-helper pickup-helper"},InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(I.sIY,{style:{fontSize:14,color:"#662582"}})}),endAdornment:(0,ie.jsx)(h.A,{onClick:()=>{Ht(0),Dt((0,s.A)((0,s.A)({},zt),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Xe(!1),$e({latitude:0,longitude:0})},size:"small",children:(0,ie.jsx)(z.A,{fontSize:"small"})}),style:{borderRadius:"10px",background:"#fff"}},value:(null===zt||void 0===zt?void 0:zt.address)||"",onChange:e=>{Dt((0,s.A)((0,s.A)({},zt),{},{address:e.target.value})),""==e.target.value&&(Ht(0),Xe(!1),$e({latitude:0,longitude:0}))}}),(0,ie.jsx)(r.A,{className:"field-group-caption",sx:{mt:2},children:"Address Details"}),(0,ie.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{fullWidth:!0,size:"small",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(_.V92,{style:{color:"#64748b",fontSize:"20px"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Door No / Street",value:(null===zt||void 0===zt?void 0:zt.doorno)||"",onChange:e=>{Dt((0,s.A)((0,s.A)({},zt),{},{doorno:e.target.value}))}})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{fullWidth:!0,size:"small",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(I.sIY,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Location",value:(null===zt||void 0===zt?void 0:zt.suburb)||"",onChange:e=>{Dt((0,s.A)((0,s.A)({},zt),{},{suburb:e.target.value}))}})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{fullWidth:!0,size:"small",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(Y.BND,{style:{color:"#64748b",fontSize:"20px"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Postcode",value:(null===zt||void 0===zt?void 0:zt.postcode)||"",onChange:e=>{Dt((0,s.A)((0,s.A)({},zt),{},{postcode:e.target.value}))}})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{fullWidth:!0,size:"small",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(I.Ndh,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Landmark",value:(null===zt||void 0===zt?void 0:zt.landmark)||"",onChange:e=>{Dt((0,s.A)((0,s.A)({},zt),{},{landmark:e.target.value}))}})})]}),1==aa&&(0,ie.jsx)(l.A,{sx:{display:"flex",justifyContent:"flex-end",mt:1},children:(0,ie.jsx)(l.A,{className:"save-later-pill",children:(0,ie.jsx)(x.A,{control:(0,ie.jsx)(g.A,{size:"small",checked:1===Xt,onChange:e=>{Jt(e.target.checked?1:0)}}),label:"Save contact for later"})})}),(0,ie.jsxs)(l.A,{className:"step-nav",children:[(0,ie.jsx)(r.A,{className:"step-nav-hint",children:Ia?"Pickup looks good. Proceed to Drop details.":"Fill the required Pickup fields to continue."}),(0,ie.jsx)(p.A,{className:"step-nav-btn step-nav-next",disabled:!Ia,endIcon:(0,ie.jsx)(C.Z0P,{style:{fontSize:12}}),onClick:()=>_a(2),children:"Continue to Drop"})]})]}),(0,ie.jsxs)(l.A,{className:"location-panel drop-panel",sx:{display:2===Ca?"block":"none"},children:[(0,ie.jsxs)(l.A,{className:"lp-header",children:[(0,ie.jsxs)(l.A,{className:"lp-header-title",children:[(0,ie.jsx)(l.A,{className:"lp-badge",children:(0,ie.jsx)(I.sIY,{})}),(0,ie.jsxs)(l.A,{children:[(0,ie.jsx)(r.A,{className:"lp-title",children:"Drop"}),(0,ie.jsx)(r.A,{className:"lp-subtitle",children:"Where to deliver the parcel"})]})]}),(0,ie.jsx)(l.A,{className:"lp-header-actions",children:(0,ie.jsx)(p.A,{className:"lp-action-btn",size:"small",disabled:!vt,startIcon:(0,ie.jsx)(q.A,{style:{fontSize:13}}),onClick:()=>{xe||At||vt?xe||At?xe?(St(!0),Rt(2),ne("")):(0,X.k)("Please select Location!","warning",3e3):(0,X.k)("Please select Location and Tenant!","warning",3e3):(0,X.k)("Please select Location, Tenant and Business!","warning",3e3)},children:"From Saved"})})]}),(0,ie.jsx)(r.A,{className:"field-group-caption",children:"Contact"}),(0,ie.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{inputRef:he,fullWidth:!0,size:"small",variant:"outlined",label:"Contact Name",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(I.x$1,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},value:(null===Yt||void 0===Yt?void 0:Yt.firstname)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Yt),{},{firstname:e.target.value}))}})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{error:pa,fullWidth:!0,size:"small",type:"number",variant:"outlined",label:"Contact Number",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(C.dRU,{style:{color:pa?"#ef4444":"#64748b"}})}),style:{borderRadius:"10px"}},value:(null===Yt||void 0===Yt?void 0:Yt.contactno)||"",onChange:e=>{e.target.value.length<=10&&Mt((0,s.A)((0,s.A)({},Yt),{},{contactno:e.target.value})),ra==e.target.value?oa(0):oa(1),e.target.value.length<10?ma(!0):ma(!1)}})})]}),(0,ie.jsx)(r.A,{className:"field-group-caption",sx:{mt:2},children:"Address Lookup"}),0==Et?(0,ie.jsx)(d.A,{id:"addressAuto2",placeholder:"Search Google Maps for an address...",variant:"outlined",size:"small",fullWidth:!0,value:se||"",onChange:e=>ne(e.target.value),helperText:"Start typing to auto-fill the address details below",FormHelperTextProps:{className:"address-search-helper drop-helper"},InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(q.A,{style:{fontSize:15,color:"#65387a"}})}),endAdornment:(0,ie.jsx)(h.A,{onClick:()=>{ne(""),Mt((0,s.A)((0,s.A)({},Yt),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Xe(!1),Ge({latitude:0,longitude:0})},size:"small",children:(0,ie.jsx)(w.A,{fontSize:"small"})}),style:{borderRadius:"10px",background:"#fff"}}}):(0,ie.jsx)(d.A,{variant:"outlined",fullWidth:!0,size:"small",helperText:"Saved address selected \xb7 clear to search again",FormHelperTextProps:{className:"address-search-helper drop-helper"},InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(I.sIY,{style:{fontSize:14,color:"#65387a"}})}),endAdornment:(0,ie.jsx)(h.A,{onClick:()=>{Ft(0),Mt((0,s.A)((0,s.A)({},Yt),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Xe(!1),Ge({latitude:0,longitude:0})},size:"small",children:(0,ie.jsx)(z.A,{fontSize:"small"})}),style:{borderRadius:"10px",background:"#fff"}},value:(null===Yt||void 0===Yt?void 0:Yt.address)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Yt),{},{address:e.target.value})),""==e.target.value&&(Ft(0),Xe(!1),Ge({latitude:0,longitude:0}))}}),(0,ie.jsx)(r.A,{className:"field-group-caption",sx:{mt:2},children:"Address Details"}),(0,ie.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{fullWidth:!0,size:"small",variant:"outlined",label:"Door No / Street",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(_.V92,{style:{color:"#64748b",fontSize:"20px"}})}),style:{borderRadius:"10px"}},value:(null===Yt||void 0===Yt?void 0:Yt.doorno)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Yt),{},{doorno:e.target.value}))}})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{fullWidth:!0,size:"small",variant:"outlined",label:"Location",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(I.sIY,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},value:(null===Yt||void 0===Yt?void 0:Yt.suburb)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Yt),{},{suburb:e.target.value}))}})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{fullWidth:!0,size:"small",variant:"outlined",label:"Postcode",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(Y.BND,{style:{color:"#64748b",fontSize:"20px"}})}),style:{borderRadius:"10px"}},value:(null===Yt||void 0===Yt?void 0:Yt.postcode)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Yt),{},{postcode:e.target.value}))}})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(d.A,{fullWidth:!0,size:"small",variant:"outlined",label:"Landmark",InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(I.Ndh,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},value:(null===Yt||void 0===Yt?void 0:Yt.landmark)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Yt),{},{landmark:e.target.value}))}})})]}),1==na&&(0,ie.jsx)(l.A,{sx:{display:"flex",justifyContent:"flex-end",mt:1},children:(0,ie.jsx)(l.A,{className:"save-later-pill",children:(0,ie.jsx)(x.A,{control:(0,ie.jsx)(g.A,{size:"small",checked:1===ea,onChange:e=>{ta(e.target.checked?1:0)}}),label:"Save contact for later"})})}),(0,ie.jsxs)(l.A,{className:"step-nav",children:[(0,ie.jsx)(p.A,{className:"step-nav-btn step-nav-back",startIcon:(0,ie.jsx)(C.QVr,{style:{fontSize:12}}),onClick:()=>_a(1),children:"Back to Pickup"}),(0,ie.jsx)(r.A,{className:"step-nav-hint",children:"Review the route below once Drop is filled."})]})]})]})]}),(0,ie.jsxs)(i.A,{className:"orders-card",sx:{p:{xs:1.5,sm:1.75,lg:2}},children:[(0,ie.jsx)(l.A,{className:"section-title-bar",sx:{mb:1.25},children:(0,ie.jsx)(r.A,{sx:{fontWeight:700,color:"#1e293b",fontSize:"15px",letterSpacing:"-0.01em"},children:"Cargo & Dispatch Logistics"})}),(0,ie.jsxs)(u.Ay,{container:!0,spacing:1.5,alignItems:"stretch",children:[(0,ie.jsx)(u.Ay,{item:!0,xs:12,sx:{pt:"0 !important"},children:(0,ie.jsxs)(l.A,{sx:{display:"flex",alignItems:"center",gap:1,mb:.25},children:[(0,ie.jsx)(r.A,{sx:{fontWeight:700,fontSize:"10.5px",color:"#64748b",letterSpacing:"0.7px",textTransform:"uppercase"},children:"Cargo Details"}),(0,ie.jsx)(l.A,{sx:{flex:1,height:"1px",background:"linear-gradient(90deg, #eef2f6 0%, transparent 100%)"}})]})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:4,children:(0,ie.jsx)(A.A,{children:(0,ie.jsx)(c.A,{id:"combo-box-demo",size:"small",options:ct,getOptionLabel:e=>(null===e||void 0===e?void 0:e.subcategoryname)||"",fullWidth:!0,sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px",paddingTop:"0px !important",paddingBottom:"0px !important"}},renderInput:e=>(0,ie.jsx)(d.A,(0,s.A)((0,s.A)({},e),{},{label:"Category",size:"small",InputLabelProps:{shrink:!0},sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px"}},InputProps:(0,s.A)((0,s.A)({},e.InputProps),{},{startAdornment:(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(C.TXh,{style:{color:"#94a3b8",fontSize:13,marginRight:6,marginLeft:2,flexShrink:0}}),e.InputProps.startAdornment]})})})),onChange:(e,t,a)=>{t?(console.log(t),pt(t.subcategoryname||""),ht(t.subcategoryid||0)):a&&(pt(null),ht(null))}})})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:4,children:(0,ie.jsx)(A.A,{children:(0,ie.jsx)(d.A,{type:"number",size:"small",value:ga,fullWidth:!0,label:"Cash Collect",InputLabelProps:{shrink:!0},onChange:e=>{Aa(e.target.value)},inputProps:{min:0},sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px"}},InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(l.A,{sx:{color:"#94a3b8",fontWeight:700,fontSize:14,lineHeight:1},children:"\u20b9"})})}})})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:4,children:(0,ie.jsx)(A.A,{children:(0,ie.jsx)(d.A,{type:"number",size:"small",value:fa,fullWidth:!0,label:"Quantity",InputLabelProps:{shrink:!0},onChange:e=>{va(e.target.value)},inputProps:{min:1},sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px"}},InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(C.H5e,{style:{color:"#94a3b8",fontSize:14}})})}})})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sx:{mt:.5,pb:0},children:(0,ie.jsxs)(l.A,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[(0,ie.jsxs)(r.A,{sx:{display:"flex",alignItems:"center",gap:.75,fontWeight:700,fontSize:"10.5px",color:"#64748b",letterSpacing:"0.7px",textTransform:"uppercase"},children:[(0,ie.jsx)(K.A,{style:{fontSize:"11px",color:"#65387a"}}),"Schedule Details"]}),(0,ie.jsx)(l.A,{sx:{flex:1,height:"1px",background:"linear-gradient(90deg, #eef2f6 0%, transparent 100%)"}})]})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sx:{pt:"0px !important"},children:(0,ie.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(E.$,{dateAdapter:F.R,children:(0,ie.jsx)(H.l,{label:"Pickup Date",format:"DD-MM-YYYY",onChange:e=>{let t=B()().diff(B()("".concat(B()(e).format("YYYY-MM-DD"))),"d");if(Ue(""),t<=0){ye(e);let t=[];Pe.map((a=>{B()().diff(B()("".concat(B()(e).format("MM-DD-YYYY")," ").concat(B()(a).format("HH:mm:ss"))),"m")<=0&&t.push(a)}))}else He("choose Upcoming Date"),Ya("choose Upcoming Date","warning"),ye(NaN)},value:B()(be),sx:{width:"100%","& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px"}},slotProps:{textField:{size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},InputProps:{startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(K.A,{style:{color:"#94a3b8",fontSize:"13px"}})})},sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px",paddingLeft:"10px"}}}},disablePast:!0})})}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,ie.jsx)(c.A,{size:"small",fullWidth:!0,options:Sa||[],sx:{width:"100%","& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px",paddingTop:"0px !important",paddingBottom:"0px !important"}},onChange:(e,t,a)=>{if("clear"!==a&&t){const e=B()(t.time,"HH:mm").format("hh:mm A");Ue(e);const a=B()("".concat(be," ").concat(e),"MM-DD-YYYY hh:mm A").format("YYYY-MM-DD hh:mm A");Pa(a)}else Ue(null),Pa(null)},getOptionLabel:e=>e?"".concat(e.name," (").concat(B()(e.time,"HH:mm").format("hh:mm A"),")"):"",renderInput:e=>(0,ie.jsx)(d.A,(0,s.A)((0,s.A)({},e),{},{label:"Pickup Time Slot",placeholder:"Select Pickup Slot",fullWidth:!0,InputLabelProps:{shrink:!0},sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px"}},InputProps:(0,s.A)((0,s.A)({},e.InputProps),{},{startAdornment:(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(V.A,{style:{color:"#94a3b8",fontSize:"13px",marginRight:"6px",marginLeft:"2px",flexShrink:0}}),e.InputProps.startAdornment]})})}))})})]})})]})]})]}),(0,ie.jsx)(u.Ay,{item:!0,xs:12,lg:4.5,sx:{position:{lg:"sticky"},top:{lg:"24px"},height:"fit-content"},children:(0,ie.jsxs)(A.A,{spacing:2,children:[(0,ie.jsxs)(i.A,{className:"orders-card",sx:{p:1.5,display:"flex",flexDirection:"column"},children:[(0,ie.jsxs)(r.A,{sx:{fontWeight:700,mb:1.25,display:"flex",alignItems:"center",gap:.75,color:"#1e293b",fontSize:"14px",letterSpacing:"-0.01em"},children:[(0,ie.jsx)(G.A,{sx:{color:"#662582",fontSize:16}}),"Live Route Preview"]}),(0,ie.jsx)("div",{className:"map-preview-wrapper",children:(0,ie.jsx)(pe,{startPoint:Ve,endPoint:Ze,appLocaLat:Bt,appLocaLng:qt})})]}),(0,ie.jsxs)(i.A,{className:"orders-card delivery-prefs-card",sx:{p:1.5},children:[(0,ie.jsxs)(l.A,{className:"delivery-prefs-header",children:[(0,ie.jsx)(r.A,{className:"delivery-prefs-title",children:"Delivery Preferences"}),(0,ie.jsx)(r.A,{className:"delivery-prefs-sub",children:"Customer notifications & dispatch instructions"})]}),(0,ie.jsxs)(l.A,{className:"delivery-prefs-row",children:[(0,ie.jsxs)(l.A,{className:"delivery-prefs-field",children:[(0,ie.jsxs)("label",{className:"delivery-prefs-label",htmlFor:"dispatch-notes-input",children:[(0,ie.jsx)($.A,{style:{fontSize:11,color:"#65387a"}}),"Special Dispatch Notes"]}),(0,ie.jsx)(d.A,{id:"dispatch-notes-input",size:"small",fullWidth:!0,placeholder:"Gate codes, call instructions, special cargo care\u2026",value:_e,onChange:e=>Ie(e.target.value),sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",padding:"0 10px",alignItems:"center",fontSize:"12px",background:"#ffffff",height:"32px"},"& .MuiOutlinedInput-input":{padding:"0 !important",fontSize:"12px !important",lineHeight:"32px"}}})]}),(0,ie.jsxs)(l.A,{className:"sms-toggle-tile ".concat(1===ha?"is-active":""),onClick:()=>xa(1===ha?0:1),role:"button",tabIndex:0,children:[(0,ie.jsxs)(l.A,{className:"sms-toggle-left",children:[(0,ie.jsx)(l.A,{className:"sms-toggle-icon",children:(0,ie.jsx)(Z.A,{style:{fontSize:13}})}),(0,ie.jsxs)(l.A,{sx:{minWidth:0},children:[(0,ie.jsx)(r.A,{className:"sms-toggle-title",children:"SMS Updates"}),(0,ie.jsx)(r.A,{className:"sms-toggle-sub",children:"Auto-notify customer on dispatch & delivery"})]})]}),(0,ie.jsx)(f.A,{size:"small",checked:1===ha,onChange:e=>{e.stopPropagation(),xa(e.target.checked?1:0)}})]})]})]}),(0,ie.jsxs)(i.A,{className:"orders-card pricing-summary-card",children:[(0,ie.jsxs)(l.A,{className:"pricing-header",children:[(0,ie.jsx)(r.A,{className:"pricing-title",children:"Pricing & Dispatch"}),(0,ie.jsx)(r.A,{className:"pricing-subtitle",children:"Live cost estimate"})]}),(0,ie.jsxs)("div",{className:"price-metric-item",children:[(0,ie.jsxs)("div",{className:"price-metric-label",children:[(0,ie.jsx)("span",{className:"price-metric-icon icon-distance",children:(0,ie.jsx)(C.$Fg,{})}),(0,ie.jsx)("span",{children:"Delivery Distance"})]}),(0,ie.jsx)("div",{className:"price-metric-value ".concat(Qe?"highlight":""),children:Qe?"".concat(Je," km"):"\u2014"})]}),(0,ie.jsxs)("div",{className:"price-metric-item",children:[(0,ie.jsxs)("div",{className:"price-metric-label",children:[(0,ie.jsx)("span",{className:"price-metric-icon icon-base",children:(0,ie.jsx)(C.MxO,{})}),(0,ie.jsxs)("span",{children:["Base Fare",(0,ie.jsxs)("span",{className:"price-metric-sub",children:[" \xb7 ",ot," km"]})]})]}),(0,ie.jsx)("div",{className:"price-metric-value",children:tt?"\u20b9".concat(tt.toFixed(2)):"\u20b90.00"})]}),(0,ie.jsxs)("div",{className:"price-metric-item",children:[(0,ie.jsxs)("div",{className:"price-metric-label",children:[(0,ie.jsx)("span",{className:"price-metric-icon icon-rate",children:(0,ie.jsx)(C.YYR,{})}),(0,ie.jsx)("span",{children:"Rate per km"})]}),(0,ie.jsxs)("div",{className:"price-metric-value",children:[st?"\u20b9".concat(st.toFixed(2)):"\u20b90.00",(0,ie.jsx)("span",{className:"price-metric-unit",children:"/km"})]})]}),Qe&&(0,ie.jsxs)("div",{className:"total-charge-badge",children:[(0,ie.jsxs)("div",{className:"total-charge-left",children:[(0,ie.jsx)(C.wTh,{className:"total-charge-icon"}),(0,ie.jsx)("div",{className:"total-charge-label",children:"Total Delivery Charge"})]}),(0,ie.jsxs)("div",{className:"total-charge-val",children:["\u20b9",it.toFixed(2)]})]}),(0,ie.jsx)(l.A,{sx:{mt:1.5},children:(0,ie.jsx)(le.A,{children:(0,ie.jsx)(p.A,{fullWidth:!0,className:"gradient-btn-create",disabled:!Qe||!Be||!wa,startIcon:!Le&&(0,ie.jsx)(C.Cer,{style:{fontSize:11}}),onClick:()=>{Me(!0),Re(!0),(async()=>{let e={};if(e={orders:{applocationid:Te.applolcationid,cancellled:"",categoryid:+Te.categoryid,configid:9,customerid:0==Xt&&+zt.customerid||0,deliveryaddress:Yt.address||"",deliverycharge:+it.toFixed(2)||0,deliverycity:Yt.city||"",deliverycontactno:Yt.contactno||"",deliverycustomer:Yt.firstname||"",deliveryid:0==ea&&+Yt.customerid||0,deliverylandmark:Yt.landmark||"",deliverylat:Yt.latitude.toString(),deliverylocation:Yt.suburb||"",deliverylocationid:Yt.deliverylocationid||0,deliverylong:Yt.longitude.toString(),deliverytime:"".concat(B()(be).format("YYYY-MM-DD")," ").concat(B()(Be.$d).format("HH:mm:ss")),deliverytype:"B",delivered:"",itemcount:1,kms:Je.toString()||0,locationid:+vt,moduleid:+Te.moduleid,orderamount:+it.toFixed(2)||0,ordercharges:0,orderdate:B()().format("YYYY-MM-DD HH:mm:ss"),ordernotes:_e,orderstatus:"created",ordervalue:+it.toFixed(2)||0,partnerid:Te.partnerid,partneruserid:+Qt,paymentstatus:1,paymenttype:42,pickupaddress:zt.address||"",pickupcity:zt.city||"",pickupcontactno:zt.contactno||"",pickupcustomer:zt.firstname||"",pickuplandmark:zt.landmark||"",pickuplat:zt.latitude.toString()||"",pickuplocation:zt.suburb||"",pickuplocationid:zt.deliverylocationid||0,pickuplong:zt.longitude.toString()||"",smsdelivery:ha,subcategoryid:+mt,tenantid:Te.tenantid,collectionamt:+ga,quantity:+fa,weight:xt,pickupSlot:wa},pickup:{address:zt.address||"",applocationid:Te.applolcationid,city:zt.city||"",configid:1,contactno:zt.contactno||"",customertoken:"",customerid:0==Xt&&zt.customerid||0,devicetype:"",deviceid:"",dialcode:"+91",doorno:zt.doorno||"",email:zt.email||"",firstname:zt.firstname||"",landmark:zt.landmark||"",latitude:zt.latitude.toString()||"",longitude:zt.longitude.toString()||"",postcode:zt.postcode||"",primaryaddress:1,locationid:zt.deliverylocationid||0,profileimage:"",state:zt.state||"",suburb:zt.suburb||"",tenantid:Te.tenantid},drop:{address:Yt.address||"",applocationid:Te.applolcationid,city:Yt.city||"",configid:1,contactno:Yt.contactno||"",customertoken:"",customerid:0==ea&&Yt.customerid||0,devicetype:"",deviceid:"",locationid:Yt.deliverylocationid||0,dialcode:"+91",doorno:Yt.doorno||"",email:Yt.email||"",firstname:Yt.firstname||"",landmark:Yt.landmark||"",latitude:Yt.latitude.toString(),longitude:Yt.longitude.toString(),postcode:Yt.postcode||"",primaryaddress:1,profileimage:"",state:Yt.state||"",suburb:Yt.suburb||"",tenantid:Te.tenantid}},console.log("createsubmitobj2",e),zt.firstname)if(zt.contactno)if(10!=zt.contactno.length)Ya("Check Pickup Contact Number ","error",2e3);else if(zt.suburb)if(zt.city)if(zt.postcode)if(zt.landmark)if(Yt.firstname)if(Yt.contactno)if(10!==Yt.contactno.length)Ya("Check Drop Contact Number ","error",2e3);else if(Yt.suburb)if(Yt.city)if(Yt.postcode)if(Yt.landmark)if(Be)if(ht)try{const a=await M.A.post("".concat("https://jupiter.nearle.app/live/api/v2","/orders/createorder"),e);a.data.status?(console.log("createRes",a),(0,U.M8)("Order Created Successfully",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),Ee&&La(),t("/nearle/orders")):Ya("Error in creating orders","warning"),Me(!1)}catch(a){Ya(a.message,"warning"),console.log("createResErr",a)}else Ya("Choose SubCategory ","warning",2e3);else Ya("Choose deliverytime ","warning",2e3);else Ya("Enter Drop Landmark ","warning",2e3);else Ya("Enter Drop postcode ","warning",2e3);else Ya("Enter Drop City ","warning",2e3);else Ya("Enter Drop Suburb ","warning",2e3);else Ya("Enter Drop Contact Number","warning",2e3);else Ya("Enter Drop Contact Name ","warning",2e3);else Ya("Enter Pickup Landmark ","warning",2e3);else Ya("Enter Pickup Postcode ","warning",2e3);else Ya("Enter Pickup City ","warning",2e3);else Ya("Enter Pickup Location ","warning",2e3);else Ya("Enter Pickup Contact Number ","warning",2e3);else Ya("Enter Pickup Contact Name ","warning",2e3)})(),setTimeout((()=>{Me(!1),Re(!1)}),2e3)},children:Le?(0,ie.jsx)(v.A,{color:"inherit",size:16,thickness:5}):"Dispatch Delivery Order"})})})]})]})})]})]}),(0,ie.jsxs)(T.A,{open:kt,onClose:()=>{St(!1),wt("")},fullWidth:!0,fullScreen:O,sx:{"& .MuiDialog-paper":{borderRadius:{xs:0,sm:"16px"},overflow:"hidden"}},children:[(0,ie.jsx)(j.A,{sx:{background:"linear-gradient(135deg, #662582 0%, #9255AB 100%)",color:"white",py:2.5},children:(0,ie.jsxs)(A.A,{spacing:1.5,children:[(0,ie.jsx)(r.A,{variant:"h4",sx:{fontWeight:600,color:"white"},children:"Select Saved Address (".concat(1===Lt?"Pickup":"Drop",")")}),(0,ie.jsx)(b.A,{sx:{width:"100%"},children:(0,ie.jsx)(y.A,{autoFocus:!0,fullWidth:!0,id:"input-search-header",placeholder:"Search by name, contact, or address...",value:Nt,onChange:e=>wt(e.target.value),sx:{bgcolor:"white",borderRadius:"10px","& .MuiOutlinedInput-input":{p:"10px 14px"}},startAdornment:(0,ie.jsx)(m.A,{position:"start",children:(0,ie.jsx)(q.A,{style:{fontSize:"small",color:"#64748b"}})}),endAdornment:(0,ie.jsx)(h.A,{sx:{visibility:Nt?"visible":"hidden",p:.5},onClick:()=>{wt("")},children:(0,ie.jsx)(z.A,{style:{fontSize:"18px"}})}),autoComplete:"off"})})]})}),(0,ie.jsx)(k.A,{}),(0,ie.jsx)(S.A,{sx:{p:3,maxHeight:"600px",overflowY:"auto",bgcolor:"#fafbfc"},children:0==(null===Pt||void 0===Pt?void 0:Pt.length)?(0,ie.jsx)(A.A,{spacing:2,direction:"row",alignItems:"center",justifyContent:"center",sx:{minHeight:300},children:(0,ie.jsx)(P.A,{description:"No saved addresses found for this client"})}):(0,ie.jsx)(l.A,{children:Pt&&Pt.map(((e,t)=>(0,ie.jsx)(p.A,{className:"address-card-btn",onClick:()=>{St(!1),wt(""),1===Lt?(console.log("PickupClient",e),Ht(1),$e({latitude:e.latitude,longitude:e.longitude}),Dt(e),ia(e.contactno)):(console.log("DropClient",e),Ft(1),Ge({latitude:e.latitude,longitude:e.longitude}),Mt(e),ca(e.contactno))},disabled:(null===zt||void 0===zt?void 0:zt.customerid)===e.customerid,children:(0,ie.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column"},children:[(0,ie.jsx)(r.A,{variant:"subtitle1",sx:{textAlign:"left",fontWeight:600,color:"#1e293b"},children:"".concat(e.firstname," (").concat(e.contactno,")")}),(0,ie.jsx)(r.A,{variant:"body2",sx:{textAlign:"left",color:"#64748b",mt:.5,lineHeight:1.4},children:e.address})]})},t)))})}),(0,ie.jsx)(k.A,{}),(0,ie.jsx)(N.A,{sx:{p:2.5,bgcolor:"#fafbfc"},children:(0,ie.jsx)(p.A,{color:"error",variant:"outlined",sx:{borderRadius:"8px",textTransform:"none",px:3,"&:hover":{bgcolor:"#ef4444",color:"white",borderColor:"#ef4444"}},onClick:()=>{St(!1),wt("")},children:"Cancel"})})]}),(0,ie.jsxs)(T.A,{open:Ae,onClose:()=>{fe(!1)},fullWidth:!0,sx:{"& .MuiDialog-paper":{borderRadius:{xs:3,sm:"16px"},p:1.5,m:{xs:1.5,sm:4},width:{xs:"calc(100% - 24px)",sm:"auto"},maxWidth:"400px"}},children:[(0,ie.jsxs)(j.A,{sx:{textAlign:"center",pb:1},children:[(0,ie.jsx)(Q.A,{sx:{fontSize:70,color:a.palette.error.main,mb:1}}),(0,ie.jsx)(r.A,{variant:"h3",sx:{color:a.palette.error.main,fontWeight:700},children:"Dispatch Blocked"})]}),(0,ie.jsx)(S.A,{sx:{textAlign:"center",pb:2},children:(0,ie.jsx)(r.A,{variant:"body1",sx:{color:"#64748b",lineHeight:1.5},children:"Our delivery partners cannot service this coordinate combination. The route distance exceeds the active operating radius for this app location."})}),(0,ie.jsx)(N.A,{sx:{bgcolor:a.palette.error.main,borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",fontWeight:600,color:"white",cursor:"pointer",py:1.5,mx:2.5,mb:2,transition:"background-color 0.2s ease","&:hover":{bgcolor:a.palette.error.dark}},onClick:()=>{fe(!1)},children:"Acknowledge & Close"})]})]})}}}]); |