Skip to content

Commit

Permalink
fix: prevent JS error when refunding non-moneris payments
Browse files Browse the repository at this point in the history
  • Loading branch information
DevinWalker committed Jan 24, 2019
1 parent 146a688 commit 5b0e243
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions assets/src/js/admin/give-moneris-admin.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
document.addEventListener( 'DOMContentLoaded', () => {

const donationStatus = document.getElementById( 'give-payment-status' );
const donationStatus = document.getElementById( 'give-payment-status' );

if ( null !== donationStatus ) {
donationStatus.addEventListener( 'change', ( event ) => {
if ( null !== donationStatus ) {
donationStatus.addEventListener( 'change', ( event ) => {

document.getElementById( 'give-moneris-opt-refund' ).checked = false;
let monerisRefundCheckbox = document.getElementById( 'give-moneris-opt-refund' );

// If donation status is complete, then show refund checkbox
if ( 'refunded' === event.target.value ) {
document.getElementById( 'give-moneris-opt-refund-wrap' ).style.display = 'block';
} else {
document.getElementById( 'give-moneris-opt-refund-wrap' ).style.display = 'none';
}
});
}
});
if ( null === monerisRefundCheckbox) {
return;
}

monerisRefundCheckbox.checked = false;

// If donation status is complete, then show refund checkbox
if ( 'refunded' === event.target.value ) {
document.getElementById( 'give-moneris-opt-refund-wrap' ).style.display = 'block';
} else {
document.getElementById( 'give-moneris-opt-refund-wrap' ).style.display = 'none';
}
} );
}
} );

0 comments on commit 5b0e243

Please sign in to comment.