GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 77d15137 authored by Stephanie Kirtiadi's avatar Stephanie Kirtiadi
Browse files

Fix perk selection when other amount is selected.

The initial symptom is that when an "other" amount is
selected after a perk tile is clicked, and the amount
is less than the minimum amount for the perk, the perk
is not cancelled. This causes a perk to be selected
in Civi though no perk is true, instead of blank.
A perk selection cancellation is now implemented if such
condition happens.

Issue #49118
parent 92831598
......@@ -792,7 +792,7 @@ module.exports={AF:["Badakhshan","Badghis","Baghlan","Balkh","Bamian","Farah","F
},{"react":"n8MK"}],"mAXL":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FrequencySelector=r;var e=t(require("react")),n=require("./frequency_option_button");function t(e){return e&&e.__esModule?e:{default:e}}function r(t){var r=t.frequencyOptions,u=t.frequency,o=t.onFrequencySelection;return"both"!=r?null:e.default.createElement("div",{className:"donate-options"},e.default.createElement(n.FrequencyOptionButton,{frequency:u,onFrequencySelection:o,name:"single"}),e.default.createElement(n.FrequencyOptionButton,{frequency:u,onFrequencySelection:o,name:"monthly"}))}
},{"react":"n8MK","./frequency_option_button":"Q3Rq"}],"eHoI":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports._GivingForm=j,exports.GivingForm=void 0;var e=m(require("react")),r=require("react-stripe-elements"),t=require("./donation_prices"),n=require("./validators"),i=require("./named_error"),a=require("./payment_option_button"),o=require("./perk_selection_section"),u=require("./giving_info_form"),c=require("./giving_error_container"),l=require("./settings"),s=require("./app_context"),f=require("./loading_dialog_react_pages"),d=require("./frequency_selector");function p(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return p=function(){return e},e}function m(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=p();if(r&&r.has(e))return r.get(e);var t={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=n?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(t,i,a):t[i]=e[i]}return t.default=e,r&&r.set(e,t),t}function h(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?h(Object(t),!0).forEach(function(r){v(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function v(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function g(e,r,t,n,i,a,o){try{var u=e[a](o),c=u.value}catch(l){return void t(l)}u.done?r(c):Promise.resolve(c).then(n,i)}function b(e){return function(){var r=this,t=arguments;return new Promise(function(n,i){var a=e.apply(r,t);function o(e){g(a,n,i,o,u,"next",e)}function u(e){g(a,n,i,o,u,"throw",e)}o(void 0)})}}function w(e){return E(e)||k(e)||S()}function S(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function k(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function E(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}function O(e,r){return F(e)||x(e,r)||P()}function P(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function x(e,r){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var t=[],n=!0,i=!1,a=void 0;try{for(var o,u=e[Symbol.iterator]();!(n=(o=u.next()).done)&&(t.push(o.value),!r||t.length!==r);n=!0);}catch(c){i=!0,a=c}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}return t}}function F(e){if(Array.isArray(e))return e}function j(r){var p=r.stripe,m=r.frequencyOptions,h=r.pricesOnButtons,v=r.donateProccessorBaseUrl,g=r.perks,S=r.initialSelectedPrices,k=r.defaultFrequencyForBoth,E=r.successRedirectUrl,P=r.shirtFits,x=r.showGifts,F=O((0,e.useState)("both"==m?k:m),2),j=F[0],N=F[1],q=l.displayPerkSelections[j],A=O((0,e.useState)(!0),2),_=A[0],z=A[1],C=O((0,e.useState)(S[j]),2),T=C[0],D=C[1],B=O((0,e.useState)(null),2),M=B[0],R=B[1],U=O((0,e.useState)("strength-in-numbers"),2),I=U[0],L=U[1],G=O((0,e.useState)("credit-card"),2),Y=G[0],J=G[1],W=O((0,e.useState)(!1),2),H=W[0],V=W[1],$=O((0,e.useState)(!1),2),K=$[0],Q=$[1],X=O((0,e.useState)([]),2),Z=X[0],ee=X[1],re=O((0,e.useState)({cardNumber:new i.NamedError("cardNumber","Your card number is incomplete."),cardExpiry:new i.NamedError("cardExpiry","Your card's expiration date is incomplete."),cardCvc:new i.NamedError("cardCvc","Your card's security code is incomplete.")}),2),te=re[0],ne=re[1],ie=O((0,e.useState)({shirt1Fit:null,shirt2Fit:null,shirt1Size:null,shirt2Size:null,sweatshirtSize:null}),2),ae=ie[0],oe=ie[1],ue=O((0,e.useState)({firstName:null,lastName:null,email:null,country:"US",region:null}),2),ce=ue[0],le=ue[1],se=(0,e.useContext)(s.AppContext),fe=E.trim();""==fe&&(fe="donate-thank-you"),fe=se.assetBaseUrl.path+fe;var de=(0,e.useRef)(null),pe=function(){return(0,l.requiredFields)(Y,M)};(0,e.useEffect)(function(){null!=(0,i.findErrorByName)(Z,"donationLessThanTwo")&&de.current.focus()});var me=function(e){return g.find(function(r){return r.name==e})},he=function(e){var r=null,t=!0,n=!1,i=void 0;try{for(var a,o=g[Symbol.iterator]();!(t=(a=o.next()).done);t=!0){var u=a.value;e>=u.price[j]&&(r=u.name)}}catch(c){n=!0,i=c}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return r},ye=function(){var e={};for(var r in ce){var t=ce[r];t&&(e[r]=t)}return _&&(e["no-perk-checkbox"]=_),"t-shirt-pack"==M?(e.Fit=ae.shirt2Fit,e.Size=ae.shirt2Size):(e.Fit="--none--",e.Size="--none--"),e},ve=function(){var e={name:"none"};return M&&(e.name=M,"t-shirt"==M?(e["size-1"]=ae.shirt1Size,e["fit-1"]=ae.shirt1Fit,e["style-1"]="take-back-internet"):"t-shirt-pack"==M?(e["style-1"]=I,e["fit-1"]=ae.shirt2Fit,e["fit-2"]=ae.shirt1Fit,e["size-1"]=ae.shirt2Size,e["size-2"]=ae.shirt1Size):"sweatshirt"==M&&(e["size-1"]=ae.sweatshirtSize)),e},ge=function(e,r,t){return r in e&&t(e[r])},be=function(e){return e in l.textFields?l.textFields[e].placeholder:null},we=function(){var e=[],r=pe(),t=!0,a=!1,o=void 0;try{for(var u,c=r[Symbol.iterator]();!(t=(u=c.next()).done);t=!0){var l=u.value;if(!ge(ce,l,n.isNotBlank)){var s=be(l);null==s&&(s=l);var f=s+" must be filled out";e.push(new i.NamedError(l,f))}}}catch(S){a=!0,o=S}finally{try{t||null==c.return||c.return()}finally{if(a)throw o}}ge(ce,"email",n.isValidEmail)||e.push(new i.NamedError("email","Invalid email")),T<200&&e.push(new i.NamedError("donationLessThanTwo","$2 minimum donation"));var d,p=null!=(d=me(M))?d.requiredFields:[],m=!0,h=!1,y=void 0;try{for(var v,g=p[Symbol.iterator]();!(m=(v=g.next()).done);m=!0){var b=v.value;ge(ae,b,n.isNotBlank)||e.push(new i.NamedError(b,b+" must be filled out"))}}catch(S){h=!0,y=S}finally{try{m||null==g.return||g.return()}finally{if(h)throw y}}if("credit-card"==Y)for(var w in te)e.push(te[w]);return e},Se=function(){var e={};for(var r in l.stripeTokenFieldMap){var t=l.stripeTokenFieldMap[r];r in ce&&(e[t]=ce[r])}return e},ke=function(){var e=b(regeneratorRuntime.mark(function e(r){var t,n,a,o,u,c,l,s,f,d,m,h,y;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("credit-card"!=Y){e.next=27;break}if(r.preventDefault(),0!=(t=we()).length){e.next=26;break}return Q(!0),n=Se(),e.next=8,p.createToken(n);case 8:if(!("token"in(a=e.sent))){e.next=25;break}return o=a.token.id,u=ye(),c=ve(),l=!1,"monthly"==j&&(l=!0),s={headers:{"Content-Type":"application/json; charset=UTF-8",Accept:"application/json, text/html"},method:"POST",body:JSON.stringify({token:o,amount:T,fields:u,paymentMethod:{name:"credit_card"},perk:c,recurring:l}),credentials:"include"},e.next=18,fetch(v+"/process-stripe",s);case 18:return f=e.sent,e.next=21,f.json();case 21:(d=e.sent).errors.length>0?(m=new Array,d.errors.forEach(function(e){m.push(e)}),h=m.join("\n"),Q(!1),t.push(new i.NamedError("stripeError",h))):window.location.href=fe,e.next=26;break;case 25:"error"in a&&(y=a.error.message,t.push(new i.NamedError("stripeError",y)),Q(!1));case 26:ee(t);case 27:case"end":return e.stop()}},e)}));return function(r){return e.apply(this,arguments)}}(),Ee=function(){var e=b(regeneratorRuntime.mark(function e(r,t){var n,a,o,u,c,l,s,f;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=we()).length>0)){e.next=4;break}throw ee(n),new Error("validation errors");case 4:return ee([]),a=!1,"monthly"==j&&(a=!0),o={credentials:"include",headers:{Accept:"application/json, text/html","Content-Type":"application/json"},method:"POST",body:JSON.stringify({amount:T,recurring:a})},e.next=10,fetch("".concat(v,"/setExpressCheckout"),o);case 10:return u=e.sent,e.next=13,u.json();case 13:if(!("token"in(c=e.sent))){e.next=18;break}return e.abrupt("return",c.token);case 18:if(!("errors"in c)){e.next=26;break}throw toggleLoading(!1),l=c.errors.join("\n"),n.push(new i.NamedError("paypalError",l)),ee(n),new Error(l);case 26:return e.next=28,u.text();case 28:throw s=e.sent,f="Invalid response from /setExpressCheckout: "+u.status+": "+s,n.push(new i.NamedError("paypalError",f)),ee(n),new Error(f);case 33:case"end":return e.stop()}},e)}));return function(r,t){return e.apply(this,arguments)}}(),Oe=function(e){J(e.target.getAttribute("name")),ee([])},Pe=null;return"True"==x&&(Pe=e.default.createElement(o.PerkSelectionSection,{displayPerkSelection:q,noPerk:_,onNoPerkCheckboxChange:function(e){R(_?he(T):null),z(e.target.checked)},perks:g,onPerkSelection:function(e,r){var t=e.target.getAttribute("name");T>=r.price[j]&&(z(!1),R(t))},selectedPrice:T,selectedPerk:M,setPerkOption:L,perkOption:I,frequency:j})),e.default.createElement(e.default.Fragment,null,e.default.createElement(d.FrequencySelector,{frequencyOptions:m,frequency:j,onFrequencySelection:function(e){N(e),D(S[e])}}),e.default.createElement("form",{action:"/donate",method:"POST",id:"donationForm",onSubmit:ke},e.default.createElement("div",{className:"donation-selection-area"},e.default.createElement(t.DonationPrices,{onPriceChange:function(e){D(e),null==he(e)||_?z(!0):R(he(e))},pricesOnButtons:h[j],selectedPrice:T,priceOtherUseRef:de}),Pe,e.default.createElement("div",{className:"totals-area"})),e.default.createElement("div",{className:"payment-method-area"},e.default.createElement("h4",{className:"payment-method-question"},"how do you want to ",e.default.createElement("span",{className:"lime"},"DONATE"),"?"),e.default.createElement("div",{className:"payment-option"},(0,l.getPaymentMethods)(se).map(function(r){return e.default.createElement(a.PaymentOptionButton,{key:r.name,method:r,paymentMethod:Y,onPaymentSelection:Oe})}))),e.default.createElement("div",{className:"info-area"},e.default.createElement(u.GivingInfoForm,{paymentMethod:Y,mailingListOptIn:H,onMailingListOptInCheckboxChange:function(e){V(e.target.checked)},selectedPerk:M,perkOption:I,perkOptionProperties:function(e){var r=!0,t=!1,n=void 0;try{for(var i,a=g[Symbol.iterator]();!(r=(i=a.next()).done);r=!0){var o=i.value;if(null!=o.options){var u=!0,c=!1,l=void 0;try{for(var s,f=o.options[Symbol.iterator]();!(u=(s=f.next()).done);u=!0){var d=s.value;if(d.name==e)return d}}catch(p){c=!0,l=p}finally{try{u||null==f.return||f.return()}finally{if(c)throw l}}}}}catch(p){t=!0,n=p}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}}(I),shirtFits:P,sweatshirtSizes:l.sweatshirtSizes,frequency:j,selectedPrice:T,noPerk:_,selectedPerkFriendlyName:function(e){var r=!0,t=!1,n=void 0;try{for(var i,a=g[Symbol.iterator]();!(r=(i=a.next()).done);r=!0){var o=i.value;if(o.name==e)return o.friendly_name[j]}}catch(u){t=!0,n=u}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}return""}(M),requiredFields:pe(),errors:Z,textFields:l.textFields,stripeSubmitHandle:ke,formData:ce,countryChanged:function(e){le(y({},ce,{country:e.target.value}))},regionChanged:function(e){le(y({},ce,{region:e.target.value}))},onInputFieldChange:function(e){var r=e.target.getAttribute("name"),t=y({},ce);t[r]=e.target.value,le(t)},fitsAndSizes:ae,updateFitsAndSizes:function(e,r,t){if("sweatshirt"==e)oe(y({},ae,{sweatshirtSize:t}));else{var n=r.charAt(0).toUpperCase()+r.slice(1),i="".concat(e).concat(n),a=y({},ae);a[i]=t,oe(a)}},validateRequiredFieldsAndDonationAmount:we,preparePerkData:ve,prepareFieldsData:ye,createBillingAgreement:Ee,onStripeFieldChange:function(e){var r=e.elementType,t=y({},te);if(null!=e.error){var n=new i.NamedError(r,e.error.message);t[r]=n,ne(t)}else delete t[r],ne(t)},addError:function(e){ee([].concat(w(Z),[e]))},displayPerkSelection:q,donateProccessorBaseUrl:v,successRedirectUrl:fe,setLoading:Q})),e.default.createElement(c.GivingErrorContainer,{errors:Z})),e.default.createElement(f.LoadingDialogReactPages,{open:K}))}var N=(0,r.injectStripe)(j);exports.GivingForm=N;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports._GivingForm=j,exports.GivingForm=void 0;var e=m(require("react")),r=require("react-stripe-elements"),t=require("./donation_prices"),n=require("./validators"),i=require("./named_error"),a=require("./payment_option_button"),o=require("./perk_selection_section"),u=require("./giving_info_form"),c=require("./giving_error_container"),l=require("./settings"),s=require("./app_context"),f=require("./loading_dialog_react_pages"),d=require("./frequency_selector");function p(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return p=function(){return e},e}function m(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=p();if(r&&r.has(e))return r.get(e);var t={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=n?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(t,i,a):t[i]=e[i]}return t.default=e,r&&r.set(e,t),t}function h(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function y(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?h(Object(t),!0).forEach(function(r){v(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function v(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function g(e,r,t,n,i,a,o){try{var u=e[a](o),c=u.value}catch(l){return void t(l)}u.done?r(c):Promise.resolve(c).then(n,i)}function b(e){return function(){var r=this,t=arguments;return new Promise(function(n,i){var a=e.apply(r,t);function o(e){g(a,n,i,o,u,"next",e)}function u(e){g(a,n,i,o,u,"throw",e)}o(void 0)})}}function w(e){return E(e)||k(e)||S()}function S(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function k(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function E(e){if(Array.isArray(e)){for(var r=0,t=new Array(e.length);r<e.length;r++)t[r]=e[r];return t}}function O(e,r){return F(e)||x(e,r)||P()}function P(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function x(e,r){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var t=[],n=!0,i=!1,a=void 0;try{for(var o,u=e[Symbol.iterator]();!(n=(o=u.next()).done)&&(t.push(o.value),!r||t.length!==r);n=!0);}catch(c){i=!0,a=c}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}return t}}function F(e){if(Array.isArray(e))return e}function j(r){var p=r.stripe,m=r.frequencyOptions,h=r.pricesOnButtons,v=r.donateProccessorBaseUrl,g=r.perks,S=r.initialSelectedPrices,k=r.defaultFrequencyForBoth,E=r.successRedirectUrl,P=r.shirtFits,x=r.showGifts,F=O((0,e.useState)("both"==m?k:m),2),j=F[0],N=F[1],q=l.displayPerkSelections[j],A=O((0,e.useState)(!0),2),_=A[0],z=A[1],C=O((0,e.useState)(S[j]),2),T=C[0],D=C[1],B=O((0,e.useState)(null),2),M=B[0],R=B[1],U=O((0,e.useState)("strength-in-numbers"),2),I=U[0],L=U[1],G=O((0,e.useState)("credit-card"),2),Y=G[0],J=G[1],W=O((0,e.useState)(!1),2),H=W[0],V=W[1],$=O((0,e.useState)(!1),2),K=$[0],Q=$[1],X=O((0,e.useState)([]),2),Z=X[0],ee=X[1],re=O((0,e.useState)({cardNumber:new i.NamedError("cardNumber","Your card number is incomplete."),cardExpiry:new i.NamedError("cardExpiry","Your card's expiration date is incomplete."),cardCvc:new i.NamedError("cardCvc","Your card's security code is incomplete.")}),2),te=re[0],ne=re[1],ie=O((0,e.useState)({shirt1Fit:null,shirt2Fit:null,shirt1Size:null,shirt2Size:null,sweatshirtSize:null}),2),ae=ie[0],oe=ie[1],ue=O((0,e.useState)({firstName:null,lastName:null,email:null,country:"US",region:null}),2),ce=ue[0],le=ue[1],se=(0,e.useContext)(s.AppContext),fe=E.trim();""==fe&&(fe="donate-thank-you"),fe=se.assetBaseUrl.path+fe;var de=(0,e.useRef)(null),pe=function(){return(0,l.requiredFields)(Y,M)};(0,e.useEffect)(function(){null!=(0,i.findErrorByName)(Z,"donationLessThanTwo")&&de.current.focus()});var me=function(e){return g.find(function(r){return r.name==e})},he=function(e){var r=null,t=!0,n=!1,i=void 0;try{for(var a,o=g[Symbol.iterator]();!(t=(a=o.next()).done);t=!0){var u=a.value;e>=u.price[j]&&(r=u.name)}}catch(c){n=!0,i=c}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return r},ye=function(){var e={};for(var r in ce){var t=ce[r];t&&(e[r]=t)}return _&&(e["no-perk-checkbox"]=_),"t-shirt-pack"==M?(e.Fit=ae.shirt2Fit,e.Size=ae.shirt2Size):(e.Fit="--none--",e.Size="--none--"),e},ve=function(){var e={name:"none"};return M&&(e.name=M,"t-shirt"==M?(e["size-1"]=ae.shirt1Size,e["fit-1"]=ae.shirt1Fit,e["style-1"]="take-back-internet"):"t-shirt-pack"==M?(e["style-1"]=I,e["fit-1"]=ae.shirt2Fit,e["fit-2"]=ae.shirt1Fit,e["size-1"]=ae.shirt2Size,e["size-2"]=ae.shirt1Size):"sweatshirt"==M&&(e["size-1"]=ae.sweatshirtSize)),e},ge=function(e,r,t){return r in e&&t(e[r])},be=function(e){return e in l.textFields?l.textFields[e].placeholder:null},we=function(){var e=[],r=pe(),t=!0,a=!1,o=void 0;try{for(var u,c=r[Symbol.iterator]();!(t=(u=c.next()).done);t=!0){var l=u.value;if(!ge(ce,l,n.isNotBlank)){var s=be(l);null==s&&(s=l);var f=s+" must be filled out";e.push(new i.NamedError(l,f))}}}catch(S){a=!0,o=S}finally{try{t||null==c.return||c.return()}finally{if(a)throw o}}ge(ce,"email",n.isValidEmail)||e.push(new i.NamedError("email","Invalid email")),T<200&&e.push(new i.NamedError("donationLessThanTwo","$2 minimum donation"));var d,p=null!=(d=me(M))?d.requiredFields:[],m=!0,h=!1,y=void 0;try{for(var v,g=p[Symbol.iterator]();!(m=(v=g.next()).done);m=!0){var b=v.value;ge(ae,b,n.isNotBlank)||e.push(new i.NamedError(b,b+" must be filled out"))}}catch(S){h=!0,y=S}finally{try{m||null==g.return||g.return()}finally{if(h)throw y}}if("credit-card"==Y)for(var w in te)e.push(te[w]);return e},Se=function(){var e={};for(var r in l.stripeTokenFieldMap){var t=l.stripeTokenFieldMap[r];r in ce&&(e[t]=ce[r])}return e},ke=function(){var e=b(regeneratorRuntime.mark(function e(r){var t,n,a,o,u,c,l,s,f,d,m,h,y;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("credit-card"!=Y){e.next=27;break}if(r.preventDefault(),0!=(t=we()).length){e.next=26;break}return Q(!0),n=Se(),e.next=8,p.createToken(n);case 8:if(!("token"in(a=e.sent))){e.next=25;break}return o=a.token.id,u=ye(),c=ve(),l=!1,"monthly"==j&&(l=!0),s={headers:{"Content-Type":"application/json; charset=UTF-8",Accept:"application/json, text/html"},method:"POST",body:JSON.stringify({token:o,amount:T,fields:u,paymentMethod:{name:"credit_card"},perk:c,recurring:l}),credentials:"include"},e.next=18,fetch(v+"/process-stripe",s);case 18:return f=e.sent,e.next=21,f.json();case 21:(d=e.sent).errors.length>0?(m=new Array,d.errors.forEach(function(e){m.push(e)}),h=m.join("\n"),Q(!1),t.push(new i.NamedError("stripeError",h))):window.location.href=fe,e.next=26;break;case 25:"error"in a&&(y=a.error.message,t.push(new i.NamedError("stripeError",y)),Q(!1));case 26:ee(t);case 27:case"end":return e.stop()}},e)}));return function(r){return e.apply(this,arguments)}}(),Ee=function(){var e=b(regeneratorRuntime.mark(function e(r,t){var n,a,o,u,c,l,s,f;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=we()).length>0)){e.next=4;break}throw ee(n),new Error("validation errors");case 4:return ee([]),a=!1,"monthly"==j&&(a=!0),o={credentials:"include",headers:{Accept:"application/json, text/html","Content-Type":"application/json"},method:"POST",body:JSON.stringify({amount:T,recurring:a})},e.next=10,fetch("".concat(v,"/setExpressCheckout"),o);case 10:return u=e.sent,e.next=13,u.json();case 13:if(!("token"in(c=e.sent))){e.next=18;break}return e.abrupt("return",c.token);case 18:if(!("errors"in c)){e.next=26;break}throw toggleLoading(!1),l=c.errors.join("\n"),n.push(new i.NamedError("paypalError",l)),ee(n),new Error(l);case 26:return e.next=28,u.text();case 28:throw s=e.sent,f="Invalid response from /setExpressCheckout: "+u.status+": "+s,n.push(new i.NamedError("paypalError",f)),ee(n),new Error(f);case 33:case"end":return e.stop()}},e)}));return function(r,t){return e.apply(this,arguments)}}(),Oe=function(e){J(e.target.getAttribute("name")),ee([])},Pe=null;return"True"==x&&(Pe=e.default.createElement(o.PerkSelectionSection,{displayPerkSelection:q,noPerk:_,onNoPerkCheckboxChange:function(e){R(_?he(T):null),z(e.target.checked)},perks:g,onPerkSelection:function(e,r){var t=e.target.getAttribute("name");T>=r.price[j]&&(z(!1),R(t))},selectedPrice:T,selectedPerk:M,setPerkOption:L,perkOption:I,frequency:j})),e.default.createElement(e.default.Fragment,null,e.default.createElement(d.FrequencySelector,{frequencyOptions:m,frequency:j,onFrequencySelection:function(e){N(e),D(S[e])}}),e.default.createElement("form",{action:"/donate",method:"POST",id:"donationForm",onSubmit:ke},e.default.createElement("div",{className:"donation-selection-area"},e.default.createElement(t.DonationPrices,{onPriceChange:function(e){D(e),null==he(e)||_?(z(!0),R(null)):R(he(e))},pricesOnButtons:h[j],selectedPrice:T,priceOtherUseRef:de}),Pe,e.default.createElement("div",{className:"totals-area"})),e.default.createElement("div",{className:"payment-method-area"},e.default.createElement("h4",{className:"payment-method-question"},"how do you want to ",e.default.createElement("span",{className:"lime"},"DONATE"),"?"),e.default.createElement("div",{className:"payment-option"},(0,l.getPaymentMethods)(se).map(function(r){return e.default.createElement(a.PaymentOptionButton,{key:r.name,method:r,paymentMethod:Y,onPaymentSelection:Oe})}))),e.default.createElement("div",{className:"info-area"},e.default.createElement(u.GivingInfoForm,{paymentMethod:Y,mailingListOptIn:H,onMailingListOptInCheckboxChange:function(e){V(e.target.checked)},selectedPerk:M,perkOption:I,perkOptionProperties:function(e){var r=!0,t=!1,n=void 0;try{for(var i,a=g[Symbol.iterator]();!(r=(i=a.next()).done);r=!0){var o=i.value;if(null!=o.options){var u=!0,c=!1,l=void 0;try{for(var s,f=o.options[Symbol.iterator]();!(u=(s=f.next()).done);u=!0){var d=s.value;if(d.name==e)return d}}catch(p){c=!0,l=p}finally{try{u||null==f.return||f.return()}finally{if(c)throw l}}}}}catch(p){t=!0,n=p}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}}(I),shirtFits:P,sweatshirtSizes:l.sweatshirtSizes,frequency:j,selectedPrice:T,noPerk:_,selectedPerkFriendlyName:function(e){var r=!0,t=!1,n=void 0;try{for(var i,a=g[Symbol.iterator]();!(r=(i=a.next()).done);r=!0){var o=i.value;if(o.name==e)return o.friendly_name[j]}}catch(u){t=!0,n=u}finally{try{r||null==a.return||a.return()}finally{if(t)throw n}}return""}(M),requiredFields:pe(),errors:Z,textFields:l.textFields,stripeSubmitHandle:ke,formData:ce,countryChanged:function(e){le(y({},ce,{country:e.target.value}))},regionChanged:function(e){le(y({},ce,{region:e.target.value}))},onInputFieldChange:function(e){var r=e.target.getAttribute("name"),t=y({},ce);t[r]=e.target.value,le(t)},fitsAndSizes:ae,updateFitsAndSizes:function(e,r,t){if("sweatshirt"==e)oe(y({},ae,{sweatshirtSize:t}));else{var n=r.charAt(0).toUpperCase()+r.slice(1),i="".concat(e).concat(n),a=y({},ae);a[i]=t,oe(a)}},validateRequiredFieldsAndDonationAmount:we,preparePerkData:ve,prepareFieldsData:ye,createBillingAgreement:Ee,onStripeFieldChange:function(e){var r=e.elementType,t=y({},te);if(null!=e.error){var n=new i.NamedError(r,e.error.message);t[r]=n,ne(t)}else delete t[r],ne(t)},addError:function(e){ee([].concat(w(Z),[e]))},displayPerkSelection:q,donateProccessorBaseUrl:v,successRedirectUrl:fe,setLoading:Q})),e.default.createElement(c.GivingErrorContainer,{errors:Z})),e.default.createElement(f.LoadingDialogReactPages,{open:K}))}var N=(0,r.injectStripe)(j);exports.GivingForm=N;
},{"react":"n8MK","react-stripe-elements":"VJkE","./donation_prices":"IFK5","./validators":"MLjd","./named_error":"H7H6","./payment_option_button":"Mosb","./perk_selection_section":"VVle","./giving_info_form":"NkYk","./giving_error_container":"oOOE","./settings":"LXja","./app_context":"rLZa","./loading_dialog_react_pages":"BxcR","./frequency_selector":"mAXL"}],"d7BQ":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useInterval=n;var e=r(require("react"));function t(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return t=function(){return e},e}function r(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=t();if(r&&r.has(e))return r.get(e);var n={},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in e)if(Object.prototype.hasOwnProperty.call(e,f)){var o=u?Object.getOwnPropertyDescriptor(e,f):null;o&&(o.get||o.set)?Object.defineProperty(n,f,o):n[f]=e[f]}return n.default=e,r&&r.set(e,n),n}function n(t,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],u=(0,e.useRef)();(0,e.useEffect)(function(){u.current=t},[t]),(0,e.useEffect)(function(){function e(){u.current()}if(n&&e(),null!==r){var t=setInterval(e,r);return function(){return clearInterval(t)}}},[r])}
},{"react":"n8MK"}],"WZxZ":[function(require,module,exports) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -88,6 +88,7 @@ export function _GivingForm(props) {
setSelectedPrice(price);
if (getDefaultPerk(price) == null || noPerk) {
setNoPerk(true);
setSelectedPerk(null);
} else {
setSelectedPerk(getDefaultPerk(price));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment