"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[901],{901:function(e,t,s){s.d(t,{Z:function(){return CartIndex}});var c=s(85893),r=s(67294),i=s(11163);function QtyIndex(e){var t,s,r,a;let d=(0,i.useRouter)();return(0,c.jsx)("div",{className:"cart",children:(0,c.jsxs)("div",{className:"qty",children:["subscription_manage_order"!==e.cartType&&(0,c.jsx)("div",{className:"sign left",onClick:()=>e.increment_decrement("decrement",e.product.unit_increment,e.product.unit,e.cart_product_id),children:(0,c.jsx)(e=>{let t;return"EA"==e.product.unit?1==e.quantity||0==e.quantity?t=(0,c.jsx)("img",{src:"".concat(d.basePath,"/assets/cart-delete.png"),style:{height:"12px"},alt:""}):e.quantity>1&&(t=(0,c.jsx)("img",{src:"".concat(d.basePath,"/assets/minus_cart.svg"),style:{width:"13px",height:"2px"},alt:""})):"LB"==e.product.unit&&(t=0==e.quantity?(0,c.jsx)("img",{src:"".concat(d.basePath,"/assets/cart-delete.png"),style:{height:"12px"},alt:""}):e.quantity==e.product.unit_increment?(0,c.jsx)("img",{src:"".concat(d.basePath,"/assets/cart-delete.png"),style:{height:"12px"},alt:""}):(0,c.jsx)("img",{src:"".concat(d.basePath,"/assets/minus_cart.svg"),style:{width:"13px",height:"2px"},alt:""})),t},{...e})}),(0,c.jsx)("div",{className:"number",children:(0,c.jsxs)("p",{children:[e.quantity," ",(null===(t=e.product)||void 0===t?void 0:t.unit)=="LB"&&(null===(s=e.product)||void 0===s?void 0:s.avg_weight)==""?"lb":(null===(r=e.product)||void 0===r?void 0:r.unit)=="LB"&&(null===(a=e.product)||void 0===a?void 0:a.avg_weight)>0?"ea":""]})}),"subscription_manage_order"!==e.cartType&&(0,c.jsx)("div",{className:"sign right",onClick:()=>e.increment_decrement("increment",e.product.unit_increment,e.product.unit,e.cart_product_id),children:(0,c.jsx)("img",{src:"".concat(d.basePath,"/assets/plus.svg"),style:{height:"13px"}})})]})})}function CartItemIndex(e){let t=(0,i.useRouter)(),[s,a]=(0,r.useState)(!1);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{children:(0,c.jsx)("p",{className:!1==s?"sort":"long",children:e.selected_modifiers_desc})}),(0,c.jsx)("div",{style:{marginLeft:"10px"},children:(0,c.jsx)("img",{src:!1==s?"".concat(t.basePath,"/assets/para-down.png"):"".concat(t.basePath,"/assets/para-up.png"),style:{position:"relative",left:"-10px"},onClick:()=>{a(!s)}})})]})}var a=s(73380),d=s.n(a);function SubItem(e){var t,s,a,n;let o=(0,i.useRouter)(),[l,p]=(0,r.useState)(""),[u,m]=(0,r.useState)(!1),clickremove=t=>{p(t),m(!0),e.removeProduct(t)},redirectToDetails=(t,s,c)=>{if("track"==e.cartType&&e.orderIdSub&&sessionStorage.setItem("redirectOrder",e.orderIdSub),s&&""!==s){let r=localStorage.getItem("SId"),i="";r&&""!==r&&(i=r),"subscription_cart_page"==e.cartType?o.push({pathname:"/product/"+t+"/"+c,query:{cpd:s,sid:i}}):o.push({pathname:"/product/"+t+"/"+c,query:{cpd:s}})}else o.push({pathname:"/product/"+t+"/"+c})};return(0,c.jsx)("div",{className:"cartItems",children:(0,c.jsxs)(c.Fragment,{children:[e.cart_product_id==l&&!0==u?(0,c.jsx)("div",{className:"text-center",children:(0,c.jsx)(d(),{color:"#000000"})}):(0,c.jsx)(c.Fragment,{children:!0==e.showCheckbox&&(0,c.jsx)("div",{className:"check-uncheck-btn",children:(0,c.jsx)("div",{className:"multiple_select",children:(0,c.jsx)("ul",{children:(0,c.jsxs)("li",{onClick:t=>e.checkedItem(t,e.product._id),children:[(0,c.jsx)("input",{type:"checkbox",name:e.brand_name,id:e.id,onChange:t=>e.checkedItem(t,e.product._id),checked:e.can_replace}),(0,c.jsx)("label",{})]})})})})}),(0,c.jsxs)("div",{children:[(0,c.jsxs)("div",{className:"cart-item-img",style:{cursor:"pointer"},onClick:()=>redirectToDetails(e.product.internal_product_id,e.cart_product_id,e.product.slug),children:[e.product.medias&&e.product.medias.length>0,(0,c.jsx)("div",{className:"img",children:(0,c.jsx)("img",{src:(null==e?void 0:null===(s=e.product)||void 0===s?void 0:null===(t=s.medias[0])||void 0===t?void 0:t.url)||"https://erewhonappsftp.s3.us-west-2.amazonaws.com/categories/aa76b721ac19f7516c0d4ca38d073318.png",alt:""})}),"cart"==e.cartType&&"some_substitute"==e.selectedFitler.type&&(0,c.jsx)("div",{className:"substitutions_img",children:(0,c.jsx)("img",{src:!0==e.can_replace?"https://erewhonappsftp.s3.us-west-2.amazonaws.com/extra_images/842a1996e75201974173d4df2109b298.png":"https://erewhonappsftp.s3.us-west-2.amazonaws.com/extra_images/4557aeffdf65810bfffea891d383b911.png",style:{height:"13px",opacity:"0.5"},alt:""})})]}),("cart"==e.cartType||"subscription_cart_page"==e.cartType||"subscription_manage_order"==e.cartType)&&(0,c.jsx)("div",{className:"mt-3 d-block d-lg-none hidden-lg-up",children:(0,c.jsx)(QtyIndex,{...e,increment_decrement:e.increment_decrement_call})})]}),(0,c.jsxs)("div",{className:"cart-item-details",children:[(0,c.jsxs)("div",{className:"brand_name_product",children:[(0,c.jsx)("p",{className:"brand_name",children:null===(a=e.product.brands)||void 0===a?void 0:a.name}),(0,c.jsx)("p",{className:"product_name",style:{cursor:"pointer"},onClick:()=>redirectToDetails(e.product.internal_product_id,e.cart_product_id,e.product.slug),children:null===(n=e.product)||void 0===n?void 0:n.name})]}),e.selected_modifiers_desc&&""!==e.selected_modifiers_desc&&(0,c.jsx)("div",{className:"cart-item-modifier",style:{display:"flex",alignItems:"baseline"},children:(0,c.jsx)(CartItemIndex,{...e})}),e.product_instruction&&""!==e.product_instruction&&(0,c.jsx)("div",{className:"cart-item-instructions",children:(0,c.jsxs)("p",{children:["Instructions: ",e.product_instruction]})}),e&&e.time_text&&""!==e.time_text&&(0,c.jsx)("div",{className:"time-text ".concat(!0==e.available?"green":"red"),children:(0,c.jsx)("p",{children:e.time_text})}),e&&"pending"==e.product_confirm_status&&""!==e.product_confirm_text&&(0,c.jsx)("div",{className:"time-text red",children:(0,c.jsx)("p",{children:e.product_confirm_text})}),(0,c.jsxs)("div",{children:[(0,c.jsxs)("div",{className:"price ".concat("cart"==e.cartType||"subscription_cart_page"==e.cartType||"subscription_manage_order"==e.cartType?"d-block d-lg-none hidden-lg-up":""),children:[(0,c.jsx)("p",{style:{marginBottom:"0px"},children:e.product&&"false"==e.product.is_sales?(0,c.jsxs)("p",{children:["$",parseFloat(e.product_price).toFixed(2)]}):e.product&&"true"==e.product.is_sales?(0,c.jsxs)("p",{children:[(0,c.jsxs)("label",{style:{color:"#64A454"},children:["$",e.product_price]}),(0,c.jsxs)("label",{style:{marginLeft:"5px"},children:[(0,c.jsxs)("del",{children:["$",e.old_price]})," "]})]}):""}),(null==e?void 0:e.bottle_deposit_msg)&&(0,c.jsx)("div",{className:"mobile",children:(0,c.jsx)("p",{className:"bottle_deposit_msg",children:null==e?void 0:e.bottle_deposit_msg})})]}),("cart"==e.cartType||"subscription_cart_page"==e.cartType)&&(0,c.jsx)("div",{className:"add_to_list-delete-btn d-block d-lg-none hidden-lg-up",children:(0,c.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[""!==e.userDataToken&&"false"==e.product.is_favourite&&(0,c.jsxs)("p",{className:"add-to-list-btn",onClick:()=>e.add_to_faviourite(e.product._id),style:{marginRight:"10px",cursor:"pointer"},children:[(0,c.jsx)("img",{src:"".concat(o.basePath,"/assets/addtoListCart.svg"),alt:"addtoList"}),(0,c.jsx)("span",{className:"delete-span",style:{paddingLeft:"3px"},children:"Add to List"})]}),""!==e.userDataToken&&"true"==e.product.is_favourite&&(0,c.jsxs)("p",{className:"add-to-list-btn",onClick:()=>e.add_to_faviourite(e.product._id),style:{marginRight:"10px",cursor:"pointer"},children:[(0,c.jsx)("img",{src:"".concat(o.basePath,"/assets/removetolist.png"),alt:"addtoList",style:{height:"12px"}}),(0,c.jsx)("span",{children:"Remove from List"})]}),(0,c.jsxs)("p",{className:"delete-btn",onClick:()=>clickremove(e.cart_product_id),style:{cursor:"pointer"},children:[(0,c.jsx)("img",{src:"".concat(o.basePath,"/assets/delete_icon.png"),style:{height:"12px"},alt:"addtoList"}),(0,c.jsx)("span",{className:"delete-span",children:"Delete"})]})]})})]}),("cart"==e.cartType||"subscription_cart_page"==e.cartType)&&(0,c.jsx)("div",{className:"d-none d-lg-block hidden-lg-down",children:(0,c.jsxs)("div",{className:"add_to_list-delete-btn",children:[""!==e.userDataToken&&"false"==e.product.is_favourite&&(0,c.jsxs)("p",{className:"add-to-list-btn",onClick:()=>e.add_to_faviourite(e.product._id),style:{marginRight:"10px",cursor:"pointer"},children:[(0,c.jsx)("img",{src:"".concat(o.basePath,"/assets/addtoListCart.svg"),alt:"addtoList"}),(0,c.jsx)("span",{className:"delete-span",children:"Add to List"})]}),""!==e.userDataToken&&"true"==e.product.is_favourite&&(0,c.jsxs)("p",{className:"add-to-list-btn",onClick:()=>e.add_to_faviourite(e.product._id),style:{marginRight:"10px",cursor:"pointer"},children:[(0,c.jsx)("img",{src:"".concat(o.basePath,"/assets/removetolist.png"),alt:"addtoList",style:{height:"13px"}}),"Remove from List"]}),(0,c.jsxs)("p",{className:"delete-btn",onClick:()=>clickremove(e.cart_product_id),style:{cursor:"pointer"},children:[(0,c.jsx)("img",{src:"".concat(o.basePath,"/assets/delete_icon.png"),style:{height:"12px",position:"relative"},alt:"addtoList"}),"Delete"]})]})})]}),"track"==e.cartType&&(0,c.jsx)("div",{className:"cart-qty-number",children:(0,c.jsx)("p",{children:e.quantity})}),("cart"==e.cartType||"subscription_cart_page"==e.cartType||"subscription_manage_order"==e.cartType)&&(0,c.jsxs)("div",{className:"cart-items-price-qty d-none d-lg-block hidden-lg-down",children:[(0,c.jsx)("div",{className:"price ".concat(e.bottle_deposit_msg&&e.bottle_deposit_msg?"deposit_msg":""),children:e.product&&"false"==e.product.is_sales?(0,c.jsxs)("p",{children:["$",parseFloat(e.product_price).toFixed(2)]}):e.product&&"true"==e.product.is_sales?(0,c.jsxs)("p",{children:[(0,c.jsxs)("label",{style:{color:"#64A454"},children:["$",e.product_price]}),(0,c.jsxs)("label",{style:{marginLeft:"5px"},children:[(0,c.jsxs)("del",{children:["$",e.old_price]})," "]})]}):""}),(null==e?void 0:e.bottle_deposit_msg)&&(0,c.jsx)("div",{children:(0,c.jsx)("p",{className:"bottle_deposit_msg",children:null==e?void 0:e.bottle_deposit_msg})}),(0,c.jsx)("div",{className:e.bottle_deposit_msg&&e.bottle_deposit_msg?"bottle_message_cart":"",children:(0,c.jsx)(QtyIndex,{...e,increment_decrement:e.increment_decrement_call})})]})]})})}function CartIndex(e){let t=(0,i.useRouter)(),[s,a]=(0,r.useState)(!0),showAllItems=()=>{a(!s)};return(0,c.jsxs)(c.Fragment,{children:[!0==e.showTitle&&(0,c.jsxs)("div",{className:"item-title-tag",children:[(0,c.jsx)("div",{className:"title",onClick:showAllItems,children:(0,c.jsxs)("p",{children:[e.name," (",e.total_items,")"]})}),(0,c.jsx)("div",{className:"arrow",onClick:showAllItems,children:(0,c.jsx)("img",{src:!0==s?"".concat(t.basePath,"/assets/cart-product-down.png"):"".concat(t.basePath,"/assets/cart-product-up.png")})})]}),!0==s&&"track"!==e.cartType&&(0,c.jsx)(c.Fragment,{children:e.products&&""!==e.products&&e.products.map((t,s)=>{if(0!==t.quantity)return(0,c.jsx)(SubItem,{...t,...e,add_to_faviourite:e.add_to_faviourite_main,increment_decrement_call:e.increment_decrement_main,removeProduct:e.removeProduct,rowLoading:e.rowLoading,showCheckbox:e.showCheckbox,showQty:e.showQty})})}),!0==s&&"track"==e.cartType&&(0,c.jsx)(c.Fragment,{children:e.product&&""!==e.product&&e.itemorderId&&""!==e.itemorderId&&(0,c.jsx)(SubItem,{...e,product:e.product,add_to_faviourite:e.add_to_faviourite_main,increment_decrement_call:e.increment_decrement_main,removeProduct:e.removeProduct,rowLoading:e.rowLoading,showCheckbox:e.showCheckbox,showQty:e.showQty,cartType:"track",orderIdSub:e.itemorderId})})]})}}}]);