(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[620],{88751:function(e,r,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/gift-cards",function(){return t(56216)}])},46969:function(e,r,t){"use strict";t.d(r,{G:function(){return f}});var n=t(85893);t(67294);var i=t(86664),a=t(94184),l=t.n(a),o=t(28670),s=t.n(o),u=t(21765),c=t.n(u),d=t(64552),m=t(70921),f=function(e){var r=e.id,t=e.errorMessage,a=e.onChange,o=e.onBlur,u=e.onFocus,f=e.hasFocus,_=(0,d.f)().theme,p=(null==_?void 0:_.palette.textPrimary)||"#FFFFFF",v=(null==_?void 0:_.palette.textTertiary)||"#FFFFFF",h="".concat(s()(p)),C="".concat(s()(v));return(0,n.jsxs)("div",{className:l()(c().root,f?c().stripeFocus:"",t?c().error:""),children:[(0,n.jsx)("label",{htmlFor:r,className:c().label,children:(0,n.jsx)("span",{children:"Credit Card"})}),(0,n.jsxs)("div",{className:c().inputContainer,children:[(0,n.jsx)(i.CardElement,{id:r,onChange:a,onBlur:o,onFocus:u,className:c().stripeElem,options:{style:{base:{fontSize:"16px",color:h,fontFamily:"Avenir, Helvetica, Arial, sans-serif","::placeholder":{color:"".concat(C)},":-webkit-autofill":{color:h}},invalid:{color:"#9e2146"}}}}),(0,n.jsx)(m.d,{error:t,id:r})]})]})}},56216:function(e,r,t){"use strict";t.r(r),t.d(r,{default:function(){return q}});var n=t(85893),i=t(67294),a=t(11010),l=t(24043),o=t(20414),s=t(87536),u=t(16310),c=t(47533),d=t(48966),m=t.n(d),f=t(86664),_=t(46969),p=t(24666),v=t.n(p),h=[{label:"$10 Gift Card",value:1e3},{label:"$25 Gift Card",value:2500},{label:"$50 Gift Card",value:5e3},{label:"$75 Gift Card",value:7500},{label:"$100 Gift Card",value:1e4},{label:"$150 Gift Card",value:15e3},{label:"$200 Gift Card",value:2e4},{label:"$300 Gift Card",value:3e4},{label:"$400 Gift Card",value:4e4},{label:"$500 Gift Card",value:5e4}],C=t(14416),g=function(e){return null==e?void 0:e.giftCard},b=t(22588),x=t(30757),G=function(){var e=(0,C.v9)(g),r=(0,C.I0)();return{giftCard:e,purchaseGiftCard:function(e){var t,n,i,a,l,o;return r((t=e.client_name,n=e.client_email,i=e.client_phone,a=e.value,l=e.slug,o=e.token,function(e){e({type:b.gT});try{e(x.Z.post("/gift_cards",{params:{},data:{id:l,client_name:t,client_email:n,client_phone:i,value:a,stripe_token:o},request:b.gT,success:b.Az,failure:b.rq}))}catch(r){e({type:b.rq,payload:{error:r.error.message}})}}))},resetGiftCardState:function(){return r(function(e){e({type:b.$m})})},startGiftCardFormLoading:function(){return r({type:b.d$})},stopGiftCardFormLoading:function(){return r({type:b.bM})}}},j=t(70076),F=t(6824),E=t(50622),N=t(60781),S=t(72245),y=t(91429),P=function(){var e,r,t,d,p,C=(0,f.useStripe)(),g=(0,f.useElements)(),b=(0,S.i)().name,x=(0,y.j)().slug,P=G(),k=P.giftCard,w=P.resetGiftCardState,T=P.startGiftCardFormLoading,q=P.stopGiftCardFormLoading,$=P.purchaseGiftCard,Y=(0,l._)(i.useState(!1),2),B=Y[0],L=Y[1],M=(0,l._)(i.useState(void 0),2),A=M[0],X=M[1],Z=(0,l._)(i.useState(!1),2),O=Z[0],U=Z[1];i.useEffect(function(){w()},[]);var z=(e=(0,a._)(function(e){var r,t,n,i,a,l,s,u;return(0,o.Jh)(this,function(o){switch(o.label){case 0:if(r=e.client_email,t=e.client_name,n=e.client_phone,i=e.value,!C||!g)return[2];if(T(),!(a=g.getElement(f.CardElement)))return[3,2];return[4,C.createToken(a,{name:t})];case 1:return s=(l=o.sent()).token,(u=l.error)?(X(null==u?void 0:u.message),q()):(X(void 0),$({client_name:t,client_email:r.trim(),client_phone:(0,E.Xl)(n).substring(1),value:i,slug:x,token:s.id})),[3,3];case 2:X("There was an error submitting your card information"),o.label=3;case 3:return[2]}})}),function(r){return e.apply(this,arguments)}),D=u.Ry({client_email:u.Z_().required("Please enter Email address").test("is-email","Please enter a valid email address",function(e){return m().isEmail(e)}),client_name:u.Z_().required("Please enter Name"),client_phone:u.Z_().transform(function(e){return(0,E.Xl)(e)}).min(11,"Phone number must be 10 or 11 digits").required("Please enter Phone").test("is-james","Please enter a valid phone number",function(e){return m().isMobilePhone(e,"en-US")}),value:u.Rx().required("Please select a Gift Card amount")}).required(),I=(0,s.cI)({defaultValues:{},resolver:(0,c.X)(D),mode:"onBlur"}),J=I.register,V=I.formState.errors,W=I.control,K=I.handleSubmit;return k.success?(0,n.jsx)("div",{className:v().root,children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:v().pageTitle,children:"Your Purchase is Complete!"}),(0,n.jsx)("div",{className:v().pageSubtitle,children:"You will be receiving an email in the next 5-10 minutes with your gift card. Thank you!"})]})}):(0,n.jsxs)("div",{className:v().root,children:[(0,n.jsx)("div",{className:v().pageTitle,children:"Purchase A Gift Card"}),(0,n.jsx)("div",{className:v().pageSubtitle,children:"You can purchase gift cards from ".concat(b," here")}),(0,n.jsxs)("form",{noValidate:!0,className:v().form,onSubmit:function(e){K(z)(e)},children:[(0,n.jsx)(F.P,{id:"value",label:"Select gift card amount",name:"value",options:h,control:W,error:null===(r=V.value)||void 0===r?void 0:r.message}),(0,n.jsx)(N.U,{id:"client_name",label:"Your Name",name:"client_name",register:J("client_name"),error:null===(t=V.client_name)||void 0===t?void 0:t.message,required:!0}),(0,n.jsx)(N.U,{id:"client_email",label:"Your Email",name:"client_email",register:J("client_email"),error:null===(d=V.client_email)||void 0===d?void 0:d.message,required:!0}),(0,n.jsx)(N.U,{id:"client_phone",label:"Phone",type:"tel",name:"client_phone",control:W,error:null===(p=V.client_phone)||void 0===p?void 0:p.message,required:!0}),(0,n.jsx)(_.G,{id:"credit-card",onChange:function(e){var r;X(null===(r=e.error)||void 0===r?void 0:r.message),U(e.complete),!e.error&&e.complete&&X(void 0)},onFocus:function(){return L(!0)},onBlur:function(){O||X("Your Credit Card information is incompleted"),L(!1)},errorMessage:A,hasFocus:B}),k.error?(0,n.jsx)("div",{className:v().error,children:k.error}):(0,n.jsx)("div",{}),(0,n.jsx)(j.Z,{className:v().submitButton,loading:k.loading,disabled:k.loading||!C||!g,onClick:function(){O||X("Your Credit Card information is incompleted")},children:"Purchase Now"})]})]})},k=t(64552);function w(){var e=(0,k.f)().components.Layout;return(0,n.jsx)(e,{children:(0,n.jsx)(P,{})})}var T=function(){return(0,n.jsx)(w,{})};T.getInitialProps=function(){return{metadata:{title:"Gift Cards"}}};var q=T},21765:function(e){e.exports={root:"StripeElement_root__WyLkw",stripeElem:"StripeElement_stripeElem__Y6f3M",label:"StripeElement_label__fzP7J",inputContainer:"StripeElement_inputContainer__Ovv4O",stripeFocus:"StripeElement_stripeFocus__3WED7"}},24666:function(e){e.exports={root:"GiftCard_root__2vC5Q",pageTitle:"GiftCard_pageTitle__WV9Du",pageSubtitle:"GiftCard_pageSubtitle__hEbKq",formContent:"GiftCard_formContent__Mr1Jt",form:"GiftCard_form__dAfKT",error:"GiftCard_error___FffD",submitButton:"GiftCard_submitButton__2_9uo"}}},function(e){e.O(0,[888,774,179],function(){return e(e.s=88751)}),_N_E=e.O()}]);