Skip to content

Commit

Permalink
only show submit button and allow payments with USD for paypal
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelT372 committed Apr 2, 2024
1 parent a464cac commit cce8d4e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/engrid.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* ENGRID PAGE TEMPLATE ASSETS
*
* Date: Tuesday, April 2, 2024 @ 11:21:26 ET
* Date: Tuesday, April 2, 2024 @ 13:14:06 ET
* By: michael
* ENGrid styles: v0.17.19
* ENGrid scripts: v0.17.20
Expand Down Expand Up @@ -8863,7 +8863,7 @@ body[data-engrid-debug]:before{
color:#000;
}

iframe[src*=fluidads]{
body[data-engrid-page-type=donation][data-engrid-payment-type=paypal]:not([data-engrid-currency-code=USD]) .en__submit,body[data-engrid-page-type=donation][data-engrid-payment-type=paypaltouch]:not([data-engrid-currency-code=USD]) .en__submit,body[data-engrid-page-type=premiumgift][data-engrid-payment-type=paypal]:not([data-engrid-currency-code=USD]) .en__submit,body[data-engrid-page-type=premiumgift][data-engrid-payment-type=paypaltouch]:not([data-engrid-currency-code=USD]) .en__submit,iframe[src*=fluidads]{
display:none;
}
body{
Expand Down
13 changes: 12 additions & 1 deletion dist/engrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* ENGRID PAGE TEMPLATE ASSETS
*
* Date: Tuesday, April 2, 2024 @ 11:21:26 ET
* Date: Tuesday, April 2, 2024 @ 13:14:06 ET
* By: michael
* ENGrid styles: v0.17.19
* ENGrid scripts: v0.17.20
Expand Down Expand Up @@ -23146,6 +23146,17 @@ const customScript = function (App, EnForm) {
if (addRecipientButton) {
addRecipientButton.innerHTML = "Add Recipient";
}

const formInstance = EnForm.getInstance();
formInstance.onValidate.subscribe(() => {
if (!formInstance.validate) return;

if (App.getPageType() === "DONATION" && ["paypaltouch", "paypal"].includes(App.getPaymentType()) && App.getCurrencyCode() !== "USD") {
App.addHtml('<div class="en__field__error en__field__error--paypal">PayPal is only available for payments in USD. Please select another payment method or USD.</div>', ".dynamic-giving-button");
formInstance.validate = false;
return false;
}
});
};
;// CONCATENATED MODULE: ./src/index.ts
// Uses ENGrid via NPM
Expand Down
4 changes: 2 additions & 2 deletions dist/engrid.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/engrid.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/sass/page-template-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
iframe[src*="fluidads"] {
display: none;
}

body[data-engrid-page-type="donation"][data-engrid-payment-type="paypal"]:not([data-engrid-currency-code="USD"]),
body[data-engrid-page-type="donation"][data-engrid-payment-type="paypaltouch"]:not([data-engrid-currency-code="USD"]),
body[data-engrid-page-type="premiumgift"][data-engrid-payment-type="paypal"]:not([data-engrid-currency-code="USD"]),
body[data-engrid-page-type="premiumgift"][data-engrid-payment-type="paypaltouch"]:not([data-engrid-currency-code="USD"]) {
.en__submit {
display: none;
}
}
18 changes: 18 additions & 0 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,22 @@ export const customScript = function (App, EnForm) {
if (addRecipientButton) {
addRecipientButton.innerHTML = "Add Recipient";
}

const formInstance = EnForm.getInstance();
formInstance.onValidate.subscribe(() => {
if (!formInstance.validate) return;

if (
App.getPageType() === "DONATION" &&
["paypaltouch", "paypal"].includes(App.getPaymentType()) &&
App.getCurrencyCode() !== "USD"
) {
App.addHtml(
'<div class="en__field__error en__field__error--paypal">PayPal is only available for payments in USD. Please select another payment method or USD.</div>',
".dynamic-giving-button"
);
formInstance.validate = false;
return false;
}
});
};

0 comments on commit cce8d4e

Please sign in to comment.