1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1629],{10254:(e,r,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/vouchers",function(){return l(38248)}])},38248:(e,r,l)=>{"use strict";l.r(r),l.d(r,{__N_SSG:()=>U,default:()=>V});var o=l(37876),a=l(15039),n=l.n(a),i=l(89033),s=l(14232),t=l(16253),d=l(69936),c=l(85426),u=l(54893),m=l(89099),h=l(66497),p=l(4359),v=l(32429),x=l(20596),y=l(12099),f=l(57303),g=l(33833),_=l(52615),j=l(85945);function b(e){let{multiplierContext:r,onRedeemed:l}=e,{t:a}=(0,i.Bd)(["voucher","order"]),{locale:n}=(0,m.useRouter)(),[t,c]=(0,s.useState)(""),[u,b]=(0,s.useState)(!1),[N,A]=(0,s.useState)(""),[w,S]=(0,s.useState)(""),[C,k]=(0,s.useState)(null),[I]=(0,y.AM)(x.nQp),q=(0,s.useId)(),E={multiplierContext:r,formatMoney:(e,r)=>(0,f.up)(e,n,r)},O=async e=>{e.preventDefault();let r=t.trim();if(r&&!u){b(!0),A(""),S("");try{var o,i;let e=await I({variables:{code:r},fetchPolicy:"network-only"}),s=(0,g.y)(null==e||null==(i=e.data)||null==(o=i.promotions)?void 0:o.attemptPromotionRedemption),t=(0,_.i)(s,a,E);if("error"===s.kind)return void A(t.message);if(await (null==l?void 0:l(s)),c(""),"crumbs"===s.kind)return void k(s.amount);let d="voucher"===s.kind?(0,j.U)({applicableStoreIds:s.applicableStoreIds,applicableStores:s.applicableStores,locale:n,t:a}):null;S([t.message,null==d?void 0:d.validAt].filter(Boolean).join(" "))}catch(e){A(a("order:unexpected_error_adding_promo_code"))}finally{b(!1)}}};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("form",{className:"flex flex-col gap-2 w-full max-w-[400px]",onSubmit:e=>{O(e)},children:[(0,o.jsx)(h.A,{label:a("voucher:enter_promo_code"),name:"promoCode",value:t,autoComplete:"off",disabled:u,"aria-invalid":!!N,"aria-describedby":N||w?q:void 0,onChange:e=>{c(e.target.value),A(""),S("")}}),(0,o.jsx)(p.A,{type:"submit",disabled:!t.trim()||u,block:!0,children:a("voucher:redeem_promo_code")}),N?(0,o.jsx)(d.A,{id:q,variant:"body2",className:"text-error-red",role:"alert",children:N}):null,w?(0,o.jsx)(d.A,{id:q,variant:"body2",role:"status","aria-live":"polite",children:w}):null]}),(0,o.jsx)(v.A,{isOpen:null!==C,earnedAmount:null!=C?C:0,onClose:()=>k(null)})]})}var N=l(67157),A=l(55319),w=l(46637),S=l(23289),C=l(56557),k=l.n(C),I=l(54587),q=l.n(I),E=l(31805);function O(e){let{isOpen:r,onClose:l,voucherName:a,qrCodeUrl:n,expiresAt:s}=e,{t}=(0,i.Bd)();return(0,o.jsx)(E.A,{isOpen:r,onClose:l,variant:"primary",title:a,children:(0,o.jsx)("div",{className:"flex flex-col items-center gap-5 p-8",children:n?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(q(),{src:n,alt:"voucher QR code",width:200,height:200}),(0,o.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,o.jsx)(d.A,{variant:"smallHeader",children:t("account-V2:scan_to_use_in_store")}),s&&(0,o.jsx)(d.A,{variant:"finePrint",className:"text-grey-60",children:t("account-V2:expires_x",{x:k()(s).format("MM/DD/YYYY")})})]})]}):(0,o.jsx)(d.A,{variant:"body1",className:"text-grey-60",children:t("common:error_loading_vouchers","Error loading QR code")})})})}var R=l(65432),U=!0;function V(){var e,r;let{t:l}=(0,i.Bd)(),{customer:a}=(0,c.L)(),{isAuthenticating:m}
1=(0,u.N)(),[h,p]=(0,s.useState)(null),{data:v,loading:x,error:y,refetch:f}=(0,w.Fn)({customerId:null==a?void 0:a.userId}),g=(null==v||null==(r=v.customer)||null==(e=r.customer)?void 0:e.activeVouchers)||[],_=["primary","secondary","primary-light","secondary-light"];return m?(0,o.jsx)("div",{className:"fixed z-50 inset-0 backdrop-blur",children:(0,o.jsx)("div",{className:"flex flex-col items-center justify-center w-full h-full",children:(0,o.jsx)("div",{className:"w-24 h-24 sm:w-32 sm:h-32 lg:w-36 lg:h-36",children:(0,o.jsx)(t.A,{})})})}):(0,o.jsx)(R.A,{headerVariant:"primary",overrideOpenGraphTitle:l("common:my_vouchers","My Vouchers"),overrideOpenGraphDescription:l("common:my_vouchers_description","View your vouchers and redeem them on your next order."),footer:!1,children:(0,o.jsxs)("div",{className:n()("flex md:py-12 gap-[3.12rem] w-full","py-5"),children:[(0,o.jsx)(S.U,{}),(0,o.jsx)("div",{className:"px-[15px] md:px-[2rem] xl:px-[3.12rem] md:border-l border-grey-10 w-full",children:(0,o.jsxs)("div",{className:"flex flex-col gap-[20px]",children:[(0,o.jsx)(d.A,{variant:"display3",as:"h1",children:l("common:my_vouchers","My Vouchers")}),(0,o.jsx)(b,{multiplierContext:"account",onRedeemed:async e=>{"voucher"===e.kind&&await f()}}),x&&(0,o.jsx)(d.A,{variant:"body1",className:"text-grey-60",children:l("common:loading_vouchers","Loading vouchers...")}),y&&(0,o.jsx)(d.A,{variant:"body1",className:"text-grey-60",children:l("common:error_loading_vouchers","Error loading vouchers")}),!x&&!y&&0===g.length&&(0,o.jsx)(d.A,{variant:"body1",className:"text-grey-60",children:l("common:no_vouchers","You don't have any vouchers yet.")}),!x&&!y&&g.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-[15px] justify-items-center md:justify-items-start",children:g.map((e,r)=>{let a=_[r%_.length];return(0,o.jsx)(N.A,{variant:a,name:e.name||"",description:e.description||void 0,requirementText:(0,A.F)(e.redemptionRequirements,l),applicableStoreIds:e.applicableStoreIds,applicableStores:e.applicableStores,showQRCodeIndicator:!0,onClick:()=>{var r,l;return p({name:e.name||"",qrCodeUrl:null==(r=e.qrCodeUrl)?void 0:r.url,expiresAt:null==(l=e.qrCodeUrl)?void 0:l.expiresAt})},className:n()("transition-transform duration-200 hover:-translate-y-1",r!==g.length-1&&"md:mb-0 mb-[-140px]")},e.voucherId)})}),(0,o.jsx)(O,{isOpen:!!h,onClose:()=>p(null),voucherName:(null==h?void 0:h.name)||"",qrCodeUrl:null==h?void 0:h.qrCodeUrl,expiresAt:null==h?void 0:h.expiresAt})]})]})})]})})}}},e=>{e.O(0,[4e3,9555,2753,1221,5432,6151,6508,5997,636,6593,8792],()=>e(e.s=10254)),_N_E=e.O()}]); 2//# sourceMappingURL=vouchers-7d928aeb8de4fa89.js.map
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.