(window.webpackJsonp=window.webpackJsonp||[]).push([[11],{"3WF5":function(e,t,n){var r=n("eUgh"),a=n("ut/Y"),c=n("l9OW"),o=n("Z0cm");e.exports=function(e,t){return(o(e)?r:c)(e,a(t,3))}},"6ajc":function(e,t,n){var r=n("XGnz"),a=n("3WF5");e.exports=function(e,t){return r(a(e,t),1)}},cWVy:function(e,t,n){"use strict";n.r(t);var r,a=n("q1tI"),c=n("k8Y/"),o=n.n(c),i=n("Wbzz"),u=n("O2s4"),s=n("Bu+q"),l=n("KQm4"),d=n("qPyV"),m=n.n(d),p=n("xweI"),f=n.n(p),y=n("z0sf"),b=n("p+7n"),g=n("bTjV"),v=n("pg3q"),k=n("6ajc"),E=n.n(k),O=n("afOK"),w=n.n(O),P=n("TSYQ"),T=n.n(P),h=n("Bjc/"),x=n("4wU3");!function(e){e.ProductList="product_list",e.OrderNow="product_order_now"}(r||(r={}));var S=function(e){var t=e.product,n=e.discount,r=e.position,a=e.pathName,c=e.quantity,o=t.productType===x.d.Extra||t.productType===x.d.OneOff||t.productType===x.d.Donation,i=o?"Extras":"Bags",u=Object(y.calculateDiscount)(n,Object.assign({},t,{productType:o?y.ProductType.Extra:y.ProductType.Primary})).price;return{name:t.name||"",id:t.sku,price:u.discounted,category:i,list:a,quantity:c,position:r,dimension6:"OneOff"}},j=function(e,t,n){switch(n){case r.ProductList:return function(e,t){var n=document.location.pathname,a=e.map((function(e,r){return S({product:e,discount:t,position:r+1,pathName:n})}));return{event:r.ProductList,eventDetails:{category:"Ecommerce",action:"Product List"},ecommerce:{currencyCode:"NZD",impressions:a}}}(e,t);case r.OrderNow:return function(e,t){var n=e.map((function(e,n){return S({product:e,discount:t,position:n+1,quantity:1})})),a=document.location.pathname;return{event:r.OrderNow,eventDetails:{category:"Ecommerce",action:"AddToCart"},ecommerce:{currencyCode:"NZD",add:{actionField:{list:a},products:n}}}}(e,t)}},N=function(e,t,n){return{label:"Buy Now"+(t?" ($"+(e.price+e.deliveryPrice).toFixed(2)+")":""),url:n+"/order/"+e.sku+"?inWeekSale=true",dataCategory:"product",dataLabel:"buffer-stock-"+e.sku,dataAction:"add"}},D=function(e){var t=e.product,n=e.siteMetadata,c=e.bgToggle,o=Object(y.useDiscountContext)().discount,i=a.useCallback((function(){return j([t],o,r.OrderNow)}),[o,t]),s=E()(t.recipeCollections,"collections"),l=Object(h.a)(s),d=w()(l),m=s.filter((function(e){return e.day===d})),p=m.map((function(e){return Object.assign({},e,{recipes:e.recipes.filter((function(e){return e.isDefaultChoice&&0===e.surcharge}))})})),f=t.productType===u.a.Extra||t.productType===u.a.OneOff||t.productType===u.a.Donation;return m.length>0?a.createElement("div",{key:t.id+"-"+d,className:T()("text-center",{"bg-secondary text-center":c})},a.createElement("h3",{className:"pt-4"},t.name),a.createElement(y.DiscountConsumer,{product:Object.assign({},t,{price:t.price+t.deliveryPrice,productType:f?y.ProductType.Extra:y.ProductType.Primary}),render:function(e){var r=e.discounted!==e.original;return a.createElement(a.Fragment,null,r&&a.createElement("div",{className:"d-flex justify-content-center w-100"},a.createElement(y.ProductGroupCardDiscountDisplay,{price:e})),a.createElement(b.TrackGtm,{getEventDetails:i},a.createElement(y.ProductOrderButton,{isBuffer:!0,sku:t.sku,productType:f?y.ProductType.Extra:y.ProductType.Primary,className:"my-2",actionButton:N(t,!r,n.gatewayUrl)})))}}),a.createElement(y.RecipeWeeks,{key:t.id,id:t.id,showWeekSelector:!1,isRecipeModalEnabled:!0,recipeCollections:p,pageSectionVerticalSpaceClassName:"py-4"})):null},B=function(e){var t=e.products,n=e.siteMetadata,c=e.preSelectedSku,i=Object(y.useStock)(),u=i[0],s=u.isLoading,d=u.bufferStock,p=i[1];a.useEffect((function(){t.forEach((function(e){return p({type:y.StockActionType.registerBuffer,sku:e.sku})}))}),[p,t]);var k=function(e){return o()(m()(e.map((function(e){return{value:e.numberOfPeopleToFeed,isDisabled:!1}})),"value"),["value"],["asc"])}(t),E=a.useMemo((function(){return c?t.find((function(e){return e.sku===c||e.itemNumber===c})):void 0}),[c,t]),O=E&&E.numberOfPeopleToFeed||k[0].value,w=a.useState(O),P=w[0],T=w[1],h=function(e){T(e),Object(v.b)("jumbo-last-minute-bags")},x=a.useMemo((function(){var e={};d.forEach((function(t){e[t.sku]=t.hasStock}));var n=f()(t.filter((function(e){return e.numberOfPeopleToFeed===P})),(function(t){return!e[t.sku]}));return E&&E.numberOfPeopleToFeed===P?(n=n.filter((function(e){return e.sku!==E.sku})),[E].concat(Object(l.a)(n))):n}),[d,E,t,P]),S=function(){return a.createElement("div",{className:"w-100 d-flex justify-content-center mt-2"},a.createElement("div",{className:"d-flex align-items-center mr-4"},a.createElement(b.PeopleIcon,{className:"mr-1"}),a.createElement("span",{className:"text-nowrap"},"People to feed")),a.createElement(b.ButtonCheckbox,{options:k,onChange:h,selected:P}))},N=Object(y.useDiscountContext)(),B=N.discount,C=N.isLoading;return a.useEffect((function(){if(!C){var e=j(x,B,r.ProductList);Object(b.sendTrackingDetails)(e)}}),[B,x,C]),a.createElement(a.Fragment,null,a.createElement(b.Jumbotron,{id:"jumbo-last-minute-bags",title:"Available Bags",description:"Below are our bags currently available for delivery this Saturday, Sunday or Monday. Stock is very limited so get in quick.",splitOnMobile:!1},a.createElement("div",{className:"mb-4"},a.createElement(S,null)),a.createElement(b.StickyHeader,{text:"Select a Bag",actionItem:a.createElement(S,null)})),s?a.createElement("div",{className:"d-flex w-100 justify-content-center my-5"},a.createElement(g.a,{color:"primary"})):x.map((function(e,t){return a.createElement("div",{key:e.id},a.createElement(D,{product:e,siteMetadata:n,bgToggle:t%2==0}))})))},C=function(e){var t=e.siteMetadata;return a.createElement(i.b,{query:"3701404271",render:function(e){var n,r=o()(Object(s.a)(e.allProductDb),["brand","name"],["desc","asc"]).filter((function(e){return e.productType===u.a.Primary}));"undefined"!=typeof window&&(n=window.location.search.substring(1));var c=new URLSearchParams(n).get("sku")||"";return a.createElement(B,{products:r,siteMetadata:t,preSelectedSku:c})}})},L=n("ymsD"),M=n("GztK"),F=n("uzlL");t.default=Object(L.WithPathRules)(Object(M.WithSiteMetadata)((function(e){var t={title:"My Food Bag Recipes by Nadia Lim - My Food Bag",description:{description:"Bags currently available for delivery this Saturday, Sunday or Monday. Stock is very limited so get in quick."},type:"article",canonicalUrlLink:{absoluteUrl:"/late-sales"},sharingLinkImage:{id:"",__typename:"",alternateText:"",small:{id:"",file:{url:""}},large:{id:"",file:{url:""}}},allowIndexing:!1,keywords:[]};return a.createElement(F.a,{metadata:t,render:function(){return a.createElement(C,e)}})})))},"k8Y/":function(e,t,n){var r=n("alwl"),a=n("Z0cm");e.exports=function(e,t,n,c){return null==e?[]:(a(t)||(t=null==t?[]:[t]),a(n=c?void 0:n)||(n=null==n?[]:[n]),r(e,t,n))}},qPyV:function(e,t,n){var r=n("ut/Y"),a=n("LGYb");e.exports=function(e,t){return e&&e.length?a(e,r(t,2)):[]}}}]); //# sourceMappingURL=component---src-pages-late-sales-tsx-995f9adb6a82c58f131c.js.map