Build 533169stable
Module 520174
2,175 characters · in 33645dc6ae61c139.jsDependencies
Source Raw
function(e,t,n){n.d(t,{A:()=>A});var i=n(627968),s=n(64700),l=n(311907),r=n(397927),a=n(869038),o=n(459357),d=n(99696),c=n(499454),u=n(351906),m=n(954571),g=n(45938),_=n(652215),x=n(985018);class h extends s.Component{state={codeInput:"",submitting:!1,hasError:!1,isPromoCode:!1};get analyticsLocation(){let{analyticsContext:{location:e}}=this.props;return{...e,object:_.ZSU.BUTTON_CTA}}handleChange=e=>{this.setState({codeInput:e,hasError:!1})};handleSubmit=async e=>{e.preventDefault();let{codeInput:t}=this.state;if(""===t)return;let n=t.trim();this.setState({submitting:!0});try{if(this.props.acceptGiftCardRedemption)try{await (0,d.Qp)(n),(0,d.HF)({initialCode:n,withRedemptionSuccessModal:!0}),this.setState({codeInput:""});return}catch{}let e=(0,g.Vd)(t);if(null==e)return void this.setState({hasError:!0});let i=await a.A.resolveGiftCode(e);if(null!=i&&null!=i.giftCode.promotion)throw this.setState({isPromoCode:!0}),Error("Cannnot redeem promotion code as gift");m.default.track(_.HAw.OPEN_MODAL,{type:"gift_accept",location:{...this.analyticsLocation,section:_.JJy.LIBRARY_INVENTORY_CODE_REDEMPTION,object:_.ZSU.BUTTON_CTA}}),(0,c.h)({processedCode:e}),this.setState({codeInput:""})}catch(e){this.setState({hasError:!0})}finally{this.setState({submitting:!1})}};render(){let{obscureInput:e}=this.props,{codeInput:t,submitting:n,hasError:s,isPromoCode:l}=this.state;return(0,i.jsx)(r.nVY,{label:x.intl.string(x.t["il+VCo"]),children:(0,i.jsx)("form",{onSubmit:this.handleSubmit,children:(0,i.jsxs)(r.M_l,{children:[(0,i.jsx)(r.ksK,{label:x.intl.string(x.t.SeKIoS),type:e?"password":"text",value:t,onChange:this.handleChange,placeholder:"WUMP-AAAAA-BBBBB-CCCCC",error:!l&&s?x.intl.string(x.t.Y11a2u):null,helperText:l?x.intl.format(x.t.gPt3PE,{promoLink:()=>{window.open(`https://discord.com/billing/promotions/${t}`)}}):null,fullWidth:!0}),(0,i.jsx)(r.Button,{variant:"primary",text:x.intl.string(x.t.KIpp7M),type:"submit",loading:n})]})})})}}function A(){let{enabled:e}=(0,o.c)({location:"UserSettingsBilling"}),t=s.useContext(m.AnalyticsContext),n=(0,l.bG)([u.A],()=>u.A.enabled);return(0,i.jsx)(h,{analyticsContext:t,obscureInput:n,acceptGiftCardRedemption:e})}}