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