Module 768161

3,322 characters · in f9c35367692d5f8a.js
Dependencies
Required by (0)none
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(l,e,t){t.d(e,{default:()=>U});var n=t(627968),a=t(64700),r=t(96337),u=t(997101),s=t(17928),i=t(189213),o=t(783878),d=t(292666),c=t(683071),C=t(753390),h=t(500380),g=t(423764),p=t(295405),f=t(99696),m=t(667455),E=t(652215),y=t(818348),R=t(375708),b=t(776409),S=t(133112);let j=r.A.filter(l=>u.M.EURO_CURRENCY_COUNTRIES.has(l.alpha2)).map(l=>({id:l.alpha2,value:l.alpha2,label:(0,g.Gw)(l.alpha2),leading:(0,n.jsx)("img",{alt:"",src:(0,h.t)(l.alpha2),style:{height:18}})}));function x(l){let{codeInput:e,isEU:t,postalCodeInput:a,selectedBillingCountry:r,redemptionError:u,codeError:s,billingError:i,onCodeInputChange:C,onPostalCodeChange:h,onBillingCountryChange:g}=l;return(0,n.jsxs)("div",{className:S.Xj,children:[null!=u&&(0,n.jsx)(c.w,{type:"critical",children:u}),(0,n.jsx)("span",{className:S.ZY,children:(0,n.jsx)(d.k,{label:R.intl.string(b.default["Bn/CZQ"]),type:"text",value:e,onChange:C,placeholder:R.intl.string(b.default.dSPkHo),error:s,fullWidth:!0})}),t?(0,n.jsx)(o.Z,{selectionMode:"single",label:R.intl.string(R.t.eDdrAD),placeholder:R.intl.string(R.t.eDdrAD),value:r,onSelectionChange:g,options:j,errorMessage:i}):(0,n.jsx)(d.k,{label:R.intl.string(b.default["3jjweL"]),type:"text",value:a,onChange:h,placeholder:R.intl.string(b.default["B+/GvM"]),error:i,fullWidth:!0}),(0,n.jsx)("p",{className:S.Bm,children:R.intl.format(b.default.CCVlIb,{giftCardTermsUrl:E.X7G.PAID_TERMS,walletTermsUrl:E.X7G.PAID_TERMS})})]})}function U(l){let{transitionState:e,onClose:t,onComplete:r,initialCode:u="",withRedemptionSuccessModal:o=!1,source:d,loadId:c}=l,[E,j]=a.useState(u),[U,v]=a.useState(!1),[A,I]=a.useState(""),[k,M]=a.useState(null),[N,_]=a.useState(null),[P,T]=a.useState(null),[w,D]=a.useState(null),{isEU:O,displayCountry:B,savedPostalCode:G}=(0,m.A)(),Y=(0,s.bG)([p.A],()=>p.A.hasFetchedPaymentSources);a.useEffect(()=>{Y||(0,C.$o)()},[Y]);let L=a.useMemo(()=>({source:d,loadId:c}),[d,c]);a.useEffect(()=>{(0,f.Pc)(L)},[L]);let Z=a.useRef(!1);a.useEffect(()=>{Z.current||null==G||""!==A||(Z.current=!0,I(G),D(null))},[G,A]);let W=R.intl.string(b.default["26tjwd"]),X=a.useMemo(()=>{if(null!=B)return{text:(0,g.Gw)(B),leadingIcon:()=>(0,n.jsx)("img",{alt:"",src:(0,h.t)(B),className:S.IM})}},[B]),$=a.useCallback(l=>{j(l),T(null),_(null)},[]),z=a.useCallback(async()=>{let l=E.trim(),e=O?null==k:""===A.trim(),n=!1;if(""===l&&(T(R.intl.string(b.default.PZDPvQ)),n=!0),e&&(D(O?R.intl.string(R.t["+bm+zE"]):R.intl.string(R.t.LRlhb1)),n=!0),!n){v(!0),_(null);try{let e=await (0,f.Ng)(l,O?void 0:A.trim(),O?k??void 0:void 0);(0,f.Ey)(e,L),r?.(e),t(),o&&(0,f.cV)({amountRedeemed:e.amount,currencyCode:e.currency,loadId:L.loadId}),(0,C.$o)().then(l=>{let e=(l?.body??[]).find(l=>l.type===y.he.TDS_WALLET);null!=e&&(0,C.YP)(e.id)})}catch(l){_((0,f.tn)(l)),(0,f.k$)(L);return}finally{v(!1)}}},[E,O,k,A,r,t,o,L]),Q=a.useCallback(l=>{I(l),D(null),_(null)},[]),V=a.useCallback(l=>{M(l),D(null),_(null)},[]);return(0,n.jsx)(i.Modal,{transitionState:e,onClose:t,title:W,subtitle:X,input:(0,n.jsx)(x,{codeInput:E,isEU:O,postalCodeInput:A,selectedBillingCountry:k,redemptionError:N,codeError:P,billingError:w,onCodeInputChange:$,onPostalCodeChange:Q,onBillingCountryChange:V}),actionBarInput:(0,n.jsx)("span",{}),actions:[{variant:"primary",size:"md",text:R.intl.string(b.default.hnRau6),loading:U,onClick:z}]})}}