1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3080],{31640:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>u});var a=n(37876),d=n(19581),r=n(14430),s=n(52913),o=n(89099),i=n(14232),l=n(97389),c=n(14169),m=n(30647),h=n(79511),p=n(61985);function u(){let{t:e}=(0,s.A)("forms"),{country:t}=(0,r.JK)((0,o.useRouter)()),{customer:n}=(0,d.cN)(),[u,y]=(0,i.useState)([]),[f,x]=(0,i.useState)(!0),[g,j]=(0,i.useState)(new Set),[S,w]=(0,i.useState)(new Set),[C,b]=(0,i.useState)(!1),[E,M]=(0,i.useState)(null),$=async()=>{try{x(!0);let e=await fetch("/api/customer/list-payment-methods",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({country:t,stripeCustomerId:n?.custom?.fields?.stripeCustomerId})}),a=await e.json();if(a.error)throw Error(a.error.message);y(a?.cards||[])}catch(e){l.$e.show({title:T.error,message:T.failedToLoadPaymentMethods,...d.TF.ERROR})}finally{x(!1)}};(0,i.useEffect)(()=>{$()},[n?.custom?.fields?.stripeCustomerId]);let T={error:e("common:error"),failedToLoadPaymentMethods:e("failedToLoadPaymentMethods"),failedToUpdatePaymentMethod:e("failedToUpdatePaymentMethod"),failedToDeletePaymentMethod:e("failedToDeletePaymentMethod"),noPaymentMethods:e("noPaymentMethods")},P=async n=>{try{if(w(e=>
1new Set(e).add(n.id)),!(await fetch("/api/customer/update-standard-payment-method",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentMethodId:n.id,isStandard:!0,country:t})})).ok)throw Error("Failed to update payment method");await $(),l.$e.show({title:e("success"),message:e("paymentMethodSetAsStandard",{brand:n.brand.toUpperCase(),last4:n.last4}),...d.TF.SUCCESS})}catch(e){l.$e.show({title:T.error,message:T.failedToUpdatePaymentMethod,...d.TF.ERROR})}finally{w(e=>{let t=new Set(e);return t.delete(n.id),t})}},_=async e=>{M(e),b(!0)},F=async()=>{if(E)try{if(j(e=>new Set(e).add(E.id)),b(!1),!(await fetch("/api/customer/delete-payment-method",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paymentMethodId:E.id,country:t})})).ok)throw Error("Failed to delete payment method");let n=u.find(e=>e.id!==E.id);if(E.isStandard&&n)try{await P(n)}catch(e){console.error("Failed to set standard card",e)}await $(),l.$e.show({title:e("success"),message:e("paymentMethodDeleted",{brand:E.brand.toUpperCase(),last4:E.last4}),...d.TF.SUCCESS})}catch(e){l.$e.show({title:T.error,message:T.failedToDeletePaymentMethod,...d.TF.ERROR})}finally{E&&j(e=>{let t=new Set(e);return t.delete(E.id),t}),M(null)}};return(0,a.jsxs)(c.s,{w:"100%",direction:"column",gap:"12px",my:"lg",children:[f?(0,a.jsx)(m.E,{c:"dimmed",children:"Loading payment methods..."}):0===u.length?(0,a.jsx)(m.E,{c:"gray.9",children:T.noPaymentMethods}):u.map(e=>(0,a.jsx)(h.default,{paymentMethod:e,handleSaveAsStandard:P,handleDelete:_,isDeleting:g.has(e.id),isSettingStandard:S.has(e.id)},e.id)),(0,a.jsx)(p.default,{opened:C,onClose:()=>{b(!1),M(null)},onDelete:F,brand:E?.brand||"",last4:E?.last4||""})]})}},61985:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l});var a=n(37876),d=n(78384),r=n(14169),s=n(30647),o=n(25407),i=n(52913);function l({opened:e,onClose:t,onDelete:n,brand:l,last4:c}){let{t:m}=(0,i.A)("forms"),h={title:m("deletePaymentMethodTitle"),description:m("deletePaymentMethodDescription"),warning:m("deletePaymentMethodWarning"),cancel:m("common:cancel"),delete:m("delete")},p=`${l} **** ${c}`;return(0,a.jsx)(d.a,{opened:e,onClose:t,centered:!0,withCloseButton:!0,size:"xl",children:(0,a.jsxs)(r.s,{direction:"column",gap:16,children:[(0,a.jsx)(s.E,{fw:700,fz:28,style:{marginBottom:0},children:h.title}),(0,a.jsx)(s.E,{fz:18,children:h.description}),(0,a.jsx)(s.E,{fw:700,fz:20,mt:8,children:p}),(0,a.jsx)(s.E,{c:"#C62828",fz:16,mt:4,style:{marginBottom:0},children:h.warning}),(0,a.jsxs)(r.s,{mt:24,gap:16,justify:"center",children:[(0,a.jsx)(o.$,{className:"secondary",onClick:t,children:h.cancel}),(0,a.jsx)(o.$,{color:"red",onClick:n,children:h.delete})]})]})})}},79511:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var a=n(37876),d=n(14169),r=n(30647),s=n(52913);function o({paymentMethod:e,handleSaveAsStandard:t,handleDelete:n,isDeleting:o,isSettingStandard:i}){let{t:l}=(0,s.A)("forms"),c={standardCard:l("standardCard"),setStandardCard:l("setStandardCard"),creditCard:l("creditCard"),delete:l("delete"),edit:l("edit"),cardholderName:l("cardholderName"),validUntil:l("validUntil")};return(0,a.jsxs)(d.s,{direction:"column",w:"100%",p:24,style:{border:"1px solid #E0E0E0",background:"#fff",minHeight:170},children:[(0,a.jsxs)(d.s,{justify:"space-between",align:"flex-start",mb:16,children:[(0,a.jsx)(d.s,{direction:"column",gap:8,children:(0,a.jsxs)(d.s,{align:"start",gap:8,children:[(0,a.jsx)(d.s,{align:"center",justify:"center",style:{background:"#E6F2FB",borderRadius:6,padding:"2px 12px",fontWeight:700,fontSize:18,color:"#222",minWidth:60},children:e.brand.toUpperCase()}),(0,a.jsxs)(d.s,{direction:"column",style:{marginLeft:8},children:[(0,a.jsxs)(r.E,{style:{fontSize:22,fontWeight:600},children:["**** **** **** ",e.last4]}),(0,a.jsx)(r.E,{style:{fontSize:18},children:e.name||c.cardholderName}),(0,a.jsxs)(r.E,{style:{fontSize:18},children:[c.validUntil," ",e.expiryDate]})]})]})}),(0,a.jsxs)(d.s,{direction:"row",align:"center",gap:8,mt:4,children:[e.isStandard&&(0,a.jsx)(d.s,{align:"center",style:{background:"#49AC33",color:"#fff",borderRadius:20,padding:"6px 12px",fontWeight:400,fontSize:16},children:c.standardCard}),(0,a.jsx)(d.s,{align:"center",style:{background:"#F2F2F2",color:"#222",borderRadius:20,padding:"6px 12px",fontWeight:400,fontSize:16},children:c.creditCard})]})]}),(0,a.jsxs)(d.s,{align:"center",direction:"row",gap:16,children:[!e.isStandard&&(0,a.jsx)(r.E,{style:{textDecoration:"underline",fontWeight:400,fontSize:18,cursor:i?"not-allowed":"pointer"},onClick:i?void 0:()=>t(e),children:i?"...":c.setStandardCard}),(0,a.jsx)(r.E,{style:{color:"#E53935",textDecoration:"underline",fontWeight:400,fontSize:18,cursor:o?"not-allowed":"pointer"},onClick:o?void 0:()=>n(e),children:o?"...":c.delete})]})]})}}
1,85564:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__N_SSP:()=>f,default:()=>x});var a=n(37876),d=n(19581),r=n(95068),s=n(14430),o=n(14169),i=n(25407),l=n(52913),c=n(77328),m=n.n(c),h=n(89099),p=n(14232),u=n(49268),y=n(31640),f=!0;function x(){let{t:e}=(0,l.A)("forms"),t=(0,h.useRouter)(),{language:n,country:c}=(0,s.JK)(t),[f,x]=(0,p.useState)(!1),g={seo:{title:e("paymentMethodsHeadline"),description:e("paymentMethodsHeadline"),canonicalUrl:`${(0,r.$_)()}/${n}/${(0,s.$9)(c)}/customer/payment`,hreflang:{currentUrl:`${(0,r.$_)()}/${n}/${(0,s.$9)(c)}/customer/payment`,languageSlugs:{en:"/customer/payment",de:"/customer/payment",ru:"/customer/payment",ja:"/customer/payment",pt:"/customer/payment",fr:"/customer/payment",es:"/customer/payment"}},robots:{noFollow:!0,noIndex:!0}}},j=(0,r.cp)(g);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m(),{children:(0,a.jsx)(a.Fragment,{children:j})}),(0,a.jsx)(d.Qp,{items:[{label:"Home",href:`/${n}/${(0,s.$9)(c)}`},{label:`${e("paymentMethodsHeadline")}`}],baseUrl:(0,r.$_)()}),(0,a.jsxs)(o.s,{justify:"space-between",w:"100%",direction:{base:"column",xs:"row"},children:[(0,a.jsx)(d.lA,{}),(0,a.jsxs)(o.s,{direction:"column",w:"100%",ml:{base:"0",xs:"100px"},children:[(0,a.jsxs)(o.s,{w:"100%",justify:"space-between",direction:{base:"column",sm:"row"},gap:{base:"0.5rem",sm:"0"},mt:{base:"1rem",xs:0},children:[(0,a.jsx)(o.s,{children:(0,a.jsx)("h1",{"data-cy":"user-payment-methods",style:{marginBottom:0},children:e("paymentMethodsHeadline")})}),(0,a.jsx)(o.s,{mt:"10px",children:!f&&(0,a.jsx)(i.$,{"data-cy":"add-payment-method",onClick:()=>{x(!0)},children:e("addPaymentMethod")})})]}),f?(0,a.jsx)("div",{className:"mt-[34px]",children:(0,a.jsx)(u.default,{setShowAddCartForm:x})}):(0,a.jsx)(y.default,{},f?"hidden":"visible")]})]})]})}},99751:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/[country]/customer/payment",function(){return n(85564)}])}},e=>{e.O(0,[1078,9268,636,6593,8792],()=>e(e.s=99751)),_N_E=e.O()}]);
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.