1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4904],{6460:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/portal/[merchantLocationId]/orders",function(){return r(14103)}])},14103:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return en}});var n,o,i=r(41844),l=r(20168),a=r(61953),d=r(55784),s=r(81719),c=r(62348),u=r(54225),h=r(29630),x=r(18661);let m=(0,s.ZP)(e=>(0,i.jsx)(c.Z,{...e,TabIndicatorProps:{style:{height:"100%",zIndex:0}}}))(e=>{let{theme:t}=e;return{backgroundColor:t.palette.common.white}});function j(e){let{children:t,count:r,...n}=e;return(0,i.jsx)(u.Z,{...n,children:(0,i.jsxs)(a.Z,{position:"relative",children:[t,void 0!==r&&(0,i.jsx)(a.Z,{position:"absolute",top:"50%",left:"calc(100% + 8px)",width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"error.main",sx:{transform:"translateY(-50%)"},children:(0,i.jsx)(h.Z,{color:"white",fontWeight:"700",fontSize:"small",children:r})})]})})}let v=(0,s.ZP)(e=>(0,i.jsx)(x.Z,{...e,component:j}))(e=>{let{theme:t}=e;return{"&.Mui-selected":{color:t.palette.primary.contrastText,fontWeight:"700",zIndex:400}}}),p=e=>{let{children:t,value:r,index:n,...o}=e;return(0,i.jsx)("div",{role:"tabpanel",hidden:r!==n,id:"tabpanel-".concat(n),"aria-labelledby":"full-width-tab-".concat(n),...o,children:r===n&&(0,i.jsx)(i.Fragment,{children:t})})};var f=r(68013),g=r(33008),Z=r(57480),y=r(70918),b=r(9144),E=r(91655),I=r(85214),O=r(95309),S=r(46875),w=r(17020),C=r(26797);let P=e=>{let{order:t,userOrder:r}=e,n=t.merchantLocation&&(0,S.oQ)(t.type,t.merchantLocation,t.tableId);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(h.Z,{variant:"h5",children:r.name||"Guest"}),(0,i.jsxs)(a.Z,{display:"flex",flexDirection:"row",alignItems:"center",children:[(0,i.jsx)(h.Z,{variant:"h6",color:t.type===f.mrS.Pickup?"primary":"text.secondary",children:(0,i.jsx)("strong",{children:n})}),t.type===f.mrS.Pickup&&(0,i.jsx)(C.Z,{fontSize:"small",color:"primary"})]}),(0,i.jsx)(h.Z,{variant:"body1",color:"text.secondary",sx:{mt:.25},children:(0,w.TE)(t.total)})]})};var N=r(28733),R=r(32912),L=r(51085),_=r(23855);let D=e=>{let t=(0,_.Z)(e);return(0,L.Z)(t)?(0,R.Z)(t,"h:mm a"):(0,R.Z)(t,"MMM d, h:mm a")};function M(e){let{orderItems:t,orderType:r,delivery:n,deliveryWindowStartAt:o,deliveryWindowEndAt:l,pickupTime:a,estimatedPreparedTime:d}=e,s=a||d;return(0,i.jsxs)(i.Fragment,{children:[r===f.mrS.Delivery?(0,i.jsxs)(i.Fragment,{children:[d?(0,i.jsxs)(h.Z,{variant:"h6",children:["Ready ",D(d)," \xb7 ",(0,i.jsx)(N.Z,{isoString:d})]}):null,o&&l?(0,i.jsxs)(h.Z,{variant:"body2",color:"text.secondary",children:["Deliver ",D(o)," â"," ",D(l)]}):(null==n?void 0:n.dropoffEta)?(0,i.jsxs)(h.Z,{variant:"body2",color:"text.secondary",children:["Deliver by ",D(n.dropoffEta)]}):null,(0,i.jsx)(h.Z,{variant:"body2",color:"text.secondary",children:n?g.af[n.status]:"Driver pending"})]}):s?(0,i.jsxs)(h.Z,{variant:"h6",children:["Pickup at ",D(s)," \xb7 ",(0,i.jsx)(N.Z,{isoString:s})]}):null,t.slice(0,2).map(e=>{var t;return(0,i.jsx)(h.Z,{variant:"body2",color:"text.secondary",children:null===(t=e.menuItem)||void 0===t?void 0:t.name},e.id)}),t.length>3&&(0,i.jsxs)(h.Z,{variant:"subtitle2",color:"text.secondary",gutterBottom:!0,children:["+",t.length-2," more"]})]})}var T=r(22326);let k=e=>{let{order:t,isLastChild:r,onLastItemBecameVisible:n}=e,o=(0,d.useRef)();return(0,d.useEffect)(()=>{if(o.current&&r&&n){let e=new IntersectionObserver(e=>{let[t]=e;t.isIntersecting&&n()});return e.observe(o.current),()=>e.disconnect()}},[r,n]),(0,i.jsxs)(b.Z,{direction:"row",width:"100%",ref:o,gap:1,children:[(0,i.jsx)(a.Z,{width:"35%",sx:{verticalAlign:"top"},children:t.userOrders.map(e=>(0,i.jsx)(P,{order:t,userOrder:e},e.id))}),(0,i.jsx)(a.Z,{width:"35%",children:t.userOrders.map((e,r)=>{var n,o;return(0,i.jsx)(M,{orderItems:e.orderItems,orderType:t.type,delivery:t.delivery,deliveryWindowStartAt:t.deliveryWindowStartAt,deliveryWindowEndAt:t.deliveryWindowEndAt,pickupTime:null===(n=t.details)||void 0===n?void 0:n.pickupTime,estimatedPreparedTime:null===(o=t.details)||void 0===o?void 0:o.estimatedPreparedTime},r)})}),(0,i.jsx)(a.Z,{width:"30%",display:"flex",justifyContent:"flex-end",children:(0,i.jsx)(T.Z,{order:t})})]})};var W=r(73350),F=r(36487),z=r(48083),A=r(41664),G=r.n(A);let U=e=>{let{cardTitle:t,orders:r,icon:n,loading:o,merchantLocationId:l}=e;return(0,i.jsx)(W.Z,{children:(0,i.jsx)(F.Z,{timeout:250,children:(0,i.jsxs)(y.Z,{sx:{p:3,m:2},"data-testid":"".concat(t," Card"),children:[(0,i.jsxs)(b.Z,{direction:"row",mb:2,alignItems:"center",children:[n,(0,i.jsx)(h.Z,{variant:"h4",sx:{pl:2},gutterBottom:!0,children:t})]}),o&&(0,i.jsxs)(h.Z,{variant:"h1",sx:{p:2},color:"text.secondary",children:[(0,i.jsx)(E.Z,{animation:"wave"}),(0,i.jsx)(E.Z,{animation:"wave"})]}),!o&&!r.length&&(0,i.jsx)(h.Z,{variant:"h5",sx:{p:3},color:"text.secondary",textAlign:"center",children:"No orders found"}),!o&&r.length>0&&(0,i.jsx)(W.Z,{component:I.Z,children:r.map(e=>(0,i.jsx)(z.Z,{children:(0,i.jsx)(O.Z,{component:G(),href:"/portal/".concat(l,"/orders?oid=").concat(e.id),children:(0,i.jsx)(k,{order:e})})},e.id))})]})})})};var K=r(10436);let V=e=>{let{merchantLocationId:t}=e,{openOrders:r,loadingOpen:n}=(0,K.m)(),o=(0,d.useMemo)(()=>{let e={submitted:[],inKitchen:[],foodReady:[]};return null==r||r.forEach(t=>{(0,g.je)(t.node.mealStatus)?e.submitted.push(t.node):t.node.mealStatus===f.Niv.SentToKitchen?e.inKitchen.push(t.node):t.node.mealStatus===f.Niv.FoodReady&&e.foodReady.push(t.node)}),e},[r]);return(0,i.jsxs)(a.Z,{overflow:"auto",height:"calc(100vh - 120px)",children:[(0,i.jsx)(U,{cardTitle:"Submitted",orders:o.submitted,icon:(0,i.jsx)(Z.F5,{fontSize:"large"}),loading:n,merchantLocationId:t}),(0,i.jsx)(U,{cardTitle:"In Kitchen",orders:o.inKitchen,icon:(0,i.jsx)(Z.V$,{fontSize:"large"}),loading:n,merchantLocationId:t}),(0,i.jsx)(U,{cardTitle:"Food Ready",orders:o.foodReady,icon:(0,i.jsx)(Z.fm,{fontSize:"large"}),loading:n,merchantLocationId:t})]})};var B=r(70754);function q(e){let{merchantLocationId:t,onFetchPage:r,pageInfo:n,orders:o,loading:l,...s}=e,c=(0,d.useRef)(!1);async function u(){!c.current&&(null==n?void 0:n.hasNextPage)&&(null==n?void 0:n.endCursor)&&(c.current=!0,await r(n.endCursor),c.current=!1)}return(0,i.jsxs)(a.Z,{height:"calc(100vh - 120px)",overflow:"auto",...s,children:[l&&!o.length&&(0,i.jsx)(B.Z,{sx:{display:"block",mx:"auto",my:4}}),!l&&!o.length&&(0,i.jsx)(h.Z,{my:4,textAlign:"center",fontWeight:"bold",fontSize:"large",color:"text.secondary",children:"No orders found"}),(0,i.jsx)(I.Z,{sx:{p:0},children:o.map((e,r)=>{let{node:n}=e;return(0,i.jsx)(O.Z,{component:G(),href:"/portal/".concat(t,"/orders?oid=").concat(n.id),sx:{px:4},children:(0,i.jsx)(k,{order:n,isLastChild:r===o.length-1,onLastItemBecameVisible:u})},n.id)})})]})}function X(e){let{merchantLocationId:t}=e,{closedOrders:r,fetchClosedOrdersPage:n,closedOrdersPageInfo:o,closedOrdersLoading:l}=(0,K.m)();return(0,i.jsx)(q,{"data-testid":"closed-orders",merchantLocationId:t,orders:r,loading:l,pageInfo:o,onFetchPage:n})}var Q=r(11163),Y=r(17092),$=r(30511);function H(e){(null===$.jZ||void 0===$.jZ?void 0:$.jZ.readyState)===WebSocket.OPEN&&$.jZ.send((0,Y.a3)({type:Y.Cs.Ping,payload:{merchant_location_id:e}}))}function J(e){let{merchantLocationId:t}=e,{upcomingOrders:r,fetchUpcomingOrdersPage:n,upcomingOrdersPageInfo:o,upcomingOrdersLoading:l}=(0,K.m)();return(0,i.jsx)(q,{"data-testid":"upcoming-orders",merchantLocationId:t,orders:r,loading:l,pageInfo:o,onFetchPage:n})}var ee=r(14622);(n=o||(o={}))[n.OPEN=0]="OPEN",n[n.UPCOMING=1]="UPCOMING",n[n.CLOSED=2]="CLOSED";let et=()=>{let e=(0,Q.useRouter)(),{merchantLocationId:t}=e.query,{tracking:r}=(0,ee.r)(),[n,l]=(0,d.useState)(o.OPEN);!function(){let e=(0,Q.useRouter)(),{merchantLocationId:t}=e.query;(0,d.useEffect)(()=>
1{if("string"==typeof t){H(t);let e=setInterval(()=>{H(t)},6e4);return()=>clearInterval(e)}},[t])}();let{refetchUpcomingOrders:s,getClosedOrders:c,upcomingOrders:u}=(0,K.m)();(0,d.useEffect)(()=>{t&&r.log("ROM:ORDERS_SCREEN_VIEWED",{merchantLocationId:t})},[t,r]),(0,d.useEffect)(()=>{n===o.UPCOMING&&(r.log("ROM:VIEW_UPCOMING_ORDERS",{merchantLocationId:t}),s()),n===o.CLOSED&&(r.log("ROM:VIEW_CLOSED_ORDERS",{merchantLocationId:t}),c())},[r,n,s,c,t]);let h=(e,t)=>{l(t)};return(0,i.jsxs)(a.Z,{children:[(0,i.jsx)(a.Z,{borderBottom:1,borderColor:"divider",children:(0,i.jsxs)(m,{value:n,onChange:h,variant:"fullWidth","aria-label":"order groups",children:[(0,i.jsx)(v,{label:"Open Orders",value:o.OPEN}),(0,i.jsx)(v,{label:"Upcoming Orders",value:o.UPCOMING,count:u.length>0?u.length:void 0}),(0,i.jsx)(v,{label:"Closed Orders",value:o.CLOSED})]})}),(0,i.jsx)(p,{value:n,index:o.OPEN,children:(0,i.jsx)(V,{merchantLocationId:t})}),(0,i.jsx)(p,{value:n,index:o.UPCOMING,children:(0,i.jsx)(J,{merchantLocationId:t})}),(0,i.jsx)(p,{value:n,index:o.CLOSED,children:(0,i.jsx)(X,{merchantLocationId:t})})]})},er=()=>(0,i.jsx)(et,{});er.getLayout=e=>(0,i.jsx)(l.Z,{children:e});var en=er}},function(e){e.O(0,[6751,1694,3525,6666,7836,8452,7764,1299,1309,7394,518,6898,5780,9898,6072,4495,6405,9619,168,2888,179],function(){return e(e.s=6460)}),_N_E=e.O()}]); 2//# sourceMappingURL=orders-aec770961643a975.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.