1 line
52 KiB
JavaScript
1 line
52 KiB
JavaScript
"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[8445],{855:(e,t,a)=>{a.d(t,{A:()=>l});var s=a(68106),n=a(82522),o=a(65908);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(13659);const n=(e,t,a)=>(0,s.M8)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:a||2e3})},42041:()=>{},79520:(e,t,a)=>{a.d(t,{D:()=>n,F:()=>s});const s=async(e,t)=>{const a=null===e||void 0===e?void 0:e.latitude,s=null===e||void 0===e?void 0:e.longitude,n=null===t||void 0===t?void 0:t.latitude,o=null===t||void 0===t?void 0:t.longitude;if(null==a||null==s||null==n||null==o)throw new Error("Invalid coordinates");const l={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_API_URL:"https://mock-data-api-nextjs.vercel.app/",REACT_APP_AUTH0_CLIENT_ID:"",REACT_APP_AUTH0_DOMAIN:"",REACT_APP_AWS_APP_CLIENT_ID:"",REACT_APP_AWS_POOL_ID:"",REACT_APP_FIREBASE_API_KEY:"",REACT_APP_FIREBASE_APP_ID:"",REACT_APP_FIREBASE_AUTH_DOMAIN:"",REACT_APP_FIREBASE_MEASUREMENT_ID:"",REACT_APP_FIREBASE_MESSAGING_SENDER_ID:"",REACT_APP_FIREBASE_PROJECT_ID:"",REACT_APP_FIREBASE_STORAGE_BUCKET:"",REACT_APP_GOOGLE_MAPS_API_KEY:"AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8",REACT_APP_RIDER_ACCESS_ID:"AAAAILMpCEU:APA91bEavuOllBI6sFgYtxXAgNmAVwNA-MnCMHLGlR4_t7UqpLajAkdn3T0CZr_zaLBknLyim9ytFLMZgbeXmKqTad_PKCbqlYjHpaizVrLXtecxqyEy4UktIacK2UvHVUATHL-7VQQk",REACT_APP_STAFF_TOKEN:"",REACT_APP_URL:"https://jupiter.nearle.app/live/api/v1",REACT_APP_URL2:"https://jupiter.nearle.app/live/api/v2",REACT_APP_URL3:"https://jupiter.nearle.app/live/api/v3",REACT_APP_VERSION:"v2.1.0"}.REACT_APP_OSRM_URL||"https://router.project-osrm.org";try{const e="".concat(l,"/route/v1/driving/").concat(s,",").concat(a,";").concat(o,",").concat(n,"?overview=false"),t=await fetch(e);if(t.ok){const e=await t.json();if(e.routes&&e.routes.length>0){const t=e.routes[0].distance/1e3;return Math.round(t)}}}catch(p){console.warn("OSRM API failed, falling back to Haversine math:",p)}const i=e=>e*Math.PI/180,r=i(n-a),c=i(o-s),d=Math.sin(r/2)*Math.sin(r/2)+Math.cos(i(a))*Math.cos(i(n))*Math.sin(c/2)*Math.sin(c/2),u=6371*(2*Math.atan2(Math.sqrt(d),Math.sqrt(1-d)));return Math.round(1.3*u)},n=(e,t,a,s)=>e<s?t:(e-s)*a+t},80987:(e,t,a)=>{a.r(t),a.d(t,{default:()=>he});var s=a(22555),n=a(85672),o=a(76264),l=a(48738),i=a(84007),r=a(2866),c=a(17488),d=a(86270),u=a(1939),p=a(80911),m=a(43318),h=a(11969),x=a(83900),g=a(28579),A=a(71392),f=a(94524),v=a(12010),j=a(19619),b=a(29398),y=a(29776),S=a(58571),k=a(5670),_=a(17450),P=a(43281),N=a(79520),C=a(38464),w=a(81600),I=a(20605),R=a(15172),E=a(51808),z=a(96515),D=a(90215),M=a(66157),L=a(69039),Y=a(76453),T=a(52351),F=(a(4114),a(59008),a(91939)),H=a(65293),W=a(12557),O=a(58689),B=a(46077),U=a.n(B),q=a(13659),K=a(26777),V=a(96048),G=a(3273),X=a(13763),Z=a(71188),Q=a(88664),$=a(37856),J=a(20466),ee=a(38965),te=a(43e3),ae=a(69191),se=a(87),ne=a(91001),oe=a(73413),le=a.n(oe),ie=(a(98443),a(42041),a(855)),re=a(65908),ce=a(22686);U().extend(ce);const de="undefined"!==typeof window?new(le().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,ue="undefined"!==typeof window?new(le().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,pe=e=>{let{startPoint:t,endPoint:a}=e;const s=(0,ee.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},me=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,re.jsx)("div",{style:{position:"relative",width:"100%",height:"100%"},children:(0,re.jsxs)(te.W,{center:l,zoom:12,style:{width:"100%",height:"100%"},zoomControl:!0,children:[(0,re.jsx)(ae.e,{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"\xa9 OpenStreetMap contributors"}),i&&(0,re.jsx)(se.p,{position:c,icon:de}),r&&(0,re.jsx)(se.p,{position:d,icon:ue}),u.length>0?(0,re.jsx)(ne.R,{positions:u,color:"#662582",weight:4}):i&&r&&(0,re.jsx)(ne.R,{positions:[c,d],color:"#662582",weight:4}),(0,re.jsx)(pe,{startPoint:t,endPoint:a})]})})};const he=()=>{Y.A.setApiKey("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8");const e=n.useRef(!1),t=(0,z.Zp)(),a=(0,L.A)(),B=(0,o.A)(a.breakpoints.down("md")),ee=(0,n.useRef)(null),te=(0,n.useRef)(null),[ae,se]=n.useState(""),[ne,oe]=n.useState(""),[le,ce]=(0,n.useState)(localStorage.getItem("locationid")),[de,ue]=(0,n.useState)(!1),pe=(0,n.useRef)(null),he=(0,n.useRef)(null),xe=(0,n.useRef)(null),[ge,Ae]=(0,n.useState)(0),[fe,ve]=(0,n.useState)(!1),[je,be]=(0,n.useState)([]),[ye,Se]=(0,n.useState)(U()().format("MM-DD-YYYY")),[ke,_e]=(0,n.useState)(),[Pe,Ne]=(0,n.useState)(),[Ce,we]=(0,n.useState)([]),[Ie,Re]=(0,n.useState)(""),[Ee,ze]=(0,n.useState)(!1),[De,Me]=(0,n.useState)(!1),[Le,Ye]=(0,n.useState)(!1),[Te,Fe]=(0,n.useState)(""),[He,We]=(0,n.useState)(),[Oe,Be]=(0,n.useState)({}),[Ue,qe]=(0,n.useState)(""),[Ke,Ve]=(0,n.useState)([]),[Ge,Xe]=(0,n.useState)({latitude:0,longitude:0}),[Ze,Qe]=(0,n.useState)({latitude:0,longitude:0}),[$e,Je]=(0,n.useState)(!1),[et,tt]=(0,n.useState)(0),[at,st]=(0,n.useState)(0),[nt,ot]=(0,n.useState)(0),[lt,it]=(0,n.useState)(0),[rt,ct]=(0,n.useState)(0),[dt,ut]=(0,n.useState)([]),[pt,mt]=(0,n.useState)("Select "),[ht,xt]=(0,n.useState)(0),[gt,At]=(0,n.useState)(""),[ft,vt]=(0,n.useState)(0),[jt,bt]=(0,n.useState)(0),[yt,St]=(0,n.useState)(null),[kt,_t]=(0,n.useState)(!1),[Pt,Nt]=(0,n.useState)(""),[Ct,wt]=(0,n.useState)([]),[It,Rt]=(0,n.useState)(null),[Et,zt]=(0,n.useState)(null),[Dt,Mt]=(0,n.useState)(null),[Lt,Yt]=(0,n.useState)(0),[Tt,Ft]=(0,n.useState)(0),[Ht,Wt]=(0,n.useState)(0),[Ot,Bt]=(0,n.useState)([]),[Ut,qt]=(0,n.useState)(),[Kt,Vt]=(0,n.useState)(),[Gt,Xt]=(0,n.useState)(),[Zt,Qt]=(0,n.useState)("Select Location"),$t=localStorage.getItem("userid"),[Jt,ea]=(0,n.useState)(0),[ta,aa]=(0,n.useState)(0),[sa,na]=(0,n.useState)(0),[oa,la]=(0,n.useState)(0),[ia,ra]=(0,n.useState)(),[ca,da]=(0,n.useState)(),[ua,pa]=(0,n.useState)(!1),[ma,ha]=(0,n.useState)(!1),[xa,ga]=(0,n.useState)(0),[Aa,fa]=(0,n.useState)(0),[va,ja]=(0,n.useState)(1),[ba,ya]=(0,n.useState)(null),[Sa,ka]=(0,n.useState)(null),[_a,Pa]=(0,n.useState)(null),[Na,Ca]=(0,n.useState)(null),[wa,Ia]=(0,n.useState)(1),Ra=!!(null!==Et&&void 0!==Et&&Et.firstname&&null!==Et&&void 0!==Et&&Et.contactno&&10===String(Et.contactno).length&&null!==Et&&void 0!==Et&&Et.doorno&&null!==Et&&void 0!==Et&&Et.suburb&&null!==Et&&void 0!==Et&&Et.postcode);(0,n.useEffect)((()=>{console.log("pickupSlotsList",_a),console.log("pickupSlot",Na)}),[_a,Na]),"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($t));console.log("fetchAppLocations",e.data.details),Qt(e.data.details)}catch(e){console.log("locationRes",e)}})()}),[]);(0,n.useEffect)((()=>{ge&&(async()=>{Me(!0),await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenants/?applocationid=").concat(ge,"&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)}))})),Ve(t)}Me(!1)})).catch((e=>{console.log(e),Me(!1)}))})()}),[ge]);(0,n.useEffect)((()=>{console.log("startPoint",Ge),console.log("endPoint",Ze),0!=Ge.latitude&&0!=Ge.longitude&&0!=Ze.latitude&&0!=Ze.longitude&&Ea(Ge,Ze)}),[Ge,Ze]);const Ea=async(e,t)=>{try{const a=await(0,N.F)(e,t);console.log("calculated distance in km:",a),tt(a);const s=(0,N.D)(a,at,nt,lt);console.log("total charge:",s),ct(s),Je(!0),a>Gt&&(Je(!0),ve(!0));const n=40,o=Math.round(a/n*60);console.log("Distance: ".concat(a,", Duration: ").concat(o))}catch(a){console.error("Error calculating distance:",a)}};(0,n.useEffect)((()=>{ft&&Ma()}),[(null===Pt||void 0===Pt?void 0:Pt.length)>3,""==Pt,ft]),(0,n.useEffect)((()=>{if(Ce[0]){let e=[];Ce.map((t=>{U()().diff(U()("".concat(U()(ye).format("MM-DD-YYYY")," ").concat(U()(t).format("HH:mm:ss"))),"m")<=0&&e.push(t)}))}}),[Ce]);(0,n.useEffect)((()=>{ft&&(async()=>{Me(!0),console.log("tenantid",ft),await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantinfo/?tenantid=").concat(ft)).then((e=>{console.log("fetchtenantinfo",e),e.data.status&&(Be(e.data.details),za(),mt(e.data.details.subcategoryname),xt(e.data.details.subcategoryid)),Me(!1)})).catch((e=>{console.log(e),Me(!1)}))})()}),[ft]);(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&&ut(e.data.details)})).catch((e=>{console.log(e)}))})()}),[]);(0,n.useEffect)((()=>{ge&&(async()=>{Me(!0),await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocations/?applocationid=").concat(ge)).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){qt(s),Vt(n),Xt(o),console.log("radius",o),_e("".concat(U()().format("MM-DD-YYYY")," ").concat(t)),Ne("".concat(U()().format("MM-DD-YYYY")," ").concat(a)),console.log("starttime","".concat(U()().format("MM-DD-YYYY")," ").concat(t)),console.log("endtime","".concat(U()().format("MM-DD-YYYY")," ").concat(a," "));let e=[];for(let s="".concat(U()().format("MM-DD-YYYY")," ").concat(t),n=0;U()("".concat(U()().format("MM-DD-YYYY")," ").concat(a," ")).diff(s,"m")>=0;n++,s=U()(s).add(30,"m"))e.push(s);console.log("setTimeslotarr",e),we(e)}Me(!1)})).catch((e=>{console.log(e),Me(!1)}))})()}),[ge]);const za=async()=>{Me(!0),await M.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocationconfig/?applocationid=").concat(ge)).then((e=>{const t=e.data.details.applocationadmins.map((e=>e.userfcmtokem));e.data.status&&We(t),Me(!1)})).catch((e=>{console.log(e),Me(!1)}))};(0,n.useEffect)((()=>{ke&&Pe&&za()}),[ke,Pe]);const Da=(e,t,a)=>{(0,q.M8)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:a||1500}),console.log(Te)},Ma=async()=>{ze(!0);try{let e=""==Pt?"".concat("https://jupiter.nearle.app/live/api/v1","/customers/gettenantcustomers/?tenantid=").concat(ft,"&pageno=1&pagesize=30"):"".concat("https://jupiter.nearle.app/live/api/v1","/customers/search/?tenantid=").concat(ft,"&keyword=").concat(Pt);await M.A.get(e).then((e=>{e.data.status&&(console.log("clientdetails",e.data.details),be(e.data.details),wt(e.data.details)),ze(!1)})).catch((e=>{console.log(e),ze(!1),Da("server error","warning")}))}catch(e){console.log(e),ze(!1)}},La=async()=>{Me(!0),await M.A.post("".concat("https://jupiter.nearle.app/live/api/v1","/utils/sendnotifications"),{priority:"high",registration_ids:He,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,q.M8)("Notification sent Successfully",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),Me(!1)})).catch((e=>{console.log(e),(0,q.M8)(e.message,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),Me(!1)}))};(0,n.useEffect)((()=>{if(ae){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(Ut,Kt),radius:1e3*Gt}).getBounds()});t.addListener("place_changed",(()=>{const e=t.getPlace();se("".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()}),Xe({latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}),zt((0,s.A)((0,s.A)({},Et),{},{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}}))})),zt((0,s.A)((0,s.A)({},Et),{},{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)}))}}),[ae]),(0,n.useEffect)((()=>{if(ne){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(Ut,Kt),radius:1e3*Gt}).getBounds()});t.addListener("place_changed",(()=>{const e=t.getPlace();oe("".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()}),Qe({latitude:e.geometry.location.lat(),longitude:e.geometry.location.lng()}),Mt((0,s.A)((0,s.A)({},Dt),{},{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)({},Dt),{},{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)}))}}),[ne]);return(0,re.jsxs)(re.Fragment,{children:[De&&(0,re.jsx)(T.A,{}),Ee&&(0,re.jsx)(T.A,{}),(0,re.jsxs)(l.A,{className:"orders-workspace-bg",sx:{p:0,m:0,minHeight:"auto",display:"flex",flexDirection:"column"},children:[(0,re.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,re.jsx)(l.A,{className:"header-title-block",sx:{display:"flex",flexDirection:"column",gap:0,minWidth:0,flex:{lg:"1 1 auto"}},children:(0,re.jsx)(l.A,{sx:{display:"flex",alignItems:"center",gap:1},children:(0,re.jsx)(r.A,{sx:{fontWeight:700,color:"#1e293b",lineHeight:1.15,fontSize:{xs:"17px",sm:"19px"}},children:"Create New Order"})})}),(0,re.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,re.jsx)(l.A,{sx:{width:{xs:"100%",sm:180,md:200,xl:220}},children:(0,re.jsx)(c.A,{fullWidth:!0,autoFocus:!0,size:"small",ref:ee,options:Zt||[],getOptionLabel:e=>"".concat(e.locationname),className:"header-compact-input",onChange:(e,t,a)=>{"clear"===a?(Ae(0),vt(0),ya(null),Ve([]),bt(0),ka(null),Bt([]),zt(null),Mt(null)):(Ae(t.applocationid),zt(null),Mt(null),vt(0),ya(null),bt(0),ka(null),Bt([]))},renderInput:e=>(0,re.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,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(R.sIY,{style:{color:"#94a3b8",fontSize:12,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})}),(0,re.jsx)(l.A,{sx:{width:{xs:"100%",sm:180,md:200,xl:220}},children:(0,re.jsx)(c.A,{fullWidth:!0,size:"small",className:"header-compact-input",options:Ke||[],value:ba,onOpen:e=>{ge||(e.preventDefault(),(0,J.k)("Please select a your location first!","warning",3e3),setTimeout((()=>{var e;null===(e=ee.current)||void 0===e||e.focus()}),0))},onChange:(e,t,a)=>{"clear"==a?(vt(0),ya(null),bt(0),ka(null),Bt([]),zt(null),Mt(null)):(vt((null===t||void 0===t?void 0:t.tenantid)||0),ya(t),bt(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),st(t.data.details.baseprice),ot(t.data.details.priceperkm),it(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?(Bt(t.data.details),Rt(t.data.details[0]),bt(t.data.details[0].locationid),ka(t.data.details[0].locationid),Pa(t.data.details[0].slots)):Bt(t.data.details)}catch(t){console.log("gettenantlocations",t)}})(t.tenantid),Mt(null))},renderInput:e=>(0,re.jsx)(d.A,(0,s.A)((0,s.A)({},e),{},{size:"small",placeholder:"Choose Client",label:"Client",inputRef:te,InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:(0,s.A)((0,s.A)({},e.InputProps),{},{startAdornment:(0,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(R.x$1,{style:{color:"#94a3b8",fontSize:11,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})}),(0,re.jsx)(l.A,{sx:{width:{xs:"100%",sm:200,md:220,xl:240}},children:1==Ot.length?(0,re.jsx)(d.A,{variant:"outlined",fullWidth:!0,size:"small",label:"Business Location",value:Ot[0].locationname,InputLabelProps:{shrink:!0},className:"header-compact-tf",InputProps:{style:{color:a.palette.primary.main},startAdornment:(0,re.jsx)(Q.A,{style:{color:"#94a3b8",fontSize:14,marginRight:6,flexShrink:0}})}}):(0,re.jsx)(c.A,{fullWidth:!0,size:"small",className:"header-compact-input",value:Sa,options:Ot||[],getOptionLabel:e=>"".concat(e.locationname," (").concat(e.suburb,")")||0,onOpen:e=>{ge||ft?ft||(e.preventDefault(),(0,J.k)("Please select a your Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=te.current)||void 0===e||e.focus()}),0)):(e.preventDefault(),(0,J.k)("Please select Location and Tenant first!","warning",3e3),setTimeout((()=>{var e;null===(e=ee.current)||void 0===e||e.focus()}),0))},onChange:(e,t,a)=>{"clear"===a?(bt(0),ka(null),zt(null)):(bt(t.locationid||0),ka(t),Rt(t),Pa(null===t||void 0===t?void 0:t.slots))},renderInput:e=>(0,re.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,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(Q.A,{style:{color:"#94a3b8",fontSize:14,marginRight:6,flexShrink:0}}),e.InputProps.startAdornment]})})}))})})]})]}),(0,re.jsxs)(u.Ay,{container:!0,spacing:{xs:2.5,sm:3,lg:4},children:[(0,re.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,re.jsxs)(i.A,{className:"orders-card",sx:{p:{xs:1.25,sm:1.5,lg:1.5}},children:[(0,re.jsxs)(l.A,{className:"route-stepper",children:[(0,re.jsxs)(l.A,{className:"route-step ".concat(1===wa?"is-active":""," ").concat(Ra?"is-done":""," step-pickup"),onClick:()=>Ia(1),role:"button",tabIndex:0,children:[(0,re.jsx)(l.A,{className:"route-step-index",children:Ra&&1!==wa?(0,re.jsx)(w.CMH,{}):"1"}),(0,re.jsxs)(l.A,{className:"route-step-text",children:[(0,re.jsx)(r.A,{className:"route-step-title",children:"Pickup"}),(0,re.jsx)(r.A,{className:"route-step-sub",children:"Where to collect"})]})]}),(0,re.jsxs)(l.A,{className:"route-step-connector ".concat(Ra?"is-done":""),children:[(0,re.jsx)(l.A,{className:"route-step-line"}),(0,re.jsx)(l.A,{className:"route-step-line-arrow",children:(0,re.jsx)(w.Z0P,{})})]}),(0,re.jsxs)(l.A,{className:"route-step ".concat(2===wa?"is-active":""," step-drop ").concat(Ra?"":"is-locked"),onClick:()=>{Ra?Ia(2):Da("Please complete Pickup details first","warning",2e3)},role:"button",tabIndex:0,children:[(0,re.jsx)(l.A,{className:"route-step-index",children:"2"}),(0,re.jsxs)(l.A,{className:"route-step-text",children:[(0,re.jsx)(r.A,{className:"route-step-title",children:"Drop"}),(0,re.jsx)(r.A,{className:"route-step-sub",children:"Where to deliver"})]})]})]}),(0,re.jsxs)(l.A,{className:"route-flow",children:[(0,re.jsxs)(l.A,{className:"location-panel pickup-panel",sx:{display:1===wa?"block":"none"},children:[(0,re.jsxs)(l.A,{className:"lp-header",children:[(0,re.jsxs)(l.A,{className:"lp-header-title",children:[(0,re.jsx)(l.A,{className:"lp-badge",children:(0,re.jsx)(R.sIY,{})}),(0,re.jsxs)(l.A,{children:[(0,re.jsx)(r.A,{className:"lp-title",children:"Pickup"}),(0,re.jsx)(r.A,{className:"lp-subtitle",children:"Where to collect the parcel"})]})]}),(0,re.jsx)(l.A,{className:"lp-header-actions",children:(0,re.jsx)(p.A,{className:"lp-action-btn",size:"small",disabled:!jt,startIcon:(0,re.jsx)(K.A,{style:{fontSize:13}}),onClick:()=>{ge||ft||jt?ge||ft?ge?(_t(!0),Yt(1),zt(null),se(""),Nt("")):(0,J.k)("Please select Location!","warning",3e3):(0,J.k)("Please select Location and Tenant!","warning",3e3):(0,J.k)("Please select Location, Tenant and Business!","warning",3e3)},children:"From Saved"})})]}),(0,re.jsx)(r.A,{className:"field-group-caption",children:"Contact"}),(0,re.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{inputRef:pe,fullWidth:!0,size:"small",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(R.x$1,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Contact Name",value:(null===Et||void 0===Et?void 0:Et.firstname)||"",onChange:e=>{zt((0,s.A)((0,s.A)({},Et),{},{firstname:e.target.value}))}})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{error:ua,inputRef:he,fullWidth:!0,size:"small",type:"number",InputProps:{inputProps:{maxLength:10},startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(w.dRU,{style:{color:ua?"#ef4444":"#64748b"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Contact Number",value:(null===Et||void 0===Et?void 0:Et.contactno)||"",onChange:e=>{e.target.value.length<=10&&zt((0,s.A)((0,s.A)({},Et),{},{contactno:e.target.value})),ia==e.target.value?na(0):na(1),e.target.value.length<10?pa(!0):pa(!1)}})})]}),(0,re.jsx)(r.A,{className:"field-group-caption",sx:{mt:2},children:"Address Lookup"}),0==Tt?(0,re.jsx)(d.A,{id:"addressAuto1",fullWidth:!0,size:"small",placeholder:"Search Google Maps for an address...",variant:"outlined",value:ae||"",onChange:e=>se(e.target.value),helperText:"Start typing to auto-fill the address details below",FormHelperTextProps:{className:"address-search-helper pickup-helper"},InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(K.A,{style:{fontSize:15,color:"#662582"}})}),endAdornment:(0,re.jsx)(h.A,{onClick:()=>{se(""),zt((0,s.A)((0,s.A)({},Et),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Je(!1),Xe({latitude:0,longitude:0})},size:"small",children:(0,re.jsx)(P.A,{fontSize:"small"})}),style:{borderRadius:"10px",background:"#fff"}}}):(0,re.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,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(R.sIY,{style:{fontSize:14,color:"#662582"}})}),endAdornment:(0,re.jsx)(h.A,{onClick:()=>{Ft(0),zt((0,s.A)((0,s.A)({},Et),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Je(!1),Xe({latitude:0,longitude:0})},size:"small",children:(0,re.jsx)(E.A,{fontSize:"small"})}),style:{borderRadius:"10px",background:"#fff"}},value:(null===Et||void 0===Et?void 0:Et.address)||"",onChange:e=>{zt((0,s.A)((0,s.A)({},Et),{},{address:e.target.value})),""==e.target.value&&(Ft(0),Je(!1),Xe({latitude:0,longitude:0}))}}),(0,re.jsx)(r.A,{className:"field-group-caption",sx:{mt:2},children:"Address Details"}),(0,re.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{fullWidth:!0,size:"small",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(I.V92,{style:{color:"#64748b",fontSize:"20px"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Door No / Street",value:(null===Et||void 0===Et?void 0:Et.doorno)||"",onChange:e=>{zt((0,s.A)((0,s.A)({},Et),{},{doorno:e.target.value}))}})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{fullWidth:!0,size:"small",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(R.sIY,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Location",value:(null===Et||void 0===Et?void 0:Et.suburb)||"",onChange:e=>{zt((0,s.A)((0,s.A)({},Et),{},{suburb:e.target.value}))}})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{fullWidth:!0,size:"small",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(D.BND,{style:{color:"#64748b",fontSize:"20px"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Postcode",value:(null===Et||void 0===Et?void 0:Et.postcode)||"",onChange:e=>{zt((0,s.A)((0,s.A)({},Et),{},{postcode:e.target.value}))}})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{fullWidth:!0,size:"small",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(R.Ndh,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},variant:"outlined",label:"Landmark",value:(null===Et||void 0===Et?void 0:Et.landmark)||"",onChange:e=>{zt((0,s.A)((0,s.A)({},Et),{},{landmark:e.target.value}))}})})]}),1==sa&&(0,re.jsx)(l.A,{sx:{display:"flex",justifyContent:"flex-end",mt:1},children:(0,re.jsx)(l.A,{className:"save-later-pill",children:(0,re.jsx)(x.A,{control:(0,re.jsx)(g.A,{size:"small",checked:1===Jt,onChange:e=>{ea(e.target.checked?1:0)}}),label:"Save contact for later"})})}),(0,re.jsxs)(l.A,{className:"step-nav",children:[(0,re.jsx)(r.A,{className:"step-nav-hint",children:Ra?"Pickup looks good. Proceed to Drop details.":"Fill the required Pickup fields to continue."}),(0,re.jsx)(p.A,{className:"step-nav-btn step-nav-next",disabled:!Ra,endIcon:(0,re.jsx)(w.Z0P,{style:{fontSize:12}}),onClick:()=>Ia(2),children:"Continue to Drop"})]})]}),(0,re.jsxs)(l.A,{className:"location-panel drop-panel",sx:{display:2===wa?"block":"none"},children:[(0,re.jsxs)(l.A,{className:"lp-header",children:[(0,re.jsxs)(l.A,{className:"lp-header-title",children:[(0,re.jsx)(l.A,{className:"lp-badge",children:(0,re.jsx)(R.sIY,{})}),(0,re.jsxs)(l.A,{children:[(0,re.jsx)(r.A,{className:"lp-title",children:"Drop"}),(0,re.jsx)(r.A,{className:"lp-subtitle",children:"Where to deliver the parcel"})]})]}),(0,re.jsx)(l.A,{className:"lp-header-actions",children:(0,re.jsx)(p.A,{className:"lp-action-btn",size:"small",disabled:!jt,startIcon:(0,re.jsx)(K.A,{style:{fontSize:13}}),onClick:()=>{ge||ft||jt?ge||ft?ge?(_t(!0),Yt(2),oe("")):(0,J.k)("Please select Location!","warning",3e3):(0,J.k)("Please select Location and Tenant!","warning",3e3):(0,J.k)("Please select Location, Tenant and Business!","warning",3e3)},children:"From Saved"})})]}),(0,re.jsx)(r.A,{className:"field-group-caption",children:"Contact"}),(0,re.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{inputRef:xe,fullWidth:!0,size:"small",variant:"outlined",label:"Contact Name",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(R.x$1,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},value:(null===Dt||void 0===Dt?void 0:Dt.firstname)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Dt),{},{firstname:e.target.value}))}})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{error:ma,fullWidth:!0,size:"small",type:"number",variant:"outlined",label:"Contact Number",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(w.dRU,{style:{color:ma?"#ef4444":"#64748b"}})}),style:{borderRadius:"10px"}},value:(null===Dt||void 0===Dt?void 0:Dt.contactno)||"",onChange:e=>{e.target.value.length<=10&&Mt((0,s.A)((0,s.A)({},Dt),{},{contactno:e.target.value})),ca==e.target.value?la(0):la(1),e.target.value.length<10?ha(!0):ha(!1)}})})]}),(0,re.jsx)(r.A,{className:"field-group-caption",sx:{mt:2},children:"Address Lookup"}),0==Ht?(0,re.jsx)(d.A,{id:"addressAuto2",placeholder:"Search Google Maps for an address...",variant:"outlined",size:"small",fullWidth:!0,value:ne||"",onChange:e=>oe(e.target.value),helperText:"Start typing to auto-fill the address details below",FormHelperTextProps:{className:"address-search-helper drop-helper"},InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(K.A,{style:{fontSize:15,color:"#65387a"}})}),endAdornment:(0,re.jsx)(h.A,{onClick:()=>{oe(""),Mt((0,s.A)((0,s.A)({},Dt),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Je(!1),Qe({latitude:0,longitude:0})},size:"small",children:(0,re.jsx)(P.A,{fontSize:"small"})}),style:{borderRadius:"10px",background:"#fff"}}}):(0,re.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,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(R.sIY,{style:{fontSize:14,color:"#65387a"}})}),endAdornment:(0,re.jsx)(h.A,{onClick:()=>{Wt(0),Mt((0,s.A)((0,s.A)({},Dt),{},{doorno:"",suburb:"",city:"",postcode:"",landmark:""})),Je(!1),Qe({latitude:0,longitude:0})},size:"small",children:(0,re.jsx)(E.A,{fontSize:"small"})}),style:{borderRadius:"10px",background:"#fff"}},value:(null===Dt||void 0===Dt?void 0:Dt.address)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Dt),{},{address:e.target.value})),""==e.target.value&&(Wt(0),Je(!1),Qe({latitude:0,longitude:0}))}}),(0,re.jsx)(r.A,{className:"field-group-caption",sx:{mt:2},children:"Address Details"}),(0,re.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{fullWidth:!0,size:"small",variant:"outlined",label:"Door No / Street",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(I.V92,{style:{color:"#64748b",fontSize:"20px"}})}),style:{borderRadius:"10px"}},value:(null===Dt||void 0===Dt?void 0:Dt.doorno)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Dt),{},{doorno:e.target.value}))}})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{fullWidth:!0,size:"small",variant:"outlined",label:"Location",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(R.sIY,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},value:(null===Dt||void 0===Dt?void 0:Dt.suburb)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Dt),{},{suburb:e.target.value}))}})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{fullWidth:!0,size:"small",variant:"outlined",label:"Postcode",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(D.BND,{style:{color:"#64748b",fontSize:"20px"}})}),style:{borderRadius:"10px"}},value:(null===Dt||void 0===Dt?void 0:Dt.postcode)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Dt),{},{postcode:e.target.value}))}})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(d.A,{fullWidth:!0,size:"small",variant:"outlined",label:"Landmark",InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(R.Ndh,{style:{color:"#64748b"}})}),style:{borderRadius:"10px"}},value:(null===Dt||void 0===Dt?void 0:Dt.landmark)||"",onChange:e=>{Mt((0,s.A)((0,s.A)({},Dt),{},{landmark:e.target.value}))}})})]}),1==oa&&(0,re.jsx)(l.A,{sx:{display:"flex",justifyContent:"flex-end",mt:1},children:(0,re.jsx)(l.A,{className:"save-later-pill",children:(0,re.jsx)(x.A,{control:(0,re.jsx)(g.A,{size:"small",checked:1===ta,onChange:e=>{aa(e.target.checked?1:0)}}),label:"Save contact for later"})})}),(0,re.jsxs)(l.A,{className:"step-nav",children:[(0,re.jsx)(p.A,{className:"step-nav-btn step-nav-back",startIcon:(0,re.jsx)(w.QVr,{style:{fontSize:12}}),onClick:()=>Ia(1),children:"Back to Pickup"}),(0,re.jsx)(r.A,{className:"step-nav-hint",children:"Review the route below once Drop is filled."})]})]})]})]}),(0,re.jsxs)(i.A,{className:"orders-card",sx:{p:{xs:1.5,sm:1.75,lg:2}},children:[(0,re.jsx)(l.A,{className:"section-title-bar",sx:{mb:1.25},children:(0,re.jsx)(r.A,{sx:{fontWeight:700,color:"#1e293b",fontSize:"15px",letterSpacing:"-0.01em"},children:"Cargo & Dispatch Logistics"})}),(0,re.jsxs)(u.Ay,{container:!0,spacing:1.5,alignItems:"stretch",children:[(0,re.jsx)(u.Ay,{item:!0,xs:12,sx:{pt:"0 !important"},children:(0,re.jsxs)(l.A,{sx:{display:"flex",alignItems:"center",gap:1,mb:.25},children:[(0,re.jsx)(r.A,{sx:{fontWeight:700,fontSize:"10.5px",color:"#64748b",letterSpacing:"0.7px",textTransform:"uppercase"},children:"Cargo Details"}),(0,re.jsx)(l.A,{sx:{flex:1,height:"1px",background:"linear-gradient(90deg, #eef2f6 0%, transparent 100%)"}})]})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:4,children:(0,re.jsx)(A.A,{children:(0,re.jsx)(c.A,{id:"combo-box-demo",size:"small",options:dt,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,re.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,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(w.TXh,{style:{color:"#94a3b8",fontSize:13,marginRight:6,marginLeft:2,flexShrink:0}}),e.InputProps.startAdornment]})})})),onChange:(e,t,a)=>{t?(console.log(t),mt(t.subcategoryname||""),xt(t.subcategoryid||0)):a&&(mt(null),xt(null))}})})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:4,children:(0,re.jsx)(A.A,{children:(0,re.jsx)(d.A,{type:"number",size:"small",value:Aa,fullWidth:!0,label:"Cash Collect",InputLabelProps:{shrink:!0},onChange:e=>{fa(e.target.value)},inputProps:{min:0},sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px"}},InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(l.A,{sx:{color:"#94a3b8",fontWeight:700,fontSize:14,lineHeight:1},children:"\u20b9"})})}})})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:4,children:(0,re.jsx)(A.A,{children:(0,re.jsx)(d.A,{type:"number",size:"small",value:va,fullWidth:!0,label:"Quantity",InputLabelProps:{shrink:!0},onChange:e=>{ja(e.target.value)},inputProps:{min:1},sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px"}},InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(w.H5e,{style:{color:"#94a3b8",fontSize:14}})})}})})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sx:{mt:.5,pb:0},children:(0,re.jsxs)(l.A,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[(0,re.jsxs)(r.A,{sx:{display:"flex",alignItems:"center",gap:.75,fontWeight:700,fontSize:"10.5px",color:"#64748b",letterSpacing:"0.7px",textTransform:"uppercase"},children:[(0,re.jsx)(V.A,{style:{fontSize:"11px",color:"#65387a"}}),"Schedule Details"]}),(0,re.jsx)(l.A,{sx:{flex:1,height:"1px",background:"linear-gradient(90deg, #eef2f6 0%, transparent 100%)"}})]})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sx:{pt:"0px !important"},children:(0,re.jsxs)(u.Ay,{container:!0,spacing:1.5,sx:{mt:.5},children:[(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(H.$,{dateAdapter:W.R,children:(0,re.jsx)(F.l,{label:"Pickup Date",format:"DD-MM-YYYY",onChange:e=>{let t=U()().diff(U()("".concat(U()(e).format("YYYY-MM-DD"))),"d");if(qe(""),t<=0){Se(e);let t=[];Ce.map((a=>{U()().diff(U()("".concat(U()(e).format("MM-DD-YYYY")," ").concat(U()(a).format("HH:mm:ss"))),"m")<=0&&t.push(a)}))}else Fe("choose Upcoming Date"),Da("choose Upcoming Date","warning"),Se(NaN)},value:U()(ye),sx:{width:"100%","& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px"}},slotProps:{textField:{size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},InputProps:{startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(V.A,{style:{color:"#94a3b8",fontSize:"13px"}})})},sx:{"& .MuiOutlinedInput-root":{borderRadius:"12px",height:"38px",paddingLeft:"10px"}}}},disablePast:!0})})}),(0,re.jsx)(u.Ay,{item:!0,xs:12,sm:6,children:(0,re.jsx)(c.A,{size:"small",fullWidth:!0,options:_a||[],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=U()(t.time,"HH:mm").format("hh:mm A");qe(e);const a=U()("".concat(ye," ").concat(e),"MM-DD-YYYY hh:mm A").format("YYYY-MM-DD hh:mm A");Ca(a)}else qe(null),Ca(null)},getOptionLabel:e=>e?"".concat(e.name," (").concat(U()(e.time,"HH:mm").format("hh:mm A"),")"):"",renderInput:e=>(0,re.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,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(G.A,{style:{color:"#94a3b8",fontSize:"13px",marginRight:"6px",marginLeft:"2px",flexShrink:0}}),e.InputProps.startAdornment]})})}))})})]})})]})]})]}),(0,re.jsx)(u.Ay,{item:!0,xs:12,lg:4.5,sx:{position:{lg:"sticky"},top:{lg:"24px"},height:"fit-content"},children:(0,re.jsxs)(A.A,{spacing:2,children:[(0,re.jsxs)(i.A,{className:"orders-card",sx:{p:1.5,display:"flex",flexDirection:"column"},children:[(0,re.jsxs)(r.A,{sx:{fontWeight:700,mb:1.25,display:"flex",alignItems:"center",gap:.75,color:"#1e293b",fontSize:"14px",letterSpacing:"-0.01em"},children:[(0,re.jsx)(Q.A,{sx:{color:"#662582",fontSize:16}}),"Live Route Preview"]}),(0,re.jsx)("div",{className:"map-preview-wrapper",children:(0,re.jsx)(me,{startPoint:Ge,endPoint:Ze,appLocaLat:Ut,appLocaLng:Kt})})]}),(0,re.jsxs)(i.A,{className:"orders-card delivery-prefs-card",sx:{p:1.5},children:[(0,re.jsxs)(l.A,{className:"delivery-prefs-header",children:[(0,re.jsx)(r.A,{className:"delivery-prefs-title",children:"Delivery Preferences"}),(0,re.jsx)(r.A,{className:"delivery-prefs-sub",children:"Customer notifications & dispatch instructions"})]}),(0,re.jsxs)(l.A,{className:"delivery-prefs-row",children:[(0,re.jsxs)(l.A,{className:"delivery-prefs-field",children:[(0,re.jsxs)("label",{className:"delivery-prefs-label",htmlFor:"dispatch-notes-input",children:[(0,re.jsx)(X.A,{style:{fontSize:11,color:"#65387a"}}),"Special Dispatch Notes"]}),(0,re.jsx)(d.A,{id:"dispatch-notes-input",size:"small",fullWidth:!0,placeholder:"Gate codes, call instructions, special cargo care\u2026",value:Ie,onChange:e=>Re(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,re.jsxs)(l.A,{className:"sms-toggle-tile ".concat(1===xa?"is-active":""),onClick:()=>ga(1===xa?0:1),role:"button",tabIndex:0,children:[(0,re.jsxs)(l.A,{className:"sms-toggle-left",children:[(0,re.jsx)(l.A,{className:"sms-toggle-icon",children:(0,re.jsx)(Z.A,{style:{fontSize:13}})}),(0,re.jsxs)(l.A,{sx:{minWidth:0},children:[(0,re.jsx)(r.A,{className:"sms-toggle-title",children:"SMS Updates"}),(0,re.jsx)(r.A,{className:"sms-toggle-sub",children:"Auto-notify customer on dispatch & delivery"})]})]}),(0,re.jsx)(f.A,{size:"small",checked:1===xa,onChange:e=>{e.stopPropagation(),ga(e.target.checked?1:0)}})]})]})]}),(0,re.jsxs)(i.A,{className:"orders-card pricing-summary-card",children:[(0,re.jsxs)(l.A,{className:"pricing-header",children:[(0,re.jsx)(r.A,{className:"pricing-title",children:"Pricing & Dispatch"}),(0,re.jsx)(r.A,{className:"pricing-subtitle",children:"Live cost estimate"})]}),(0,re.jsxs)("div",{className:"price-metric-item",children:[(0,re.jsxs)("div",{className:"price-metric-label",children:[(0,re.jsx)("span",{className:"price-metric-icon icon-distance",children:(0,re.jsx)(w.$Fg,{})}),(0,re.jsx)("span",{children:"Delivery Distance"})]}),(0,re.jsx)("div",{className:"price-metric-value ".concat($e?"highlight":""),children:$e?"".concat(et," km"):"\u2014"})]}),(0,re.jsxs)("div",{className:"price-metric-item",children:[(0,re.jsxs)("div",{className:"price-metric-label",children:[(0,re.jsx)("span",{className:"price-metric-icon icon-base",children:(0,re.jsx)(w.MxO,{})}),(0,re.jsxs)("span",{children:["Base Fare",(0,re.jsxs)("span",{className:"price-metric-sub",children:[" \xb7 ",lt," km"]})]})]}),(0,re.jsx)("div",{className:"price-metric-value",children:at?"\u20b9".concat(at.toFixed(2)):"\u20b90.00"})]}),(0,re.jsxs)("div",{className:"price-metric-item",children:[(0,re.jsxs)("div",{className:"price-metric-label",children:[(0,re.jsx)("span",{className:"price-metric-icon icon-rate",children:(0,re.jsx)(w.YYR,{})}),(0,re.jsx)("span",{children:"Rate per km"})]}),(0,re.jsxs)("div",{className:"price-metric-value",children:[nt?"\u20b9".concat(nt.toFixed(2)):"\u20b90.00",(0,re.jsx)("span",{className:"price-metric-unit",children:"/km"})]})]}),$e&&(0,re.jsxs)("div",{className:"total-charge-badge",children:[(0,re.jsxs)("div",{className:"total-charge-left",children:[(0,re.jsx)(w.wTh,{className:"total-charge-icon"}),(0,re.jsx)("div",{className:"total-charge-label",children:"Total Delivery Charge"})]}),(0,re.jsxs)("div",{className:"total-charge-val",children:["\u20b9",rt.toFixed(2)]})]}),(0,re.jsx)(l.A,{sx:{mt:1.5},children:(0,re.jsx)(ie.A,{children:(0,re.jsx)(p.A,{fullWidth:!0,className:"gradient-btn-create",disabled:!$e||!Ue||!Na,startIcon:!Le&&(0,re.jsx)(w.Cer,{style:{fontSize:11}}),onClick:()=>{Me(!0),Ye(!0),(async()=>{let e={};if(e={orders:{applocationid:Oe.applolcationid,cancellled:"",categoryid:+Oe.categoryid,configid:9,customerid:0==Jt&&+Et.customerid||0,deliveryaddress:Dt.address||"",deliverycharge:+rt.toFixed(2)||0,deliverycity:Dt.city||"",deliverycontactno:Dt.contactno||"",deliverycustomer:Dt.firstname||"",deliveryid:0==ta&&+Dt.customerid||0,deliverylandmark:Dt.landmark||"",deliverylat:Dt.latitude.toString(),deliverylocation:Dt.suburb||"",deliverylocationid:Dt.deliverylocationid||0,deliverylong:Dt.longitude.toString(),deliverytime:"".concat(U()(ye).format("YYYY-MM-DD")," ").concat(U()(Ue.$d).format("HH:mm:ss")),deliverytype:"B",delivered:"",itemcount:1,kms:et.toString()||0,locationid:+jt,moduleid:+Oe.moduleid,orderamount:+rt.toFixed(2)||0,ordercharges:0,orderdate:U()().format("YYYY-MM-DD HH:mm:ss"),ordernotes:Ie,orderstatus:"created",ordervalue:+rt.toFixed(2)||0,partnerid:Oe.partnerid,partneruserid:+$t,paymentstatus:1,paymenttype:42,pickupaddress:Et.address||"",pickupcity:Et.city||"",pickupcontactno:Et.contactno||"",pickupcustomer:Et.firstname||"",pickuplandmark:Et.landmark||"",pickuplat:Et.latitude.toString()||"",pickuplocation:Et.suburb||"",pickuplocationid:Et.deliverylocationid||0,pickuplong:Et.longitude.toString()||"",smsdelivery:xa,subcategoryid:+ht,tenantid:Oe.tenantid,collectionamt:+Aa,quantity:+va,weight:gt,pickupSlot:Na},pickup:{address:Et.address||"",applocationid:Oe.applolcationid,city:Et.city||"",configid:1,contactno:Et.contactno||"",customertoken:"",customerid:0==Jt&&Et.customerid||0,devicetype:"",deviceid:"",dialcode:"+91",doorno:Et.doorno||"",email:Et.email||"",firstname:Et.firstname||"",landmark:Et.landmark||"",latitude:Et.latitude.toString()||"",longitude:Et.longitude.toString()||"",postcode:Et.postcode||"",primaryaddress:1,locationid:Et.deliverylocationid||0,profileimage:"",state:Et.state||"",suburb:Et.suburb||"",tenantid:Oe.tenantid},drop:{address:Dt.address||"",applocationid:Oe.applolcationid,city:Dt.city||"",configid:1,contactno:Dt.contactno||"",customertoken:"",customerid:0==ta&&Dt.customerid||0,devicetype:"",deviceid:"",locationid:Dt.deliverylocationid||0,dialcode:"+91",doorno:Dt.doorno||"",email:Dt.email||"",firstname:Dt.firstname||"",landmark:Dt.landmark||"",latitude:Dt.latitude.toString(),longitude:Dt.longitude.toString(),postcode:Dt.postcode||"",primaryaddress:1,profileimage:"",state:Dt.state||"",suburb:Dt.suburb||"",tenantid:Oe.tenantid}},console.log("createsubmitobj2",e),Et.firstname)if(Et.contactno)if(10!=Et.contactno.length)Da("Check Pickup Contact Number ","error",2e3);else if(Et.suburb)if(Et.city)if(Et.postcode)if(Et.landmark)if(Dt.firstname)if(Dt.contactno)if(10!==Dt.contactno.length)Da("Check Drop Contact Number ","error",2e3);else if(Dt.suburb)if(Dt.city)if(Dt.postcode)if(Dt.landmark)if(Ue)if(xt)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,q.M8)("Order Created Successfully",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:1e3}),He&&La(),t("/nearle/orders")):Da("Error in creating orders","warning"),Me(!1)}catch(a){Da(a.message,"warning"),console.log("createResErr",a)}else Da("Choose SubCategory ","warning",2e3);else Da("Choose deliverytime ","warning",2e3);else Da("Enter Drop Landmark ","warning",2e3);else Da("Enter Drop postcode ","warning",2e3);else Da("Enter Drop City ","warning",2e3);else Da("Enter Drop Suburb ","warning",2e3);else Da("Enter Drop Contact Number","warning",2e3);else Da("Enter Drop Contact Name ","warning",2e3);else Da("Enter Pickup Landmark ","warning",2e3);else Da("Enter Pickup Postcode ","warning",2e3);else Da("Enter Pickup City ","warning",2e3);else Da("Enter Pickup Location ","warning",2e3);else Da("Enter Pickup Contact Number ","warning",2e3);else Da("Enter Pickup Contact Name ","warning",2e3)})(),setTimeout((()=>{Me(!1),Ye(!1)}),2e3)},children:Le?(0,re.jsx)(v.A,{color:"inherit",size:16,thickness:5}):"Dispatch Delivery Order"})})})]})]})})]})]}),(0,re.jsxs)(O.A,{open:kt,onClose:()=>{_t(!1),Nt("")},fullWidth:!0,fullScreen:B,sx:{"& .MuiDialog-paper":{borderRadius:{xs:0,sm:"16px"},overflow:"hidden"}},children:[(0,re.jsx)(j.A,{sx:{background:"linear-gradient(135deg, #662582 0%, #9255AB 100%)",color:"white",py:2.5},children:(0,re.jsxs)(A.A,{spacing:1.5,children:[(0,re.jsx)(r.A,{variant:"h4",sx:{fontWeight:600,color:"white"},children:"Select Saved Address (".concat(1===Lt?"Pickup":"Drop",")")}),(0,re.jsx)(b.A,{sx:{width:"100%"},children:(0,re.jsx)(y.A,{autoFocus:!0,fullWidth:!0,id:"input-search-header",placeholder:"Search by name, contact, or address...",value:Pt,onChange:e=>Nt(e.target.value),sx:{bgcolor:"white",borderRadius:"10px","& .MuiOutlinedInput-input":{p:"10px 14px"}},startAdornment:(0,re.jsx)(m.A,{position:"start",children:(0,re.jsx)(K.A,{style:{fontSize:"small",color:"#64748b"}})}),endAdornment:(0,re.jsx)(h.A,{sx:{visibility:Pt?"visible":"hidden",p:.5},onClick:()=>{Nt("")},children:(0,re.jsx)(E.A,{style:{fontSize:"18px"}})}),autoComplete:"off"})})]})}),(0,re.jsx)(S.A,{}),(0,re.jsx)(k.A,{sx:{p:3,maxHeight:"600px",overflowY:"auto",bgcolor:"#fafbfc"},children:0==(null===Ct||void 0===Ct?void 0:Ct.length)?(0,re.jsx)(A.A,{spacing:2,direction:"row",alignItems:"center",justifyContent:"center",sx:{minHeight:300},children:(0,re.jsx)(C.A,{description:"No saved addresses found for this client"})}):(0,re.jsx)(l.A,{children:Ct&&Ct.map(((e,t)=>(0,re.jsx)(p.A,{className:"address-card-btn",onClick:()=>{_t(!1),Nt(""),1===Lt?(console.log("PickupClient",e),Ft(1),Xe({latitude:e.latitude,longitude:e.longitude}),zt(e),ra(e.contactno)):(console.log("DropClient",e),Wt(1),Qe({latitude:e.latitude,longitude:e.longitude}),Mt(e),da(e.contactno))},disabled:(null===Et||void 0===Et?void 0:Et.customerid)===e.customerid,children:(0,re.jsxs)("div",{style:{width:"100%",display:"flex",flexDirection:"column"},children:[(0,re.jsx)(r.A,{variant:"subtitle1",sx:{textAlign:"left",fontWeight:600,color:"#1e293b"},children:"".concat(e.firstname," (").concat(e.contactno,")")}),(0,re.jsx)(r.A,{variant:"body2",sx:{textAlign:"left",color:"#64748b",mt:.5,lineHeight:1.4},children:e.address})]})},t)))})}),(0,re.jsx)(S.A,{}),(0,re.jsx)(_.A,{sx:{p:2.5,bgcolor:"#fafbfc"},children:(0,re.jsx)(p.A,{color:"error",variant:"outlined",sx:{borderRadius:"8px",textTransform:"none",px:3,"&:hover":{bgcolor:"#ef4444",color:"white",borderColor:"#ef4444"}},onClick:()=>{_t(!1),Nt("")},children:"Cancel"})})]}),(0,re.jsxs)(O.A,{open:fe,onClose:()=>{ve(!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,re.jsxs)(j.A,{sx:{textAlign:"center",pb:1},children:[(0,re.jsx)($.A,{sx:{fontSize:70,color:a.palette.error.main,mb:1}}),(0,re.jsx)(r.A,{variant:"h3",sx:{color:a.palette.error.main,fontWeight:700},children:"Dispatch Blocked"})]}),(0,re.jsx)(k.A,{sx:{textAlign:"center",pb:2},children:(0,re.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,re.jsx)(_.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:()=>{ve(!1)},children:"Acknowledge & Close"})]})]})}}}]); |