PageSourceSearch

https://shop.wba.co.uk/inc/frontend/CartSidebar.a41aa95be78a7339b3d0.js

js wba.co.uk collected 2026-10-02 03:03:00 UTC 6,289 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkjonas_frontend=self.webpackChunkjonas_frontend||[]).push([[147],{1395(e,t,o){o.r(t),o.d(t,{default:()=>j});var n=o(4848),s=o(6540),i=o(3356),r=o(2944),a=o(433),c=o(4477),d=o(9494),l=o(2483),p=o(5985),h=o(8943),u=o(7809),m=o(2389),f=o(5165),x=o(3438),g=o(9200);const y=({subtotal:e,totalPromotionsDiscount:t,promotions:o,total:s,proceedToCheckout:i,t:r})=>{const a=(0,g.o)(o);return(0,n.jsxs)(c.A,{sx:{position:"sticky",bottom:0,backgroundColor:"#fff",zIndex:1,borderTop:"1px solid #e0e0e0"},children:[(0,n.jsxs)(c.A,{p:2,children:[e>0&&t>0&&(0,n.jsxs)(c.A,{display:"flex",justifyContent:"space-between",mb:.5,children:[(0,n.jsx)(d.A,{variant:"body2",color:"textSecondary",children:"Subtotal"}),(0,n.jsxs)(d.A,{variant:"body2",children:["£",e.toFixed(2)]})]}),e>0&&a.length>0&&a.map((e,t)=>(0,n.jsxs)(c.A,{display:"flex",justifyContent:"space-between",mb:.5,children:[(0,n.jsx)(d.A,{variant:"body2",color:"#d32f2f",children:e.description}),(0,n.jsxs)(d.A,{variant:"body2",color:"#d32f2f",children:["-£",Math.abs(e.discount).toFixed(2)]})]},`${e.id}-${t}`)),e>0&&!!i&&(0,n.jsxs)(c.A,{display:"flex",justifyContent:"space-between",mt:a.length>0?1.5:0,children:[(0,n.jsx)(d.A,{variant:"body1",fontWeight:"bold",children:"Total"}),(0,n.jsxs)(d.A,{variant:"body1",fontWeight:"bold",children:["£",s.toFixed(2)]})]})]}),(0,n.jsxs)(c.A,{p:2,pt:0,children:[(0,n.jsx)("a",{href:"/cart.php",title:r("proceed_to_checkout"),className:"proceed-to-checkout button expanded button--success checkout-button marg-0",children:r(e>0&&i?"proceed_to_checkout":"goto_cart")}),(0,n.jsx)(c.A,{display:"flex",justifyContent:"center",mt:2,children:(0,n.jsx)("img",{src:"/siteimg/misc/payment_methods_img.png",alt:"Payment Methods",style:{maxWidth:"80%",height:"auto"}})})]})]})};var b=o(2057);const j=({cart:e})=>{const[t,g]=(0,s.useState)(!1),[j,A]=(0,s.useState)([]),[_,C]=(0,s.useState)([]),[v,k]=(0,s.useState)(!0),[S,w]=(0,s.useState)(0),[I,T]=(0,s.useState)(null),[D,M]=(0,s.useState)(!1),{t:E}=(0,m.Bd)(),P=(0,i.A)(),O=(0,r.A)(P.breakpoints.down(460)),q=(0,s.useMemo)(()=>j.reduce((e,t)=>e+(t.price+(t.personalisation_cost||0)+(t.patches||0))*t.quantity,0),[j]),F=(0,s.useMemo)(()=>_.reduce((e,t)=>e+-(t.discount>0?-t.discount:t.discount),0),[_]),z=(0,s.useMemo)(()=>q-F,[q,F]),W=(0,s.useMemo)(()=>z>S?100:S>0?z/S*100:0,[S,z]),N=(0,s.useMemo)(()=>Math.max(0,S-z),[S,z]),B=(0,s.useMemo)(()=>j.reduce((e,t)=>e+t.quantity,0),[j]),H=e=>{g(e)},J=()=>{T(null)},R=e=>{e.preventDefault(),H(!0)};(0,s.useEffect)(()=>{window.toggleCartSidebar=e=>{H(e)};const e=document.querySelector(".mega-menu__icon--bag");return e&&e.addEventListener("click",R),()=>{delete window.toggleCartSidebar,e&&e.removeEventListener("click",R)}},[]);const U=(...t)=>{return n=void 0,s=[...t],r=function*(t=!0){k(t||!0);try{const t=null;if(t){const{loadMockCartData:e}=yield o.e(104).then(o.bind(o,1104)),n=yield e(t),s=n.cart_items||[];return A(s),C(n.promotions||[]),M(s.length>0),w(n.free_shipping||0),void k(!1)}const n=yield fetch("/api/cart/cartItems.php?action=list",{headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST",body:JSON.stringify({cartId:encodeURIComponent(e)})}),s=yield n.json(),i=s.cart_items||[];A(i),C(s.promotions||[]),M(i.length>0),w(s.free_shipping||0),k(!1)}catch(e){console.error("Error fetching cart data:",e),A([]),k(!1),T(E("error_fetch_cart","Failed to fetch cart items. Please try again."))}},new((i=void 0)||(i=Promise))(function(e,t){function o(e){try{c(r.next(e))}catch(e){t(e)}}function a(e){try{c(r.throw(e))}catch(e){t(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(o,a)}c((r=r.apply(n,s||[])).next())});var n,s,i,r};return(0,s.useEffect)(()=>{t&&U()},[t]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(a.Ay,{anchor:"right",open:t,disableEscapeKeyDown:!0,"aria-hidden":!t,onClose:(e,t)=>{"backdropClick"!==t&&H(!1)},sx:{"& .MuiDrawer-paper":{width:O?"100%":460,display:"flex",flexDirection:"column"}},children:[(0,n.jsxs)(c.A,{display:"flex",justifyContent:"space-between",alignItems:"center",p:2,borderBottom:"1px solid #e0e0e0",sx:{position:"sticky",top:0,backgroundColor:"#fff",zIndex:1},children:[(0,n.jsxs)(c.A,{display:"flex",alignItems:"center",children:[(0,n.jsx)(d.A,{variant:"h6",fontWeight:"bold",color:"textPrimary",children:E("your_bag")}),(0,n.jsxs)(d.A,{variant:"h6",fontWeight:"bold",sx:{ml:1},children:["(",B," item",1!==B?"s":"",")"]})]}),(0,n.jsx)(l.A,{onClick:()=>H(!1),"aria-label":"Close cart sidebar","aria-hidden":!1,children:(0,n.jsx)(u.A,{sx:{fontSize:24}})})]}),(0,n.jsx)(c.A,{sx:{px:{xs:2,md:0}},children:(0,n.jsx)(b.A,{cartItems:j,loading:v,shippingThreshold:S,remainingForFreeShipping:N,progressBarValue:W,handleQuantityChange:(t,o)=>{const n=j.find(e=>e.id===t);n&&!n.is_free_item&&(A(e=>e.map(e=>e.id===t?Object.assign(Object.assign({},e),{quantity:o}):e)),fetch("/api/cart/cartItems.php?action=update",{headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST",body:JSON.stringify({cartId:encodeURIComponent(e),itemId:t,quantity:o})}).then(e=>{if(console.log(e),!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{e.success?console.info("Quantity updated successfully:",e.message):console.error("Error updating quantity:",e.message),U(!1)}).catch(e=>{console.error("Error updating quantity:",e);const t=e.message?String(e.message):E("error_update_quantity");T(t),U(!1)}))},handleDelete:t=>{A(e=>e.filter(e=>e.id!==t)),fetch("/api/cart/cartItems.php?action=delete",{headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST",body:JSON.stringify({cartId:encodeURIComponent(e),itemId:t})}).then(e=>e.json()).then(e=>{e.success||T(e.message?String(e.message):E("error_delete_item")),U(!1)}).catch(e=>{console.error("Error deleting item:",e),T(E("error_delete_item")),U(!1)})},decodeHtml:f.i,__t:x.tY,showDigitalDeliveryDetails:!0})}),(0,n.jsx)(y,{subtotal:q,totalPromotionsDiscount:F,promotions:_,total:z,proceedToCheckout:D,t:E})]}),(0,n.jsx)(p.A,{open:!!I,autoHideDuration:4e3,onClose:J,anchorOrigin:{vertical:"bottom",horizontal:"left"},sx:{zIndex:1500},children:(0,n.jsx)(h.A,{onClose:J,severity:"info",sx:{width:"100%",bgcolor:"background.paper"},children:I})})]})}}}]);

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.