1 line
45 KiB
JavaScript
1 line
45 KiB
JavaScript
(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[6752],{38215:function(e,t,n){"use strict";n.d(t,{Z:function(){return c}});var r=n(17592),i=n(85281),o=n(46417),s=(0,r.ZP)("div")((function(){return{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:2001,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255, 255, 255, 0.7)",padding:"20px",borderRadius:"10px"}})),a=(0,r.ZP)("div")((function(){return{position:"absolute",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center"}})),c=function(){return(0,o.jsxs)(s,{children:[(0,o.jsx)(i.Z,{color:"primary",size:80,thickness:6}),(0,o.jsx)(a,{children:(0,o.jsx)("img",{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAA+CAYAAABzwahEAAAPnUlEQVR4AdVae3AU9R3/7d4jdyGQQKAhECBAJBSmEAtFSQUjqPgAHGlhRm0lDkWY6Tg+O9qiErR26h8WR8ZWqTMN1ur4qMpDrTyjtDwDJloeCYiBvAgkaZ53l7vb3X4/v9vfZS/Zu9uFwLSfmb3d293f7u/z+z5/399K7CphdW5JrupgBZosZ0ialmu8pklSjUOTamRJbvvjqTUV7CpAYlcIj+SWZHQ55WJZlm7UNK2IXpRhpZ3GWJskSWXUZrPD4Sp77eSva9gVwIATXz35+SJNYWs1phWxAYDEpDKVaZv+fOrZUjaAGDDiK695rpgetpYOc82upw72sMycdJbz/SzmHeKl/ynRay31bbS1s7rjTczXGYj3ihrShnUDNQCXTXzlNS8UyExdbybhSdeNYwXz81nBzflE2pKms7oT51ntiSa276NKVn3wrNktNcGQelNpTUkNuwxcFvFV+S88rKnKy8ZzkOz84uvYvOJZ/PhyAE3Y/+HXbN+HFVwjjJAlR8lr1WueY9wt2MclEYfj8rnkj+nwRnHOLuGWhnbmpfuMKh/3Xn0Atm74IuY8OcGPFYk99kbVM98xm7BFnDyttHLyb3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EY9rSQqOTHAmP91TFdNGChJsyPTdlelztqcMu6i+XvNiIkBQRHlcPHGv6sUbHIKzo56J1AZBkvR5cSFhUVBR2CbD69bIpysvLecdoAHqINOytm0ijJt9J3r+TVBLHXfrGkwsiJRIMLF1i76MBEue7qE0XqTPadYiNnFen3j6Ad5HGYSDwTcslkQYGamVULLrLpH7y6dOnuY1TGctFFR0hcYfhvujinQ6eaNBgYc6sEHm+0WAKqatEWJkwYYI6depUjYhbtuWrBW775GGd1FEXFQA8FFsR8+HRMdFBKocgPrTvRkgnh4l70ijPxtwAzpLnCLpDvSztvFqQ9C8PuAPEINDeTdpgjADYjOFQhESn3s6hP+OKr9dfSUhCaiIcYjNIMur52f850f95/BfoYlARf1CQvwAAAABJRU5ErkJggg==",alt:"Logo",style:{width:"100%",height:"100%"}})})]})}},31655:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return Ze}});var r=n(1413),i=n(93433),o=n(74165),s=n(15861),a=n(29439),c=n(47313),l=n(56573),d=n(13997),u=n.n(d),p=n(48737),x=n(10658),h=n.n(x),f=n(58467),m=n(19860),g=n(24813),v=n(90842),Z=n(91554),b=n(57829),j=n(42832),S=n(61113),y=n(66212),w=n(9019),k=n(73428),Y=n(16783),C=n(41727),W=n(76088),z=n(69099),M=n(85281),A=n(51629),D=n(70501),P=n(66835),I=n(23477),N=n(24076),R=n(67478),H=n(57861),T=n(61689),L=n(47131),E=n(94469),O=n(33604),B=n(1550),F=n(49914),J=n(19536),V=n(96467),G=n(16429),q=n(83929),K=n(44758),U=n(4117),Q=n(29736),X=n(23208),_=n(45904),$=n(23195),ee=n(7308),te=n(89720),ne=n(43065),re=n(855),ie=n(3598),oe=n(15708),se=n(11829),ae=n(66736),ce=n(40765),le=n(95569),de=n(36528),ue=n(88960),pe=n(22539),xe=n(11577),he=n(38215),fe=n(46417),me=n(91635);h().extend(me);var ge={fontSize:11.5,fontWeight:700,color:"#475569",py:.75,px:1},ve={fontSize:12,py:.6,px:1},Ze=function(){var e,t=(0,f.s0)(),n=(0,m.Z)(),d=(0,g.Z)(n.breakpoints.down("md")),x=((0,c.useRef)(null),localStorage.getItem("userid")),me=localStorage.getItem("tenantid"),Ze=(0,c.useState)([]),be=(0,a.Z)(Ze,2),je=(be[0],be[1]),Se=(0,c.useState)([]),ye=(0,a.Z)(Se,2),we=ye[0],ke=ye[1],Ye=(0,c.useState)(!1),Ce=(0,a.Z)(Ye,2),We=Ce[0],ze=Ce[1],Me=(0,c.useState)(!1),Ae=(0,a.Z)(Me,2),De=Ae[0],Pe=Ae[1],Ie=(0,c.useState)(0),Ne=(0,a.Z)(Ie,2),Re=Ne[0],He=(Ne[1],(0,c.useState)(0)),Te=(0,a.Z)(He,2),Le=Te[0],Ee=Te[1],Oe=(0,c.useState)(null),Be=(0,a.Z)(Oe,2),Fe=Be[0],Je=Be[1],Ve=(0,c.useState)(0),Ge=(0,a.Z)(Ve,2),qe=Ge[0],Ke=Ge[1],Ue=(0,c.useState)(0),Qe=(0,a.Z)(Ue,2),Xe=Qe[0],_e=Qe[1],$e=(0,c.useState)(0),et=(0,a.Z)($e,2),tt=et[0],nt=et[1],rt=(0,c.useState)(null),it=(0,a.Z)(rt,2),ot=it[0],st=it[1],at=(0,c.useState)([]),ct=(0,a.Z)(at,2),lt=ct[0],dt=ct[1],ut=(0,c.useState)([]),pt=(0,a.Z)(ut,2),xt=pt[0],ht=pt[1],ft=(0,c.useState)(!1),mt=(0,a.Z)(ft,2),gt=mt[0],vt=mt[1],Zt=(0,c.useState)(""),bt=(0,a.Z)(Zt,2),jt=bt[0],St=bt[1],yt=(0,c.useState)(h()().format("MM-DD-YYYY")),wt=(0,a.Z)(yt,2),kt=wt[0],Yt=wt[1],Ct=(0,c.useState)(""),Wt=(0,a.Z)(Ct,2),zt=Wt[0],Mt=Wt[1],At=(0,c.useState)(null),Dt=(0,a.Z)(At,2),Pt=Dt[0],It=Dt[1],Nt=(0,c.useState)(null),Rt=(0,a.Z)(Nt,2),Ht=Rt[0],Tt=Rt[1],Lt=(0,c.useState)(""),Et=(0,a.Z)(Lt,2),Ot=Et[0],Bt=Et[1],Ft=(0,c.useState)(),Jt=(0,a.Z)(Ft,2),Vt=Jt[0],Gt=Jt[1],qt=(0,c.useState)(0),Kt=(0,a.Z)(qt,2),Ut=Kt[0],Qt=Kt[1],Xt=(0,c.useState)(0),_t=(0,a.Z)(Xt,2),$t=_t[0],en=_t[1],tn=(0,c.useState)(0),nn=(0,a.Z)(tn,2),rn=nn[0],on=nn[1],sn=(0,c.useState)(0),an=(0,a.Z)(sn,2),cn=an[0],ln=an[1],dn=(0,c.useState)(null),un=(0,a.Z)(dn,2),pn=un[0],xn=un[1],hn=(0,c.useState)([]),fn=(0,a.Z)(hn,2),mn=fn[0],gn=fn[1],vn=(0,c.useState)(""),Zn=(0,a.Z)(vn,2),bn=Zn[0],jn=Zn[1],Sn=(0,c.useState)(!1),yn=(0,a.Z)(Sn,2),wn=yn[0],kn=yn[1],Yn=(0,c.useRef)({}),Cn=function(e,t,n){(0,v.yv)(e,{variant:t,anchorOrigin:{vertical:"top",horizontal:"right"},autoHideDuration:n||1500})},Wn=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3,r="".concat(t,"-").concat(e);Yn.current[r]||(Cn(e,t,n),Yn.current[r]=!0,setTimeout((function(){return delete Yn.current[r]}),3e3))};(0,c.useEffect)((function(){Ee(0),Je(null),dt([]),gn([]),xn(null),jn(""),It(null),Tt(null),Mt("")}),[Re]);var zn=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(){var t;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ze(!0),e.prev=1,e.next=4,l.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(x));case 4:t=e.sent,je(t.data.details||[]),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),Wn(e.t0.message,"error",5e3);case 11:return e.prev=11,ze(!1),e.finish(11);case 14:case"end":return e.stop()}}),e,null,[[1,8,11,14]])})));return function(){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){zn()}),[]);var Mn=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(t){var n,r;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,l.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantpricing/?tenantid=").concat(t));case 3:n=e.sent,r=n.data.details||{},Ke(r.baseprice||0),_e(r.priceperkm||0),nt(r.minkm||0),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),console.log("fetchTenantPricing",e.t0);case 13:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(t){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){me&&Mn(me)}),[]);var An=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(t){var n,r;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,l.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/tenants/gettenantlocations/?tenantid=").concat(t));case 3:n=e.sent,1===(r=n.data.details||[]).length?(ke(r),st(r[0]),Ee(r[0].locationid),Je(r[0]),It(r[0].slots)):ke(r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.log("gettenantlocations",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(t){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){me&&An(me)}),[]);var Dn=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(){var t,n;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=""===jt?"".concat("https://jupiter.nearle.app/live/api/v1","/customers/gettenantcustomers/?tenantid=").concat(me,"&pageno=1&pagesize=30"):"".concat("https://jupiter.nearle.app/live/api/v1","/customers/search/?tenantid=").concat(me,"&keyword=").concat(jt),e.next=4,l.Z.get(t);case 4:(n=e.sent).data.status&&ht(n.data.details||[]),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),Cn("server error","warning");case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){if(me){var e=setTimeout((function(){(""===jt||jt.length>2)&&Dn()}),250);return function(){return clearTimeout(e)}}}),[jt,me]),(0,c.useEffect)((function(){var e=0,t=0,n=0,r=0;lt.forEach((function(i){e+=Number(i.distance)||0,t+=Number(i.totalcharge)||0,n+=Number(i.quantity)||0,r+=Number(i.collectionamt)||0})),Qt(e),en(t),on(n),ln(r)}),[lt]);var Pn=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(t){var n,r,i,s,a,c,l,d,u,p,x,h,f,m;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!==typeof window&&null!==(n=window.google)&&void 0!==n&&null!==(r=n.maps)&&void 0!==r&&r.DistanceMatrixService){e.next=2;break}throw new Error("Google Maps not loaded");case 2:if(i=new window.google.maps.DistanceMatrixService,s=function(e,t){return new Promise((function(n,r){try{if(!e||!t)return r(new Error("Origin or destination data missing."));i.getDistanceMatrix({origins:[new window.google.maps.LatLng(e.latitude,e.longitude)],destinations:[new window.google.maps.LatLng(t.latitude,t.longitude)],travelMode:"DRIVING",unitSystem:window.google.maps.UnitSystem.METRIC},(function(e,t){"OK"===t?n(e):r(new Error("Google API error: ".concat(t)))}))}catch(o){r(new Error("Unexpected error inside DistanceMatrixService: ".concat(o.message)))}}))},e.prev=4,t&&"object"===typeof t){e.next=7;break}throw new Error("Invalid customer data.");case 7:if(ot&&"object"===typeof ot){e.next=9;break}throw new Error("Origin (pickCust) data missing or invalid.");case 9:return e.next=11,s(ot,t);case 11:if(p=e.sent,null!=(x=null===p||void 0===p||null===(a=p.rows)||void 0===a||null===(c=a[0])||void 0===c||null===(l=c.elements)||void 0===l||null===(d=l[0])||void 0===d||null===(u=d.distance)||void 0===u?void 0:u.value)){e.next=15;break}throw new Error("Malformed Distance Matrix response: missing distance value.");case 15:return h=x/1e3,f=Math.round(h),m=f<tt?qe:(f-tt)*Xe+qe,e.abrupt("return",{roundedDistance:f,totalcharge:m});case 21:throw e.prev=21,e.t0=e.catch(4),e.t0.message.includes("Google API")?Wn("Invalid coordinates or Google API error.","error",3e3):e.t0.message.includes("Malformed")?Wn("Google Distance Matrix returned invalid data.","error",3e3):Wn("Unexpected error during distance calculation.","error",3e3),e.t0;case 25:case"end":return e.stop()}}),e,null,[[4,21]])})));return function(t){return e.apply(this,arguments)}}(),In=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(t,n){var s,a,c;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(ze(!0),e.prev=1,!t.target.checked){e.next=11;break}return e.next=5,Pn(n);case 5:s=e.sent,a=s.roundedDistance,c=s.totalcharge,dt((function(e){return[].concat((0,i.Z)(e),[(0,r.Z)((0,r.Z)({},n),{},{distance:a,totalcharge:c})])})),e.next=12;break;case 11:dt((function(e){return e.filter((function(e){return e.customerid!==n.customerid}))}));case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(1),console.error("Failed to calculate distance:",e.t0);case 17:return e.prev=17,ze(!1),e.finish(17);case 20:case"end":return e.stop()}}),e,null,[[1,14,17,20]])})));return function(t,n){return e.apply(this,arguments)}}(),Nn=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(t){var n,s,a,c;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!1,dt((function(e){return(n=e.some((function(e){return e.firstname===t.firstname})))?e.filter((function(e){return e.firstname!==t.firstname})):e})),!n){e.next=4;break}return e.abrupt("return");case 4:return ze(!0),e.prev=5,e.next=8,Pn(t);case 8:s=e.sent,a=s.roundedDistance,c=s.totalcharge,dt((function(e){return e.some((function(e){return e.firstname===t.firstname}))?e:[].concat((0,i.Z)(e),[(0,r.Z)((0,r.Z)({},t),{},{distance:a,totalcharge:c})])})),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(5),console.error("Failed to calculate distance:",e.t0);case 17:return e.prev=17,ze(!1),e.finish(17);case 20:case"end":return e.stop()}}),e,null,[[5,14,17,20]])})));return function(t){return e.apply(this,arguments)}}(),Rn=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(){var t,n;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,l.Z.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getapplocationconfig/?applocationid=").concat(Re));case 3:(t=e.sent).data.status&&(n=t.data.details.applocationadmins.map((function(e){return e.userfcmtokem})),Gt(n)),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.log(e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){Re&&Rn()}),[Re]);var Hn=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(){return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,l.Z.post("".concat("https://jupiter.nearle.app/live/api/v1","/utils/sendnotifications"),{priority:"high",registration_ids:Vt,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"}});case 3:"Success"===e.sent.data.message&&Cn("Notification sent Successfully","success",1e3),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),Cn(e.t0.message,"error",1e3);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}(),Tn=function(e){return null===e||void 0===e?void 0:e.toString().trim().toLowerCase().replace(/\s+/g,"")},Ln={"pickupdate(yyyy-mmm-dd)":"date","sendername*":"locationname","senderphone*":"locationcontact","senderaddress*":"locationaddress","receivername*":"firstname",receiverphone:"contactno","receiveralternatephone*":"altcontactno",receiverfulladdress:"address",receiverlatitude:"latitude",receiverlongitude:"longitude","itemdescription*":"description",Quantity:"quantity"," Collect Cash":"collectionamt"},En=function(){if(Ht){var e=h()(Ht,["YYYY-MM-DD hh:mm A","YYYY-MM-DD HH:mm:ss"]);if(e.isValid())return e.format("YYYY-MM-DD HH:mm:ss")}if(kt&&zt){var t=h()("".concat(h()(kt).format("YYYY-MM-DD")," ").concat(zt),["YYYY-MM-DD hh:mm A","YYYY-MM-DD HH:mm:ss"]);if(t.isValid())return t.format("YYYY-MM-DD HH:mm:ss")}return h()().format("YYYY-MM-DD HH:mm:ss")},On=function(){var e=(0,s.Z)((0,o.Z)().mark((function e(){var n,r,i,s,a,c;return(0,o.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(me){e.next=3;break}return Cn("Client not found. Please re-login.","warning"),e.abrupt("return");case 3:if(ot){e.next=6;break}return Cn("Pickup location required","warning"),e.abrupt("return");case 6:if(Ht){e.next=9;break}return Cn("Select a pickup slot","warning"),e.abrupt("return");case 9:if(lt.length){e.next=12;break}return Cn("Add at least one drop customer","warning"),e.abrupt("return");case 12:return n=En(),r=lt.map((function(e){var t,r,i,o;return{applocationid:ot.applocationid,configid:9,partnerid:ot.partnerid,partneruserid:+x,paymentstatus:1,paymenttype:42,pickupaddress:ot.address||"",pickupcity:ot.city||"",pickupcontactno:ot.contactno||"",pickupcustomer:ot.locationname||"",pickuplandmark:ot.landmark||"",pickuplat:ot.latitude,pickuplocation:ot.suburb||"",pickuplocationid:ot.locationid||0,pickuplong:ot.longitude,tenantid:ot.tenantid,customerid:+(null===e||void 0===e?void 0:e.customerid),deliveryaddress:e.address||"",deliverycharge:+e.totalcharge||0,deliverycity:e.city||"",deliverycontactno:(null===(t=e.contactno)||void 0===t?void 0:t.toString())||"",deliverycustomer:e.firstname||"",deliveryid:+e.customerid,deliverylandmark:e.landmark||"",deliverylat:(null===(r=e.latitude)||void 0===r?void 0:r.toString())||"",deliverylocation:e.suburb||"",deliverylocationid:e.deliverylocationid||0,deliverylong:(null===(i=e.longitude)||void 0===i?void 0:i.toString())||"",deliverytime:n,deliverytype:"B",itemcount:1,quantity:e.quantity,collectionamt:e.collectionamt,kms:(null===(o=e.distance)||void 0===o?void 0:o.toString())||"0",locationid:+ot.locationid,moduleid:+ot.moduleid,orderamount:+e.totalcharge||0,ordercharges:0,orderdate:h()().format("YYYY-MM-DD HH:mm:ss"),ordernotes:Ot,orderstatus:"created",ordervalue:+e.totalcharge||0,pickupSlot:Ht}})),ze(!0),Pe(!0),e.prev=16,e.next=19,l.Z.post("".concat("https://jupiter.nearle.app/live/api/v1","/orders/createorders"),r);case 19:(i=e.sent).data.status?(Cn("Orders Created Successfully","success",2e3),Vt&&Hn(),t("/nearle/orders")):Cn((null===i||void 0===i||null===(s=i.data)||void 0===s?void 0:s.message)||"Order creation failed. Please try again.","warning",3e3),e.next=27;break;case 23:e.prev=23,e.t0=e.catch(16),c=e.t0.response?(null===(a=e.t0.response.data)||void 0===a?void 0:a.message)||"Server error (".concat(e.t0.response.status,")"):e.t0.request?"Network error. Check your internet connection.":"Something went wrong.",Cn(c,"error",3e3);case 27:return e.prev=27,ze(!1),Pe(!1),e.finish(27);case 31:case"end":return e.stop()}}),e,null,[[16,23,27,31]])})));return function(){return e.apply(this,arguments)}}(),Bn=!!Le&&!!Ht&<.length>0,Fn=!!Le,Jn=lt.length>0?"drops":mn.length>0?"preview":"empty";return(0,fe.jsxs)(fe.Fragment,{children:[We&&(0,fe.jsx)(xe.Z,{}),(0,fe.jsx)(Z.Z,{sx:{color:"#fff",zIndex:function(e){return e.zIndex.drawer+1}},open:De,children:(0,fe.jsx)(he.Z,{color:"inherit"})}),(0,fe.jsxs)(b.Z,{className:"orders-workspace-bg",sx:{height:{xs:"auto",md:"calc(100vh - 64px)"},minHeight:{xs:"calc(100vh - 64px)",md:0},display:"flex",flexDirection:"column",overflow:{xs:"visible",md:"hidden"},p:{xs:.75,sm:1.25},gap:1},children:[(0,fe.jsxs)(j.Z,{direction:"row",alignItems:"center",gap:1,flexWrap:"wrap",sx:{flexShrink:0,px:.5},children:[(0,fe.jsx)(S.Z,{sx:{fontWeight:700,fontSize:{xs:16,sm:17},color:"#1e293b",lineHeight:1.2},children:"Create Multiple Orders"}),(0,fe.jsx)(y.Z,{size:"small",label:"".concat(lt.length," drop").concat(1===lt.length?"":"s"),sx:{height:20,fontSize:10.5,fontWeight:700,bgcolor:lt.length?"rgba(24,144,255,0.10)":"#f1f5f9",color:lt.length?"#1890ff":"#94a3b8",border:"1px solid ".concat(lt.length?"rgba(24,144,255,0.25)":"#e2e8f0")}}),(0,fe.jsx)(b.Z,{sx:{flex:1}}),(0,fe.jsx)(S.Z,{sx:{fontSize:11,color:"#94a3b8",display:{xs:"none",md:"block"}},children:"Bulk-create deliveries from CSV/Excel or saved customers."})]}),(0,fe.jsxs)(w.ZP,{container:!0,spacing:1.25,sx:{flex:1,minHeight:0,overflow:{xs:"visible",md:"hidden"}},children:[(0,fe.jsxs)(w.ZP,{item:!0,xs:12,md:6,sx:{height:{xs:"auto",md:"100%"},minHeight:0,display:"flex",flexDirection:"column",gap:{xs:1.25,md:2.25},overflowY:{xs:"visible",md:"auto"},pr:{xs:0,md:.75}},children:[(0,fe.jsxs)(k.Z,{className:"orders-card",sx:{p:2,flexShrink:0},children:[(0,fe.jsx)(b.Z,{className:"section-title-bar section-title-bar--accent",sx:{mb:1.5},children:(0,fe.jsx)(S.Z,{sx:{fontWeight:700,color:"#1e293b",fontSize:13.5,letterSpacing:"-0.01em"},children:"Schedule & Pickup"})}),(0,fe.jsxs)(w.ZP,{container:!0,spacing:1.75,children:[(0,fe.jsx)(w.ZP,{item:!0,xs:12,children:1===(null===we||void 0===we?void 0:we.length)?(0,fe.jsx)(Y.Z,{size:"small",variant:"outlined",fullWidth:!0,label:"Business Location",value:(null===(e=we[0])||void 0===e?void 0:e.locationname)||"",InputProps:{readOnly:!0,style:{color:n.palette.primary.main},startAdornment:(0,fe.jsx)(C.Z,{position:"start",children:(0,fe.jsx)(ee.Z,{color:"primary",style:{fontSize:"16px"}})})},sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",height:"36px",alignItems:"center"},"& .MuiOutlinedInput-input":{padding:"0 14px !important"}}}):(0,fe.jsx)(W.Z,{size:"small",fullWidth:!0,options:we||[],getOptionLabel:function(e){return e?"".concat(e.locationname," (").concat(e.suburb||e.locationsuburb||"",")"):""},value:Fe,onChange:function(e,t,n){"clear"!==n&&t?(Ee(t.locationid||0),Je(t),st(t),It((null===t||void 0===t?void 0:t.slots)||null)):(Ee(0),Je(null),st(null),It(null))},renderInput:function(e){return(0,fe.jsx)(Y.Z,(0,r.Z)((0,r.Z)({},e),{},{label:"Select Business Location",placeholder:"Select Business Location",InputLabelProps:{shrink:!0}}))},sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",height:"36px",alignItems:"center",padding:"0 9px !important"},"& .MuiAutocomplete-input":{padding:"0 !important"}}})}),(0,fe.jsx)(w.ZP,{item:!0,xs:12,sm:6,children:(0,fe.jsx)(X._,{dateAdapter:_.y,children:(0,fe.jsx)(Q.M,{label:"Pickup Date",format:"DD-MM-YYYY",value:kt?h()(kt):null,onChange:function(e){e&&h()(e).isValid()?h()().diff(h()(h()(e).format("YYYY-MM-DD")),"d")<=0?(Yt(h()(e).format("MM-DD-YYYY")),Mt(""),Tt(null)):(Cn("Choose an upcoming date","warning"),Yt(h()().format("MM-DD-YYYY"))):Yt(h()().format("MM-DD-YYYY"))},disablePast:!0,slotProps:{textField:{size:"small",fullWidth:!0,InputLabelProps:{shrink:!0},InputProps:{startAdornment:(0,fe.jsx)(C.Z,{position:"start",children:(0,fe.jsx)(te.Z,{style:{color:"#94a3b8",fontSize:"13px"}})})},sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",height:"36px"}}}}})})}),(0,fe.jsx)(w.ZP,{item:!0,xs:12,sm:6,children:(0,fe.jsx)(W.Z,{size:"small",fullWidth:!0,options:Pt||[],open:wn,onOpen:function(){Le?kn(!0):Wn("Please select a Business Location first.","warning",3e3)},onClose:function(){return kn(!1)},sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",height:"36px",alignItems:"center",padding:"0 9px !important"},"& .MuiAutocomplete-input":{padding:"0 !important"}},onChange:function(e,t,n){if("clear"===n||!t)return Mt(null),void Tt(null);if(t.time){var r=h()(t.time,"HH:mm").format("hh:mm A");Mt(r);var i=h()("".concat(kt," ").concat(r),"MM-DD-YYYY hh:mm A").format("YYYY-MM-DD hh:mm A");Tt(i)}else Wn("This slot has no time configured.","warning",3e3)},getOptionLabel:function(e){return e?"".concat(e.name," (").concat(h()(e.time,"HH:mm").format("hh:mm A"),")"):""},renderInput:function(e){return(0,fe.jsx)(Y.Z,(0,r.Z)((0,r.Z)({},e),{},{label:"Pickup Slot",placeholder:"Select Pickup Slot",fullWidth:!0,InputLabelProps:{shrink:!0},InputProps:(0,r.Z)((0,r.Z)({},e.InputProps),{},{startAdornment:(0,fe.jsx)(C.Z,{position:"start",children:(0,fe.jsx)(ne.Z,{style:{color:"#94a3b8",fontSize:"13px"}})})})}))}})}),(0,fe.jsx)(w.ZP,{item:!0,xs:12,children:ot?(0,fe.jsxs)(j.Z,{direction:"row",spacing:1.25,alignItems:"center",sx:{border:"1px solid #eef2f6",borderLeft:"3px solid #1890ff",borderRadius:"10px",px:1.25,py:.75,bgcolor:"#fbfcff"},children:[(0,fe.jsx)(b.Z,{sx:{width:28,height:28,borderRadius:"8px",background:"linear-gradient(135deg,#1890ff,#096dd9)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,fontSize:12,boxShadow:"0 4px 10px rgba(24,144,255,0.30)"},children:(0,fe.jsx)(ue.GUT,{})}),(0,fe.jsxs)(b.Z,{sx:{minWidth:0,flex:1},children:[(0,fe.jsx)(S.Z,{sx:{fontSize:12.5,fontWeight:700,color:"#1e293b",lineHeight:1.2},noWrap:!0,children:ot.locationname||"\u2014"}),(0,fe.jsx)(S.Z,{sx:{fontSize:11,color:"#64748b",lineHeight:1.3},noWrap:!0,children:ot.address||"\u2014"})]})]}):(0,fe.jsx)(S.Z,{sx:{color:"#94a3b8",fontSize:12},children:"Pickup auto-fills once a Business Location is selected."})})]})]}),(0,fe.jsxs)(k.Z,{className:"orders-card delivery-prefs-card",sx:{p:2,flexShrink:0},children:[(0,fe.jsxs)(b.Z,{className:"delivery-prefs-header",sx:{mb:1},children:[(0,fe.jsx)(S.Z,{className:"delivery-prefs-title",children:"Order Notes"}),(0,fe.jsx)(S.Z,{className:"delivery-prefs-sub",children:"Applied to every order"})]}),(0,fe.jsx)(b.Z,{className:"delivery-prefs-row",children:(0,fe.jsxs)(b.Z,{className:"delivery-prefs-field",sx:{width:"100%"},children:[(0,fe.jsxs)("label",{className:"delivery-prefs-label",htmlFor:"bulk-dispatch-notes-input",children:[(0,fe.jsx)(re.Z,{style:{fontSize:11,color:"#65387a"}}),"Special Dispatch Notes"]}),(0,fe.jsx)(Y.Z,{id:"bulk-dispatch-notes-input",size:"small",fullWidth:!0,placeholder:"Gate codes, call instructions, special cargo care\u2026",value:Ot,onChange:function(e){return Bt(e.target.value)},sx:{"& .MuiOutlinedInput-root":{borderRadius:"10px",height:"36px",alignItems:"center",fontSize:"12px",background:"#ffffff"},"& .MuiOutlinedInput-input":{padding:"0 14px !important",fontSize:"12px"}}})]})})]}),(0,fe.jsxs)(k.Z,{className:"orders-card pricing-summary-card",sx:{flexShrink:0,p:"16px 18px !important"},children:[(0,fe.jsxs)(b.Z,{className:"pricing-header",sx:{mb:1.5,pb:1},children:[(0,fe.jsx)(S.Z,{className:"pricing-title",sx:{fontSize:"13px !important"},children:"Bulk Summary"}),(0,fe.jsx)(S.Z,{className:"pricing-subtitle",sx:{fontSize:"10px !important"},children:"Live totals"})]}),function(){var e=function(e){var t=e.icon,n=e.label,i=e.value,o=e.accent,s=e.active;return(0,fe.jsxs)(b.Z,{sx:(0,r.Z)({bgcolor:"#fff",border:"1px solid #eef2f6",borderRadius:"10px",px:1,py:.75,display:"flex",alignItems:"center",gap:.85,minWidth:0,transition:"border-color 0.2s, box-shadow 0.2s"},s&&{borderColor:"".concat(o,"55"),boxShadow:"0 2px 6px -2px ".concat(o,"33")}),children:[(0,fe.jsx)(b.Z,{sx:{width:26,height:26,borderRadius:"8px",bgcolor:"".concat(o,"18"),color:o,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,flexShrink:0},children:(0,fe.jsx)(t,{})}),(0,fe.jsxs)(b.Z,{sx:{minWidth:0,flex:1},children:[(0,fe.jsx)(S.Z,{sx:{fontSize:9.5,fontWeight:600,color:"#94a3b8",letterSpacing:.4,textTransform:"uppercase",lineHeight:1},children:n}),(0,fe.jsx)(S.Z,{sx:{fontSize:13.5,fontWeight:800,color:s?"#1e293b":"#94a3b8",lineHeight:1.2,mt:.25},noWrap:!0,children:i})]})]})};return(0,fe.jsxs)(w.ZP,{container:!0,spacing:1.25,children:[(0,fe.jsx)(w.ZP,{item:!0,xs:6,children:e({icon:de.tbd,label:"Distance",value:Ut?"".concat(Ut," km"):"\u2014",accent:"#1890ff",active:!!Ut})}),(0,fe.jsx)(w.ZP,{item:!0,xs:6,children:e({icon:de.nO,label:"Quantity",value:rn||0,accent:"#16a34a",active:!!rn})}),(0,fe.jsx)(w.ZP,{item:!0,xs:6,children:e({icon:de.l80,label:"Cash Collect",value:"\u20b9".concat(Number(cn).toFixed(2)),accent:"#d97706",active:!!cn})}),(0,fe.jsx)(w.ZP,{item:!0,xs:6,children:e({icon:de.Hzt,label:"Deliveries",value:lt.length,accent:"#65387a",active:lt.length>0})})]})}(),lt.length>0&&(0,fe.jsxs)("div",{className:"total-charge-badge",style:{marginTop:14,padding:"10px 14px"},children:[(0,fe.jsxs)("div",{className:"total-charge-left",children:[(0,fe.jsx)(de.$aT,{className:"total-charge-icon"}),(0,fe.jsx)("div",{className:"total-charge-label",children:"Total Charge"})]}),(0,fe.jsxs)("div",{className:"total-charge-val",style:{fontSize:17},children:["\u20b9",Number($t).toFixed(2)]})]}),(0,fe.jsx)(b.Z,{sx:{mt:1.75},children:(0,fe.jsx)(z.Z,{fullWidth:!0,className:"gradient-btn-create",disabled:!Bn||De,startIcon:!De&&(0,fe.jsx)(de.Y2X,{style:{fontSize:11}}),onClick:On,sx:{minHeight:"36px !important"},children:De?(0,fe.jsx)(M.Z,{color:"inherit",size:16,thickness:5}):"Dispatch ".concat(lt.length||""," ").concat(1===lt.length?"Order":"Orders").trim()})})]})]}),(0,fe.jsx)(w.ZP,{item:!0,xs:12,md:6,sx:{height:{xs:"auto",md:"100%"},minHeight:0,display:"flex",flexDirection:"column"},children:(0,fe.jsxs)(k.Z,{className:"orders-card",sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",p:1.25,maxHeight:{xs:"none",md:685}},children:[(0,fe.jsxs)(j.Z,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,sx:{mb:.75,flexShrink:0},children:[(0,fe.jsxs)(b.Z,{className:"section-title-bar",sx:{mb:0},children:[(0,fe.jsx)(S.Z,{sx:{fontWeight:700,color:"#1e293b",fontSize:13.5,letterSpacing:"-0.01em"},children:"drops"===Jn?"Drop List":"preview"===Jn?"File Preview":"Preview"}),(0,fe.jsx)(y.Z,{size:"small",label:"drops"===Jn?lt.length:"preview"===Jn?mn.length:0,sx:{height:20,fontSize:10.5,fontWeight:700,ml:1,bgcolor:"rgba(168,85,247,0.10)",color:"#65387a",border:"1px solid rgba(168,85,247,0.25)"}})]}),"drops"===Jn&&(0,fe.jsx)(y.Z,{size:"small",label:"\u20b9".concat(Number($t).toFixed(2)," total"),sx:{height:22,fontWeight:700,fontSize:11,bgcolor:"rgba(101,56,122,0.10)",color:"#65387a",border:"1px solid rgba(101,56,122,0.25)"}}),"preview"===Jn&&(0,fe.jsx)(y.Z,{size:"small",label:"Awaiting Continue",icon:(0,fe.jsx)(ie.Z,{style:{fontSize:11}}),sx:{height:22,fontWeight:700,fontSize:11,bgcolor:"rgba(245,158,11,0.12)",color:"#b45309",border:"1px solid rgba(245,158,11,0.30)","& .MuiChip-icon":{color:"#b45309"}}}),"empty"!==Jn&&function(){var e=function(e){var t;Fn?(xn(e),0===e?null===(t=document.getElementById("upload-file"))||void 0===t||t.click():1===e&&(vt(!0),St(""))):Wn("Please select a Business Location first.","warning",3e3)};return(0,fe.jsxs)(j.Z,{direction:"row",gap:.75,alignItems:"center",children:[(0,fe.jsx)(z.Z,{size:"small",variant:"outlined",onClick:function(){return e(0)},startIcon:(0,fe.jsx)(pe.YFT,{}),sx:{height:24,py:0,textTransform:"none",borderRadius:"6px",fontSize:10.5,fontWeight:600,borderColor:"#cbd5e1",color:"#475569","&:hover":{borderColor:"#1890ff",color:"#1890ff"}},children:"Excel / CSV"}),(0,fe.jsx)(z.Z,{size:"small",variant:"outlined",onClick:function(){return e(1)},startIcon:(0,fe.jsx)(de.I$,{}),sx:{height:24,py:0,textTransform:"none",borderRadius:"6px",fontSize:10.5,fontWeight:600,borderColor:"#cbd5e1",color:"#475569","&:hover":{borderColor:"#65387a",color:"#65387a"}},children:"Selection"})]})}()]}),bn&&(0,fe.jsxs)(j.Z,{direction:"row",gap:.75,alignItems:"center",sx:{mb:.75,color:"#64748b",flexShrink:0},children:[(0,fe.jsx)(oe.Z,{style:{fontSize:12}}),(0,fe.jsx)(S.Z,{sx:{fontSize:11.5},noWrap:!0,children:bn})]}),"preview"===Jn&&mn.length>=1&&(0,fe.jsxs)(b.Z,{sx:{mb:1,p:1.25,bgcolor:"rgba(245,158,11,0.06)",border:"1.5px solid rgba(245,158,11,0.25)",borderRadius:"10px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,animation:"blink 1.5s infinite","@keyframes blink":{"0%":{borderColor:"rgba(245,158,11,0.25)"},"50%":{borderColor:"rgba(245,158,11,0.6)"},"100%":{borderColor:"rgba(245,158,11,0.25)"}}},children:[(0,fe.jsxs)(b.Z,{sx:{textAlign:"left"},children:[(0,fe.jsx)(S.Z,{sx:{fontWeight:700,fontSize:12,color:"#b45309",lineHeight:1.2},children:"Process & Calculate Distances"}),(0,fe.jsx)(S.Z,{sx:{color:"#b45309",opacity:.8,fontSize:10.5,lineHeight:1.25},children:"Click continue to import spreadsheet rows and calculate drop charges."})]}),(0,fe.jsx)(z.Z,{variant:"contained",size:"small",color:"warning",onClick:function(){return mn.forEach((function(e){return Nn(e)}))},sx:{textTransform:"none",borderRadius:"8px",fontWeight:700,fontSize:11,height:28,px:1.5,bgcolor:"#d97706",boxShadow:"none","&:hover":{bgcolor:"#b45309",boxShadow:"none"}},children:"Continue"})]}),(0,fe.jsxs)(b.Z,{sx:{flex:1,minHeight:0,overflow:"auto"},children:["drops"===Jn&&(0,fe.jsx)(A.Z,{component:D.Z,sx:{borderRadius:"10px",border:"1px solid #eef2f6",boxShadow:"none"},children:(0,fe.jsxs)(P.Z,{size:"small",stickyHeader:!0,children:[(0,fe.jsx)(I.Z,{sx:{bgcolor:"#f8fafc"},children:(0,fe.jsxs)(N.Z,{children:[(0,fe.jsx)(R.Z,{sx:ge,children:"#"}),(0,fe.jsx)(R.Z,{sx:ge,children:"Customer"}),(0,fe.jsx)(R.Z,{sx:ge,children:"Address"}),(0,fe.jsx)(R.Z,{sx:ge,align:"center",children:"Qty"}),(0,fe.jsx)(R.Z,{sx:ge,align:"center",children:"Cash"}),(0,fe.jsx)(R.Z,{sx:ge,children:"Km"}),(0,fe.jsx)(R.Z,{sx:ge,align:"right",children:"Charge"}),(0,fe.jsx)(R.Z,{sx:ge,align:"center",children:" "})]})}),(0,fe.jsxs)(H.Z,{children:[lt.map((function(e,t){return(0,fe.jsxs)(N.Z,{hover:!0,children:[(0,fe.jsx)(R.Z,{sx:ve,children:t+1}),(0,fe.jsx)(R.Z,{sx:(0,r.Z)((0,r.Z)({},ve),{},{whiteSpace:"nowrap",color:"#1e293b",fontWeight:600}),children:e.firstname}),(0,fe.jsx)(R.Z,{sx:(0,r.Z)((0,r.Z)({},ve),{},{color:"#64748b",maxWidth:220}),children:(0,fe.jsx)(T.Z,{title:e.address||"",children:(0,fe.jsx)("span",{style:{display:"inline-block",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"middle"},children:e.address})})}),(0,fe.jsx)(R.Z,{align:"center",sx:ve,children:0===pn?e.quantity:(0,fe.jsx)(Y.Z,{size:"small",type:"number",value:e.quantity||"",onChange:function(t){return n=e.customerid,i=t.target.value,void dt((function(e){return e.map((function(e){return e.customerid===n?(0,r.Z)((0,r.Z)({},e),{},{quantity:Number(i)||0}):e}))}));var n,i},inputProps:{min:0},sx:{width:64,"& .MuiOutlinedInput-root":{borderRadius:"8px",height:30}}})}),(0,fe.jsx)(R.Z,{align:"center",sx:ve,children:0===pn?"\u20b9".concat(Number(e.collectionamt||0).toFixed(2)):(0,fe.jsx)(Y.Z,{size:"small",type:"number",value:e.collectionamt||"",placeholder:"0",onChange:function(t){var n,i,o=Number(t.target.value);n=e.customerid,i=o>0?o:0,dt((function(e){return e.map((function(e){return e.customerid===n?(0,r.Z)((0,r.Z)({},e),{},{collectionamt:Number(i)||0}):e}))}))},inputProps:{min:0},InputProps:{startAdornment:(0,fe.jsx)(C.Z,{position:"start",children:"\u20b9"})},sx:{width:90,"& .MuiOutlinedInput-root":{borderRadius:"8px",height:30}}})}),(0,fe.jsx)(R.Z,{sx:ve,children:e.distance}),(0,fe.jsxs)(R.Z,{align:"right",sx:(0,r.Z)((0,r.Z)({},ve),{},{fontWeight:700,color:"#1e293b"}),children:["\u20b9",Number((null===e||void 0===e?void 0:e.totalcharge)||0).toFixed(2)]}),(0,fe.jsx)(R.Z,{align:"center",sx:ve,children:(0,fe.jsx)(T.Z,{title:"Remove",children:(0,fe.jsx)(L.Z,{size:"small",onClick:function(){return Nn(e)},sx:{color:"#ef4444",p:.5},children:(0,fe.jsx)(se.Z,{style:{fontSize:13}})})})})]},e.customerid||e.firstname||t)})),(0,fe.jsxs)(N.Z,{sx:{bgcolor:"#fafbfc"},children:[(0,fe.jsx)(R.Z,{sx:(0,r.Z)((0,r.Z)({},ve),{},{fontWeight:800}),children:"Total"}),(0,fe.jsx)(R.Z,{colSpan:2,sx:ve}),(0,fe.jsx)(R.Z,{align:"center",sx:(0,r.Z)((0,r.Z)({},ve),{},{fontWeight:800}),children:rn}),(0,fe.jsxs)(R.Z,{align:"center",sx:(0,r.Z)((0,r.Z)({},ve),{},{fontWeight:800}),children:["\u20b9",Number(cn).toFixed(2)]}),(0,fe.jsx)(R.Z,{sx:(0,r.Z)((0,r.Z)({},ve),{},{fontWeight:800}),children:Ut}),(0,fe.jsxs)(R.Z,{align:"right",sx:(0,r.Z)((0,r.Z)({},ve),{},{fontWeight:800,color:"#65387a"}),children:["\u20b9",Number($t).toFixed(2)]}),(0,fe.jsx)(R.Z,{sx:ve})]})]})]})}),"preview"===Jn&&(0,fe.jsx)(A.Z,{component:D.Z,sx:{borderRadius:"10px",border:"1px solid #eef2f6",boxShadow:"none"},children:(0,fe.jsxs)(P.Z,{size:"small",stickyHeader:!0,children:[(0,fe.jsx)(I.Z,{sx:{bgcolor:"#f8fafc"},children:(0,fe.jsxs)(N.Z,{children:[(0,fe.jsx)(R.Z,{sx:ge,children:"#"}),(0,fe.jsx)(R.Z,{sx:ge,children:"Name"}),(0,fe.jsx)(R.Z,{sx:ge,children:"Contact"}),(0,fe.jsx)(R.Z,{sx:ge,children:"Address"}),(0,fe.jsx)(R.Z,{sx:ge,align:"center",children:"Qty"}),(0,fe.jsx)(R.Z,{sx:ge,align:"center",children:"Cash"})]})}),(0,fe.jsx)(H.Z,{children:mn.map((function(e,t){var n;return(0,fe.jsxs)(N.Z,{hover:!0,children:[(0,fe.jsx)(R.Z,{sx:ve,children:t+1}),(0,fe.jsx)(R.Z,{sx:(0,r.Z)((0,r.Z)({},ve),{},{whiteSpace:"nowrap",color:"#1e293b",fontWeight:600}),children:e.firstname||"\u2014"}),(0,fe.jsx)(R.Z,{sx:ve,children:e.contactno||"\u2014"}),(0,fe.jsx)(R.Z,{sx:(0,r.Z)((0,r.Z)({},ve),{},{color:"#64748b",maxWidth:240}),children:(0,fe.jsx)(T.Z,{title:e.address||"",children:(0,fe.jsx)("span",{style:{display:"inline-block",maxWidth:240,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"middle"},children:e.address||"\u2014"})})}),(0,fe.jsx)(R.Z,{align:"center",sx:ve,children:null!==(n=e.quantity)&&void 0!==n?n:"\u2014"}),(0,fe.jsx)(R.Z,{align:"center",sx:ve,children:null!=e.collectionamt?"\u20b9".concat(Number(e.collectionamt).toFixed(2)):"\u2014"})]},t)}))})]})}),"empty"===Jn&&function(){var e=function(e){var t;Fn?(xn(e),dt([]),gn([]),jn(""),0===e?null===(t=document.getElementById("upload-file"))||void 0===t||t.click():1===e&&(vt(!0),St(""))):Wn("Please select a Business Location first.","warning",3e3)},t=function(t){var n=t.value,r=t.icon,i=t.title,o=t.sub,s=t.accent;return(0,fe.jsxs)(b.Z,{role:"button",tabIndex:0,onClick:function(){return e(n)},onKeyDown:function(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e(n))},sx:{flex:1,minWidth:0,display:"flex",alignItems:"center",textAlign:"left",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",border:"1.5px solid #eef2f6",bgcolor:"#fff",opacity:Fn?1:.6,cursor:Fn?"pointer":"not-allowed",transition:"all 0.18s ease","&:hover":Fn?{borderColor:s,boxShadow:"0 4px 12px -4px ".concat(s,"40"),transform:"translateY(-1px)"}:void 0},children:[(0,fe.jsx)(b.Z,{sx:{width:32,height:32,borderRadius:"8px",background:"".concat(s,"15"),color:s,display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,flexShrink:0},children:(0,fe.jsx)(r,{})}),(0,fe.jsxs)(b.Z,{sx:{minWidth:0,flex:1},children:[(0,fe.jsx)(S.Z,{sx:{fontWeight:700,fontSize:13,color:"#1e293b",lineHeight:1.15},children:i}),(0,fe.jsx)(S.Z,{sx:{fontSize:11,color:"#94a3b8",lineHeight:1.25},noWrap:!0,children:o})]})]})};return(0,fe.jsxs)(j.Z,{alignItems:"center",justifyContent:"center",spacing:1.5,sx:{height:"100%",minHeight:240,bgcolor:"rgba(24,144,255,0.03)",border:"1px dashed rgba(24,144,255,0.25)",borderRadius:"12px",p:3,textAlign:"center"},children:[(0,fe.jsx)(b.Z,{sx:{width:56,height:56,borderRadius:"14px",bgcolor:"rgba(24,144,255,0.08)",color:"#1890ff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:28},children:(0,fe.jsx)(ae.Z,{})}),(0,fe.jsx)(S.Z,{sx:{fontWeight:700,color:"#1e293b",fontSize:14},children:"Choose a Drop Source to begin"}),(0,fe.jsx)(S.Z,{sx:{color:"#64748b",fontSize:12,maxWidth:360,mb:1},children:"Select a source below to import or pick your delivery customers."}),(0,fe.jsxs)(j.Z,{direction:{xs:"column",sm:"row"},gap:1.5,sx:{width:"100%",maxWidth:480,mt:1},children:[t({value:0,icon:pe.YFT,title:"Excel / CSV",sub:"Bulk upload a sheet",accent:"#1890ff"}),t({value:1,icon:de.I$,title:"Selection",sub:"Pick saved customers",accent:"#65387a"})]})]})}()]})]})})]})]}),(0,fe.jsx)("input",{accept:".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",id:"upload-file",type:"file",hidden:!0,onChange:function(e){var t=e.target.files[0];if(t){var n=t.name.replace(/\.[^/.]+$/,"");jn((function(e){return e?"".concat(e,", ").concat(n):n})),function(e){try{var t,n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!n)return void Cn("No file selected.","warning");var r=n.name.toLowerCase(),i=r.endsWith(".csv"),o=r.endsWith(".xls")||r.endsWith(".xlsx");if(!i&&!o)return void Cn("Invalid file type. Please upload a CSV or Excel file.","warning");var s=function(e,t){var n={};for(var r in Ln)n[Tn(r)]=Ln[r];var i=e.map((function(e){var t,r={};for(var i in e){var o=Tn(i),s=n[o]||o,a=e[i];"firstname"===s&&(a="string"===typeof(t=a)?t.replace(/^[\d.\s]+/,"").trim():t),r[s]=a}return r})),o=Object.keys(Ln).filter((function(e){return e.trim().endsWith("*")})).filter((function(e){return!t.includes(Tn(e))}));o.length>0&&Cn("Missing columns: ".concat(o.join(", ")),"warning",3e3),gn(i),Cn("File uploaded successfully","success",2e3),Cn("Press Continue to add as drop customers","info",2500)};if(i&&u().parse(n,{header:!0,dynamicTyping:!0,skipEmptyLines:!0,complete:function(e){var t;if(null===(t=e.data)||void 0===t||!t.length)return Cn("CSV file is empty or has no valid rows.","warning"),void gn([]);s(e.data,e.meta.fields.map(Tn))},error:function(e){return Cn("CSV parsing failed: ".concat(e.message),"warning")}}),o){var a=new FileReader;a.onload=function(e){try{var t=p.ij(e.target.result,{type:"binary"}),n=p.P6.sheet_to_json(t.Sheets[t.SheetNames[0]],{defval:""});if(null===n||void 0===n||!n.length)return Cn("Excel file is empty or invalid.","warning"),void gn([]);s(n,Object.keys(n[0]).map(Tn))}catch(r){Cn("Error reading Excel: ".concat(r.message),"warning")}},a.readAsBinaryString(n)}}catch(c){Cn("Unexpected error: ".concat(c.message),"warning")}}(e)}}}),(0,fe.jsxs)(E.Z,{open:gt,onClose:function(){return vt(!1)},fullWidth:!0,fullScreen:d,sx:{"& .MuiDialog-paper":{borderRadius:{xs:0,sm:"16px"},overflow:"hidden"}},children:[(0,fe.jsx)(O.Z,{sx:{bgcolor:n.palette.primary.main,color:"white",py:2.5},children:(0,fe.jsxs)(j.Z,{spacing:1.5,children:[(0,fe.jsx)(S.Z,{variant:"h4",sx:{fontWeight:600,color:"white"},children:"Select Drop Customers (".concat(lt.length||0,")")}),(0,fe.jsx)(B.Z,{sx:{width:"100%"},children:(0,fe.jsx)(F.Z,{autoFocus:!0,fullWidth:!0,id:"input-search-header",placeholder:"Search by name, contact, or address\u2026",value:jt,onChange:function(e){return St(e.target.value)},sx:{bgcolor:"white",borderRadius:"10px","& .MuiOutlinedInput-input":{p:"10px 14px"}},startAdornment:(0,fe.jsx)(C.Z,{position:"start",children:(0,fe.jsx)(ce.Z,{style:{fontSize:"small",color:"#64748b"}})}),endAdornment:(0,fe.jsx)(L.Z,{sx:{visibility:jt?"visible":"hidden",p:.5},onClick:function(){return St("")},children:(0,fe.jsx)($.Z,{style:{fontSize:"18px"}})}),autoComplete:"off"})})]})}),(0,fe.jsx)(J.Z,{}),(0,fe.jsx)(V.Z,{sx:{p:2.5,bgcolor:"#fafbfc",minHeight:400,maxHeight:{xs:"none",sm:600}},children:0===(null===xt||void 0===xt?void 0:xt.length)?(0,fe.jsx)(j.Z,{alignItems:"center",justifyContent:"center",sx:{minHeight:300},children:(0,fe.jsx)(le.Z,{description:"No saved customers found for this client"})}):(0,fe.jsx)(j.Z,{spacing:0,children:null===xt||void 0===xt?void 0:xt.map((function(e,t){var n=lt.some((function(t){return t.customerid===e.customerid}));return(0,fe.jsx)(G.Z,{children:(0,fe.jsx)(q.Z,{sx:{m:0,py:1,px:1.25,borderRadius:"10px","&:hover":{bgcolor:"rgba(24,144,255,0.04)"}},control:(0,fe.jsx)(K.Z,{checked:n,onChange:function(t){return In(t,e)}}),label:(0,fe.jsxs)(b.Z,{sx:{width:"100%"},children:[(0,fe.jsxs)(S.Z,{sx:{fontWeight:600,color:"#1e293b",fontSize:13.5},children:[e.firstname," (",e.contactno,")"]}),(0,fe.jsx)(S.Z,{sx:{color:"#64748b",fontSize:12,mt:.25},children:e.address})]})})},e.customerid||t)}))})}),(0,fe.jsx)(J.Z,{}),(0,fe.jsx)(U.Z,{sx:{p:2,bgcolor:"#fafbfc"},children:(0,fe.jsx)(z.Z,{variant:"outlined",color:0===lt.length?"error":"primary",onClick:function(){return vt(!1)},sx:{borderRadius:"10px",textTransform:"none",fontWeight:600,px:3},children:0===lt.length?"Close":"Continue"})})]})]})}},20067:function(){}}]); |